microsoft/FASTER · error · Exception

Unexpected sealed buffer found

Error message

Unexpected sealed buffer found

What it means

In the elastic (multi-segment) Enqueue, when the current segment is full the library moves to the next buffer; if that tail buffer is marked Sealed (drained/inactive), enqueueing into it would corrupt the ring's lifecycle invariants. The library throws instead of proceeding, signaling a bug in segment sealing/rotation logic or concurrent misuse of the buffer.

Solutions

  1. Synchronize all Enqueue/Dequeue access with a lock or use only from a single thread per direction.
  2. Inspect and fix custom modifications to segment sealing/rotation logic if you maintain a fork.
  3. Recreate the buffer instance if it entered a bad state; do not attempt to continue after this exception.

Example fix

// before: concurrent producers
queue.Enqueue(ref item); // from many threads

// after
lock (queueLock) { queue.Enqueue(ref item); }
Defensive patterns

Strategy: try-catch

Try / catch

try { elasticQueue.Enqueue(ref item); }
catch (Exception ex) when (ex.Message == "Unexpected sealed buffer found")
{
    // buffer lifecycle is corrupted; rebuild the queue and report
    log.Fatal(ex, "ElasticCircularBuffer invariants violated");
    elasticQueue = new ElasticCircularBuffer<T>();
}

Prevention

When it happens

Trigger: Concurrent Enqueue/Dequeue from multiple threads without synchronization causing segment rotation to race; enqueuing after a segment was sealed but before a new one is linked; corrupt internal buffer list state.

Common situations: Using the elastic circular buffer as a lock-free queue from multiple producer threads when it is not safe for that pattern; mixing elastic and single-buffer APIs on the same instance.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at cs/remote/src/FASTER.common/ElasticCircularBuffer.cs:130

        public void Enqueue(ref T value)
        {
            if (tail.Value.IsFull())
            {
                tail.Value.Sealed = true;
                var next = tail.Next;
                if (next == null) next = buffers.First;
                if (next.Value.Sealed)
                {
                    next = new LinkedListNode<CircularBuffer<T>>(new CircularBuffer<T>());
                    buffers.AddAfter(tail, next);
                }
                next.Value.Enqueue(ref value);
                tail = next;
            }
            else
            {
                if (tail.Value.Sealed)
                    throw new Exception("Unexpected sealed buffer found");
                tail.Value.Enqueue(ref value);
            }
        }

        /// <summary>
        /// Enqueue
        /// </summary>
        /// <param name="value"></param>
        public void Enqueue(T value)
        {
            Enqueue(ref value);
        }

        /// <summary>
        /// Dequeue
        /// </summary>
        /// <returns></returns>
        [MethodImpl(MethodImplOptions.AggressiveInlining)]

View on GitHub (pinned to 321d872eab)