{"record":{"id":"f27632e0f7a35a21","repo":"microsoft/FASTER","slug":"the-outer-list-is-empty","errorCode":null,"errorMessage":"The outer list is empty!","messagePattern":"The outer list is empty!","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"cs/remote/src/FASTER.common/ElasticCircularBuffer.cs","lineNumber":154,"sourceCode":"        /// Enqueue\n        /// </summary>\n        /// <param name=\"value\"></param>\n        public void Enqueue(T value)\n        {\n            Enqueue(ref value);\n        }\n\n        /// <summary>\n        /// Dequeue\n        /// </summary>\n        /// <returns></returns>\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public T Dequeue()\n        {\n            if (head.Value.IsEmpty())\n            {\n                if (head == tail)\n                    throw new InvalidOperationException(\"The outer list is empty!\");\n\n                var temp = head;\n                head = head.Next;\n                if (head == null) head = buffers.First;\n                temp.Value.Sealed = false;\n            }\n            return head.Value.Dequeue();\n        }\n\n        /// <summary>\n        /// Peek at head\n        /// </summary>\n        /// <returns></returns>\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        public T PeekFirst()\n        {\n            if (head.Value.head == head.Value.tail)\n            {","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/remote/src/FASTER.common/ElasticCircularBuffer.cs#L136-L172","documentation":"ElasticCircularBuffer<T>.Dequeue found the head segment empty and, because head == tail, the entire outer buffer list is empty — no segment anywhere holds an item. The library throws InvalidOperationException instead of returning a default T, surfacing empty-state misuse of the elastic queue.","triggerScenarios":"Dequeue called when all segments are drained and the outer list holds only the empty head segment equal to tail — consumers polling with no producers active.","commonSituations":"Consumer threads spinning on Dequeue during idle periods; multiple consumers racing to dequeue the last item; shutdown ordering where consumers outlive producers.","solutions":["Check emptiness (or use TryDequeue-style logic) before Dequeue.","Coordinate consumers with a condition/semaphore so they sleep while the queue is empty.","Serialize consumer access so a single dequeue consumes each available item exactly once."],"exampleFix":"// before\nvar item = elasticQueue.Dequeue();\n\n// after\nif (!elasticQueue.IsEmpty())\n{\n    var item = elasticQueue.Dequeue();\n}","handlingStrategy":"validation","validationCode":"if (elasticQueue.IsEmpty()) return default; // or block on a signal\nvar item = elasticQueue.Dequeue();","typeGuard":null,"tryCatchPattern":"try { item = elasticQueue.Dequeue(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"outer list is empty\"))\n{\n    item = default; // fully drained; wait for producers\n}","preventionTips":["Use empty checks or TryDequeue semantics before each dequeue.","Park idle consumers on a wait handle instead of busy-polling.","Serialize consumer threads or hand each item to exactly one consumer.","During shutdown, stop consumers before/with producers, not after the queue drains."],"tags":["csharp","buffer","empty","faster"],"backgroundTag":"empty-result-set","analyzedSha":"321d872eabda6a0345c8bd76419f89723ed864ae","analyzedAt":"2026-09-15T22:18:00.693Z","contentChangedAt":"2026-09-15T22:18:00.693Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}