SESSION.CLOSE
Closes the current session and resets all session state while keeping the connection open.
Syntax
Section titled “Syntax”SESSION.CLOSEThis command takes no parameters.
Return Value
Section titled “Return Value”Simple string: OK on success.
Behavior
Section titled “Behavior”The command performs a full session reset without closing the underlying network connection:
- Cursors: All active cursors (read, delete, update query contexts) are cleared
- FDB Transaction: Any active FoundationDB transaction is rolled back and closed
- MULTI State:
MULTItransaction state (queued commands, the MULTI flag) is reset - Watched Keys: All keys being watched via
WATCHare unwatched - Cursor ID Counter: Reset to 1
- Session Defaults: the configuration attributes (
reply_type,input_type,batch,object_id_format) are reset to their defaults, snapshot read goes back to off, and the current namespace goes back to the default one
Everything that belongs to the connection rather than the session is kept: the negotiated RESP version, the
authentication state, and the client name and library info set with CLIENT SETNAME and CLIENT SETINFO. A client
that has already authenticated does not need to send AUTH again after this command.
Errors
Section titled “Errors”Argument errors:
| Error Code | Error message | Cause |
|---|---|---|
ERR | wrong number of arguments for 'SESSION. | - |
Examples
Section titled “Examples”Basic usage:
> SESSION.CLOSEOKAfter starting a transaction:
> BEGINOK
> SESSION.CLOSEOK
> ROLLBACK(error) TRANSACTION there is no transaction in progress.The transaction is rolled back; no explicit ROLLBACK is needed.
Resetting modified session attributes:
> SESSION.ATTRIBUTE SET batch 50OK
> SESSION.CLOSEOK
> SESSION.ATTRIBUTE LIST1# reply_type => bson2# input_type => bson3# batch => (integer) 1004# object_id_format => bytesThe batch attribute is reset to its default value (100).
Resetting snapshot read:
> SNAPSHOTREAD ONOK
> SESSION.CLOSEOKReads are serializable again. The next transaction on this connection does not inherit snapshot isolation.
Resetting the current namespace:
> NAMESPACE USE global.stagingOK
> SESSION.CLOSEOK
> NAMESPACE CURRENTglobal