{"record":{"id":"a53f3a69d214c2c1","repo":"microsoft/FASTER","slug":"pending-reads-not-supported-with-pub-sub","errorCode":null,"errorMessage":"Pending reads not supported with pub/sub","messagePattern":"Pending reads not supported with pub/sub","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"cs/remote/src/FASTER.server/BinaryServerSession.cs","lineNumber":290,"sourceCode":"            if (!status.IsPending)\n            {\n                // Write six bytes (message | status | sid)\n                hrw.Write(message, ref dcurr, (int)(dend - dcurr));\n                Write(ref status, ref dcurr, (int)(dend - dcurr));\n                Write(sid, ref dcurr, (int)(dend - dcurr));\n                if (prefix)\n                    serializer.Write(ref key, ref dcurr, (int)(dend - dcurr));\n                if (valPtr != null)\n                {\n                    ref Value value = ref serializer.ReadValueByRef(ref valPtr);\n                    serializer.Write(ref value, ref dcurr, (int)(dend - dcurr));\n                }\n                else if (status.Found)\n                    serializer.SkipOutput(ref dcurr);\n            }\n            else\n            {\n                throw new Exception(\"Pending reads not supported with pub/sub\");\n            }\n\n            // Send replies\n            var dstart = d + sizeof(int);\n            Unsafe.AsRef<BatchHeader>(dstart).NumMessages = 1;\n            Unsafe.AsRef<BatchHeader>(dstart).SeqNo = 0;\n            int payloadSize = (int)(dcurr - d);\n            // Set packet size in header\n            *(int*)networkSender.GetResponseObjectHead()= -(payloadSize - sizeof(int));\n            networkSender.SendResponse(0, payloadSize);\n        }\n\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        private static unsafe bool Write(ref Status s, ref byte* dst, int length)\n        {\n            if (length < 1) return false;\n            *dst++ = s.Value;\n            return true;","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/remote/src/FASTER.server/BinaryServerSession.cs#L272-L308","documentation":"BinaryServerSession.Publish rejects batches that contain read operations with pending completions. In pub/sub mode FASTER server sessions only support fire-and-forget publish/subscribe semantics; a client sent a Read whose status is Pending (e.g. with async read modals or ReadOptions that make reads complete later), which the pub/sub reply path cannot serialize, so it throws.","triggerScenarios":"Sending a ReadRequest over the binary wire protocol to a session whose backend provider is the pub/sub session (BinaryServerSession.Publish path) where the read returns status Pending — e.g. reads issued with ReadOptions/CheckpointId that defer completion, or CacheHit/Pending combos in InMemoryPubSub.","commonSituations":"Pointing a client at the pub/sub wire format/subsystem while issuing normal keyed reads that can pend; using ReadOptions (PullIterator or pinning) against a subscription backend; mixing read-modify-write/pending-read traffic into a messaging-style workload.","solutions":["Do not issue Read operations (or reads with ReadOptions that can pend) on pub/sub sessions; use Publish/Subscribe messages only.","Use a standard session (wire format backed by a store provider) instead of the pub/sub provider for read traffic.","If pending semantics are required, refactor the client to poll/subscribe rather than using pending reads."],"exampleFix":"// before\nclient.Read(key); // against pub/sub session\n// after\nclient.Publish(key, value); // pub/sub sessions support publish/subscribe only","handlingStrategy":"validation","validationCode":"// client side: only issue Publish/Subscribe on pub/sub sessions; never Read\nif (sessionType == SessionType.PubSub && request is ReadRequest) throw new InvalidOperationException(\"Reads unsupported on pub/sub sessions\");","typeGuard":null,"tryCatchPattern":"try { client.Read(key); } catch (Exception) { /* fall back to a store-backed session for reads */ }","preventionTips":["Match operation types to session kind: reads to store sessions, publish/subscribe to pub/sub sessions.","Avoid ReadOptions that produce pending reads when using pub/sub backends."],"tags":["csharp","faster","pubsub","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"321d872eabda6a0345c8bd76419f89723ed864ae","analyzedAt":"2026-09-15T22:18:00.693Z","contentChangedAt":"2026-09-15T22:18:00.693Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}