microsoft/FASTER · error · Exception

Pending reads not supported with pub/sub

Error message

Pending reads not supported with pub/sub

What it means

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.

Solutions

  1. Do not issue Read operations (or reads with ReadOptions that can pend) on pub/sub sessions; use Publish/Subscribe messages only.
  2. Use a standard session (wire format backed by a store provider) instead of the pub/sub provider for read traffic.
  3. If pending semantics are required, refactor the client to poll/subscribe rather than using pending reads.

Example fix

// before
client.Read(key); // against pub/sub session
// after
client.Publish(key, value); // pub/sub sessions support publish/subscribe only
Defensive patterns

Strategy: validation

Validate before calling

// client side: only issue Publish/Subscribe on pub/sub sessions; never Read
if (sessionType == SessionType.PubSub && request is ReadRequest) throw new InvalidOperationException("Reads unsupported on pub/sub sessions");

Try / catch

try { client.Read(key); } catch (Exception) { /* fall back to a store-backed session for reads */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of microsoft/FASTER@321d872eab (2026-09-15). Data as JSON: /api/errors/a53f3a69d214c2c1. Report an issue: GitHub.

Appendix: source

Thrown at cs/remote/src/FASTER.server/BinaryServerSession.cs:290

            if (!status.IsPending)
            {
                // Write six bytes (message | status | sid)
                hrw.Write(message, ref dcurr, (int)(dend - dcurr));
                Write(ref status, ref dcurr, (int)(dend - dcurr));
                Write(sid, ref dcurr, (int)(dend - dcurr));
                if (prefix)
                    serializer.Write(ref key, ref dcurr, (int)(dend - dcurr));
                if (valPtr != null)
                {
                    ref Value value = ref serializer.ReadValueByRef(ref valPtr);
                    serializer.Write(ref value, ref dcurr, (int)(dend - dcurr));
                }
                else if (status.Found)
                    serializer.SkipOutput(ref dcurr);
            }
            else
            {
                throw new Exception("Pending reads not supported with pub/sub");
            }

            // Send replies
            var dstart = d + sizeof(int);
            Unsafe.AsRef<BatchHeader>(dstart).NumMessages = 1;
            Unsafe.AsRef<BatchHeader>(dstart).SeqNo = 0;
            int payloadSize = (int)(dcurr - d);
            // Set packet size in header
            *(int*)networkSender.GetResponseObjectHead()= -(payloadSize - sizeof(int));
            networkSender.SendResponse(0, payloadSize);
        }

        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        private static unsafe bool Write(ref Status s, ref byte* dst, int length)
        {
            if (length < 1) return false;
            *dst++ = s.Value;
            return true;

View on GitHub (pinned to 321d872eab)