{"record":{"id":"183e87a09d79c0a2","repo":"Tencent/WeKnora","slug":"check-owning-session-w","errorCode":null,"errorMessage":"check owning session: %w","messagePattern":"check owning session: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sandbox/session_lifecycle.go","lineNumber":155,"sourceCode":"\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"destroy remote sandbox for session: %w\", err)\n\t}\n\treturn nil\n}\n\nfunc (l *remoteSessionLifecycle) resolveLocked(\n\tctx context.Context,\n\tkey SessionSandboxKey,\n) (RemoteSandboxHandle, error) {\n\tbinding, err := l.readBinding(ctx, key)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\texists, err := l.sessionChecker.SessionExists(ctx, key)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"check owning session: %w\", err)\n\t}\n\tif !exists {\n\t\tif binding != nil {\n\t\t\terr = l.destroyBindingLocked(ctx, key, *binding)\n\t\t}\n\t\treturn nil, errors.Join(ErrSandboxSessionDeleted, err)\n\t}\n\n\tif binding != nil && binding.Provider != l.client.Provider() {\n\t\tdeleted, err := l.bindings.DeleteIfMatch(\n\t\t\tctx,\n\t\t\tkey,\n\t\t\tbinding.Provider,\n\t\t\tbinding.SandboxID,\n\t\t)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"delete mismatched provider binding: %w\", err)\n\t\t}","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/sandbox/session_lifecycle.go#L137-L173","documentation":"resolveLocked checks the durable session record via SessionExistenceChecker before touching sandboxes. This error wraps a failure of that check itself (as opposed to the session merely not existing, which yields ErrSandboxSessionDeleted). The lifecycle throws it because it cannot safely decide whether to keep or destroy the sandbox without knowing whether the owning session exists.","triggerScenarios":"resolveLocked calls sessionChecker.SessionExists and the checker's backing store (e.g. the session database/Redis) errors — connection failure, timeout, or context cancellation during the existence query.","commonSituations":"Session store database outage or connection pool exhaustion; misconfigured session store DSN; context deadline exceeded because the lifecycle lock wait already consumed most of the deadline; permission errors on the session table.","solutions":["Check the session existence store's connectivity/config (DSN, credentials, pool limits) and fix the underlying error from the %w chain.","Increase the context deadline for Resolve so the existence check is not starved after lock acquisition.","Retry Resolve with backoff — the check is read-only and safe to re-issue.","Add health checks/alerting on the session store so outages are caught before sandbox resolution."],"exampleFix":"// before\nctx := context.WithTimeout(context.Background(), 3*time.Second)\nhandle, err := lifecycle.Resolve(ctx, key)\n// after\nctx := context.WithTimeout(context.Background(), 15*time.Second) // allow for lock wait + session check\nhandle, err := lifecycle.Resolve(ctx, key)\nif err != nil && !errors.Is(err, sandbox.ErrSandboxSessionDeleted) {\n    // inspect errors.Unwrap chain for session-store connectivity issues\n}","handlingStrategy":"retry","validationCode":"if err := rdb.Ping(ctx).Err(); err != nil {\n    return fmt.Errorf(\"session store down before resolve: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"exists, err := checker.SessionExists(ctx, key)\nif err != nil {\n    if isRetryable(err) {\n        time.Sleep(backoff)\n        exists, err = checker.SessionExists(ctx, key)\n    }\n    if err != nil { return fmt.Errorf(\"session store unavailable: %w\", err) }\n}","preventionTips":["Health-check the session store before processing turns.","Size DB/Redis connection pools for lock-holding resolve paths.","Give Resolve a deadline that leaves room after lock acquisition.","Alert on session-store error rates, since every sandbox resolve depends on it."],"tags":["session-store","database","sandbox"],"backgroundTag":"session-existence-check-failed","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}