Bolt Protocol server state specification
For the server, each connection using the Bolt Protocol will occupy one of several states throughout its lifetime.
This state is used to determine what actions may be undertaken by the client. Each server state specification corresponds to a message specification with the same version.
For a summary of all available server state transitions in each version of the Bolt Protocol, see the Appendix pages.
Server states
Each connection maintained by a Bolt server will occupy one of several states throughout its lifetime. This state is used to determine what actions may be undertaken by the client.
| State | Logic state | Description |
|---|---|---|
X |
no socket connection |
|
X |
the socket connection is permanently closed |
|
protocol handshake is completed successfully; ready to accept a |
||
|
||
ready to accept a |
||
Auto-commit Transaction, a result is available for streaming from the server |
||
Explicit Transaction, ready to accept a |
||
Explicit Transaction, a result is available for streaming from the server |
||
a connection is in a temporarily unusable state |
||
the server got an |
Server state DISCONNECTED
No socket connection has yet been established. This is the initial state and exists only in a logical sense prior to the socket being opened.
Server state NEGOTIATION
After a new protocol connection has been established and handshake has been completed successfully, the server enters the NEGOTIATION state.
The connection has not yet been authenticated and permits only one transition, through successful initialization using the HELLO message, into the AUTHENTICATION state.
Server state AUTHENTICATION
Connection has been established and metadata has been sent back from the HELLO message or a LOGOFF message was received whilst in ready state.
Ready to accept a LOGON message with authentication information.
Server state DEFUNCT
This is not strictly a connection state, but is instead a logical state that exists after a connection has been closed.
When DEFUNCT, a connection is permanently not usable.
This may arise due to a graceful shutdown or can occur after an unrecoverable error or protocol violation.
Clients and servers should clear up any resources associated with a connection on entering this state, including closing any open sockets.
This is a terminal state on which no further transitions may be carried out.
The <DISCONNECT> signal will set the connection in the DEFUNCT server state.
Server state READY
The READY state can handle the request messages RUN and BEGIN and receive a query.
Server state STREAMING
When STREAMING, a result is available for streaming from server to client.
This result must be fully consumed or discarded by a client before the server can re-enter the READY state and allow any further queries to be executed.
Transitions from STREAMING
-
<INTERRUPT>toINTERRUPTED -
<DISCONNECT>toDEFUNCT -
PULLtoREADY,FAILED, orSTREAMING -
DISCARDtoREADY,FAILED, orSTREAMING
In v1, v2 and v3, the following transitions are possible:
-
<INTERRUPT>toINTERRUPTED -
<DISCONNECT>toDEFUNCT -
PULL_ALLtoREADYorFAILED -
DISCARD_ALLtoREADYorFAILED
| State | New state | Response |
|---|---|---|
|
|
|
|
|
|
|
|
|
| State | New state | Response |
|---|---|---|
|
|
[ |
|
|
[ |
|
|
[ |
| State | New state | Response |
|---|---|---|
|
|
`SUCCESS {} |
|
|
|
| State | New state | Response |
|---|---|---|
|
|
[ |
|
|
[ |
Server state TX_READY
Transitions from TX_READY
-
<INTERRUPT>toINTERRUPTED -
<DISCONNECT>toDEFUNCT -
RUNtoTX_STREAMINGorFAILED -
COMMITtoREADYorFAILED -
ROLLBACKtoREADYorFAILED
| State | New state | Response |
|---|---|---|
|
|
|
|
|
|
|
The |
Server state TX_STREAMING
When TX_STREAMING, a result is available for streaming from server to client.
This result must be fully consumed or discarded by a client before the server can transition to the TX_READY state.
Transitions from TX_STREAMING
-
<INTERRUPT>toINTERRUPTED -
<DISCONNECT>toDEFUNCT -
RUNtoTX_STREAMINGorFAILED -
PULLtoTX_READY,FAILEDorTX_STREAMING -
DISCARDtoTX_READY,FAILEDorTX_STREAMING
| State | New state | Response |
|---|---|---|
|
|
|
|
|
|
| State | New state | Response |
|---|---|---|
|
|
|
|
|
|
|
|
|
| State | New state | Response |
|---|---|---|
|
|
[ |
|
|
[ |
|
|
[ |
|
The |
Server state FAILED
When FAILED, a connection is in a temporarily unusable state.
This is generally as the result of encountering a recoverable error.
This mode ensures that only one failure can exist at a time, preventing cascading issues from batches of work.
Transitions from FAILED
-
<INTERRUPT>toINTERRUPTED -
<DISCONNECT>toDEFUNCT -
RUNtoFAILED -
PULLtoFAILED -
DISCARDtoFAILED
In v1 and v2, in a FAILED state, no more work will be processed until the failure has been acknowledged by ACK_FAILURE or until the connection has been RESET.
In v1 and v2, the following transitions are possible:
-
<INTERRUPT>toINTERRUPTED -
<DISCONNECT>toDEFUNCT -
ACK_FAILUREtoREADYorDEFUNCT
Server state INTERRUPTED
This state occurs between the server receiving the jump-ahead <INTERRUPT> and the queued RESET message, (the RESET message triggers an <INTERRUPT>).
Most incoming messages are ignored when the server are in an INTERRUPTED state, with the exception of the RESET that allows transition back to READY.
The <INTERRUPT> signal will set the connection in the INTERRUPTED server state.
Transitions from INTERRUPTED
-
<INTERRUPT>toINTERRUPTED -
<DISCONNECT>toDEFUNCT -
RUNtoINTERRUPTED -
DISCARDtoINTERRUPTED -
PULLtoINTERRUPTED -
BEGINtoINTERRUPTED -
COMMITtoINTERRUPTED -
ROLLBACKtoINTERRUPTED -
RESETtoREADYorDEFUNCT
In v1 and v2, the following transitions are possible:
-
<INTERRUPT>toINTERRUPTED -
<DISCONNECT>toDEFUNCT -
RUNtoINTERRUPTED -
DISCARD_ALLtoINTERRUPTED -
PULL_ALLtoINTERRUPTED -
ACK_FAILUREtoINTERRUPTED -
RESETtoREADYorDEFUNCT
Summary of changes per version
The sections below list the changes compared to the previous version.
Version 5.1
-
CONNECTEDstate has been renamed toNEGOTIATIONbut still accepts theHELLOmessage. -
HELLOmessage no longer accepts authentication and transitions to theAUTHENTICATIONstate fromNEGOTIATION. -
LOGONmessage has been added. It can only be received in theAUTHENTICATIONstate and transitions to theREADYstate. -
LOGOFFmessage has be added. It can only be received in theREADYstate and transitions to theAUTHENTICATIONstate.
Version 4.3
-
The
ROUTEmessage was added. It can only be received in theREADYstate and causes no transition.
Version 4.0
Compared to version 3 the RUN, PULL and DISCARD now can re-enter STREAMING or TX_STREAMING.
The server state transitions are using the updated set of messages defined in Bolt Protocol Message Specification Version 4.0.
Version 3
Compared to version 2 there are new server states:
-
TX_READY -
TX_STREAMINGThese states are introduced to handle the concept of Explicit Transaction. The server state transitions are using the updated set of messages defined in Bolt Protocol Message Specification Version 3.