{"record":{"id":"b1853cb2f2117a2c","repo":"microsoft/FASTER","slug":"can-spin-wait-for-commit-checkpoint-completion-only-if-wait","errorCode":null,"errorMessage":"Can spin-wait for commit (checkpoint completion) only if wait is true","messagePattern":"Can spin-wait for commit \\(checkpoint completion\\) only if wait is true","errorType":"exception","errorClass":"FasterException","httpStatus":null,"severity":"error","filePath":"cs/src/core/ClientSession/ClientSession.cs","lineNumber":856,"sourceCode":"            try\n            {\n                return UnsafeCompletePending(FasterSession, getOutputs, wait, spinWaitForCommit);\n            }\n            finally\n            {\n                UnsafeSuspendThread();\n            }\n        }\n\n        internal bool UnsafeCompletePending<FasterSession>(FasterSession fasterSession, bool getOutputs, bool wait, bool spinWaitForCommit)\n            where FasterSession : IFasterSession<Key, Value, Input, Output, Context>\n        {\n            var requestedOutputs = getOutputs ? this.completedOutputs : default;\n            var result = fht.InternalCompletePending(fasterSession, wait, requestedOutputs);\n            if (spinWaitForCommit)\n            {\n                if (!wait)\n                    throw new FasterException(\"Can spin-wait for commit (checkpoint completion) only if wait is true\");\n                do\n                {\n                    fht.InternalCompletePending(fasterSession, wait, requestedOutputs);\n                    if (fht.InRestPhase())\n                    {\n                        fht.InternalCompletePending(fasterSession, wait, requestedOutputs);\n                        return true;\n                    }\n                } while (wait);\n            }\n            return result;\n        }\n\n        /// <inheritdoc/>\n        public ValueTask CompletePendingAsync(bool waitForCommit = false, CancellationToken token = default)\n            => CompletePendingAsync(false, waitForCommit, token);\n\n        /// <inheritdoc/>","sourceCodeStart":838,"sourceCodeEnd":874,"githubUrl":"https://github.com/microsoft/FASTER/blob/321d872eabda6a0345c8bd76419f89723ed864ae/cs/src/core/ClientSession/ClientSession.cs#L838-L874","documentation":"CompletePending(spinWaitForCommit: true) blocks by spinning until a checkpoint/commit finishes, which is only meaningful when the call itself blocks (wait: true). Passing spinWaitForCommit with wait=false would spin on a non-blocking call, so FASTER rejects the combination immediately.","triggerScenarios":"Calling session.CompletePending(wait: false, spinWaitForCommit: true) (or the CompletePendingWithoutCommit spinWait variant) on a ClientSession.","commonSituations":"Developers copy a CompletePending(wait: true, spinWaitForCommit: true) call and change wait to false to avoid blocking, forgetting the spinWaitForCommit flag still set; boolean flags passed positionally in the wrong order.","solutions":["Pass wait: true when using spinWaitForCommit: true.","If you do not need to block, drop spinWaitForCommit and call CompletePending(wait: false).","For async scenarios use CompletePendingAsync(waitForCommit: true) instead of spinning."],"exampleFix":"// before\nsession.CompletePending(wait: false, spinWaitForCommit: true); // throws\n\n// after\nsession.CompletePending(wait: true, spinWaitForCommit: true);","handlingStrategy":"validation","validationCode":"bool wait = true, spinWaitForCommit = true;\nif (spinWaitForCommit && !wait)\n    throw new ArgumentException(\"spinWaitForCommit requires wait: true\");\nsession.CompletePending(wait, spinWaitForCommit);","typeGuard":null,"tryCatchPattern":"try\n{\n    session.CompletePending(wait, spinWaitForCommit);\n}\ncatch (FasterException ex) when (ex.Message.Contains(\"spin-wait\"))\n{\n    session.CompletePending(wait: true, spinWaitForCommit: true);\n}","preventionTips":["Avoid positional booleans; use named arguments for CompletePending.","Wrap session completion in a helper with a valid default combination.","Review call sites that toggle 'wait' to false for leftover spinWaitForCommit flags."],"tags":["csharp","faster","invalid-arguments","checkpoint"],"backgroundTag":"conflicting-config-options","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"}