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
-
PULL
toREADY
,FAILED
, orSTREAMING
-
DISCARD
toREADY
,FAILED
, orSTREAMING
In v1, v2 and v3, the following transitions are possible:
-
<INTERRUPT>
toINTERRUPTED
-
<DISCONNECT>
toDEFUNCT
-
PULL_ALL
toREADY
orFAILED
-
DISCARD_ALL
toREADY
orFAILED
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
-
RUN
toTX_STREAMING
orFAILED
-
COMMIT
toREADY
orFAILED
-
ROLLBACK
toREADY
orFAILED
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
-
RUN
toTX_STREAMING
orFAILED
-
PULL
toTX_READY
,FAILED
orTX_STREAMING
-
DISCARD
toTX_READY
,FAILED
orTX_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
-
RUN
toFAILED
-
PULL
toFAILED
-
DISCARD
toFAILED
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_FAILURE
toREADY
orDEFUNCT
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
-
RUN
toINTERRUPTED
-
DISCARD
toINTERRUPTED
-
PULL
toINTERRUPTED
-
BEGIN
toINTERRUPTED
-
COMMIT
toINTERRUPTED
-
ROLLBACK
toINTERRUPTED
-
RESET
toREADY
orDEFUNCT
In v1 and v2, the following transitions are possible:
-
<INTERRUPT>
toINTERRUPTED
-
<DISCONNECT>
toDEFUNCT
-
RUN
toINTERRUPTED
-
DISCARD_ALL
toINTERRUPTED
-
PULL_ALL
toINTERRUPTED
-
ACK_FAILURE
toINTERRUPTED
-
RESET
toREADY
orDEFUNCT
Summary of changes per version
The sections below list the changes compared to the previous version.
Version 5.1
-
CONNECTED
state has been renamed toNEGOTIATION
but still accepts theHELLO
message. -
HELLO
message no longer accepts authentication and transitions to theAUTHENTICATION
state fromNEGOTIATION
. -
LOGON
message has been added. It can only be received in theAUTHENTICATION
state and transitions to theREADY
state. -
LOGOFF
message has be added. It can only be received in theREADY
state and transitions to theAUTHENTICATION
state.
Version 4.3
-
The
ROUTE
message was added. It can only be received in theREADY
state 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_STREAMING
These 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.