Skip to content

Commit e491e1a

Browse files
committed
Add more information to the gql frameworks
1 parent 888001f commit e491e1a

File tree

4 files changed

+96
-109
lines changed

4 files changed

+96
-109
lines changed

modules/ROOT/pages/draft.adoc

Lines changed: 0 additions & 32 deletions
This file was deleted.

modules/ROOT/pages/errors/index.adoc

Lines changed: 92 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,27 @@
22
[[neo4j-errors]]
33
= Server errors
44

5-
A server error is returned by the Neo4j DBMS to indicate that the outcome of a Cypher query or command execution is not successful.
5+
The Neo4j DBMS returns a server error to indicate that the outcome of a Cypher query or command execution is unsuccessful.
66
The driver receives these errors and sends them to the client, which displays them to the user.
77

8-
Starting from version 5.25, Neo4j has a new GqlStatusObject API in addition to the existing HasStatus API.
9-
The GqlStatusObject API provides information about the status of a Cypher query or command execution in compliance with the GQL standard.
8+
Starting from version 5.25, the Neo4j error codes have an additional GQL-status object that provides information about the status of a Cypher query or command execution in compliance with the link:https://www.iso.org/standard/76120.html[ISO/IEC 39075:2024(en) - Information technology - Database languages - GQL Standard].
109

11-
This page describes both the Neo4j error and the GQL-status object frameworks, how they are structured, the objects they provide for errors, and how to interpret them.
12-
//It also explains the server error grouping and filtering, the error internals, and the server-driver compatibility for both the HasStatus and GqlStatusObject APIs.
10+
This page describes the GQL-status object and the Neo4j error frameworks, their structure, the objects they provide for errors, and how to interpret them.
11+
It also explains the error internals and the server-driver compatibility for both the GQLSTATUS and legacy errors.
1312

14-
15-
[role=label--version-5.23]
13+
[role=label--version-5.25]
1614
[[gqlstatus-error-object]]
1715
== GQL-status error object
1816

1917
In the GQL-status object framework, errors are an implementation-defined subset of the GQL-status objects that cover exceptions.
2018

2119
In GQL, the execution of a query from user to server always has an outcome, called the _execution outcome_.
22-
The execution outcome is a list of GQL-status objects, ordered by the following precedence, where the first object in the list is the primary GQL-status object:
20+
The execution outcome is a list of GQL-status objects ordered by the following precedence rules:
2321

24-
. Every exception condition for transaction rollback has precedence over every other exception condition.
25-
. Every exception condition has precedence over every completion condition.
22+
. Every exception that results in a transaction rollback takes precedence over other exceptions.
23+
. Every exception takes precedence over any completion condition.
2624

27-
The GQL-status object also includes the Neo4j-specific information, such as the severity level and the classification of the error.
25+
The GQL-status object also includes the Neo4j-specific information, such as the severity level and the error classification.
2826

2927
Each GQL-status object consists of the following fields:
3028

@@ -47,75 +45,57 @@ Additional helper methods are exposed for some useful fields.
4745
! `OPERATION_CODE` ! The operation code that the error is related to. Always defaults to `0`.
4846
! `CURRENT_SCHEMA` ! The current schema that the error is related to. Always defaults to `/`.
4947
! `_severity` a! The Neo4j severity level of the error, which is always `ERROR`.
50-
!`_classification` ! The Neo4j category of the error, which can be `CLIENT_ERROR`, `TRANSIENT_ERROR`, or `DATABASE_ERROR`.
48+
!`_classification` ! The Neo4j error classification, which can be `CLIENT_ERROR`, `TRANSIENT_ERROR`, or `DATABASE_ERROR`.
5149
! `_position` ! The position, given by row and column, where the error is relevant in the query text.
5250
//! `_status_parameters`! A map that contains all variable parts of the status description.
5351
!===
5452
|===
5553

56-
A GQL-status error object can also contain an optional nested GQL-status object for providing additional diagnostic information, such as a cause, which is a GQL-status object wrapped in another GQL-status object.
54+
A GQL-status error object can also contain an optional wrapped GQL-status object to provide additional diagnostic information, such as a cause.
5755

5856
[[gqlstatus-neo4j-defined-codes]]
5957
== Classes of GQLSTATUS error codes
6058

61-
The Neo4j-defined GQLSTATUS codes are divided into classes and subclasses, where the class code is a 2-character string (one of `00`, `01`, or `03`) and the subclass code is a 3-character string.
62-
The class code indicates the general condition of the status (such as successful completion, warning, or information), and the subclass code provides more detailed information about the condition, such as classification and messages.
59+
The Neo4j GQLSTATUS codes are divided into classes and subclasses.
60+
The class code is a 2-character string that indicates the general condition of the status, such as connection exception, data exception, etc.
61+
The subclass code is a 3-character string that provides more detailed information about the condition.
62+
The Neo4j-define subclasses start with N, followed by a 2-digit number.
6363

64-
The following table lists the Neo4j-defined groups of GQLSTATUS codes and their meanings:
64+
The following table lists the GQLSTATUS classes and their meanings:
6565

66-
.GQLSTATUS groups of codes as defined by Neo4j
66+
.GQLSTATUS code classes
6767
[frame="topbot", stripes=odd, grid="cols", cols="<1s,<4"]
6868
|===
69-
|GQLSTATUS code
69+
|Class
7070
|*Description*
7171

72-
| 01N0[y]
73-
| Deprecation warnings
74-
75-
| 01N3[y]
76-
| Hint warnings
77-
78-
| 01N4[y]
79-
| Unsupported warnings
80-
81-
| 01N5[y]
82-
| Unrecognized warnings
83-
84-
| 01N6[y]
85-
| Generic warnings
86-
87-
| 01N7[y]
88-
| Security warnings
89-
90-
| 03N9[y]
91-
| Performance information
92-
93-
| 03N6[y]
94-
| Generic information
95-
96-
| 00N5[y]
97-
| Unrecognized information under successful completion
98-
99-
| 00N6[y]
100-
| Generic information under successful completion
101-
102-
| 00N7[y]
103-
| Security information under successful completion
104-
105-
| 00N8[y]
106-
| Topology information under successful completion
107-
72+
| 08
73+
| connection exception
74+
| 22
75+
| data exception
76+
| 25
77+
| invalid transaction state
78+
| 40
79+
| transaction rollback
80+
| 42
81+
| syntax error or access rule violation
82+
| 50
83+
| general processing exception
84+
| 51
85+
| system configuration or operation exception
86+
| 52
87+
| procedure exception
10888
|===
10989

110-
[[neo4j-error-object]]
111-
== Neo4j error object
90+
[[legacy-error-object]]
91+
== Legacy error object
11292

113-
The Neo4j error object contains diagnostic information representing the *unsuccessful* outcome of a Cypher query or command execution, including severity, status code, category, description, message, and position in the query text where the error is relevant.
93+
The Neo4j legacy error object contains diagnostic information representing the *unsuccessful* outcome of a Cypher query or command execution, including severity, status code, category, description, message, and position in the query text where the error is relevant.
11494
Depending on the application, some of the fields from the error object might not be visible.
11595

11696
The error object consists of the following fields:
11797

118-
.Neo4j error object
98+
.Neo4j legacy error object
11999
[cols="<1s,<4"]
120100
|===
121101
|Neo4j code
@@ -133,48 +113,88 @@ Available categories are `CLIENT_ERROR`, `TRANSIENT_ERROR`, and `DATABASE_ERROR`
133113
a|The position, given by row and column, where the error is relevant in the query text.
134114
|===
135115

116+
For more information, see the xref:errors/all-errors.adoc[List of legacy server error codes].
117+
136118
[[error-grouping-and-filtering]]
137119
== Server error classification
138120

139-
The fact that a Neo4j status code is returned by the server does not always mean there is a fatal error.
140-
Neo4j status codes can also indicate transient problems that may go away if you retry the request.
141-
The status code classification determines the effect on the transaction.
121+
The fact that an error is returned by the server does not always mean that it is a fatal error.
122+
Status codes can also indicate transient problems that may go away if you retry the request.
123+
The server error classification determines the effect on the transaction.
142124

143-
.Neo4j status code types
125+
.Server error classification
144126
[options="header", cols="<1m,<2,<1"]
145127
|===
146128

147-
| Type
129+
| Classification
148130
| Description
149131
| Effect on the transaction
150132

151133
| xref:errors/all-errors.adoc#_client_errors[ClientError]
152-
| The client sent a bad request - changing the request might yield a successful outcome.
134+
| These errors are caused by the client and are usually related to the request itself.
135+
Changing the request might yield a successful outcome.
136+
Legacy client errors have the prefix `Neo.ClientError`.
153137
| Rollback
154138

155139
| xref:errors/all-errors#_transient_errors[TransientError]
156-
| The database cannot service the request right now, retrying later might yield a successful outcome.
140+
| These errors are detected by the server and are usually related to some kind of database unavailability, such as limits reached, out-of-memory, timeouts, etc.
141+
The error can be temporary, therefore retrying later might yield a successful outcome.
142+
Legacy transient errors have the prefix Neo.`TransientError`.
157143
| Rollback
158144

159145
| xref:errors/all-errors#_database_error[DatabaseError]
160-
| The database failed to service the request.
146+
| These errors are caused by the database and are usually related to the database state and mean that the database failed to service the request.
147+
Legacy database errors have the prefix `Neo.DatabaseError`.
161148
| Rollback
162149

163150
|===
164151

165152
[[error-internals]]
166153
== Error internals
167154

168-
The server and driver communicate with each other through the Bolt protocol.
169-
During the handshake process, they agree on using the newest possible Bolt protocol version that both the server and the driver support.
170-
For more information on the Bolt versions supported by different server versions, see the link:https://neo4j.com/docs/bolt/current/bolt-compatibility[Bolt Protocol documentation].
171-
172155
Neo4j supports server errors in the form of Java exceptions.
173156
Most of these implement the `HasStatus` interface, which means they have a Neo4j status code in addition to the exception message.
174157

175158
On the server side, an exception contains normal Java constructors and methods like `getMessage()`, `getCause()`, etc., and additionally the `status()` method from the `HasStatus` API, which returns the Neo4j status code.
176-
These exceptions are then sent to the driver as failure Bolt message metadata.
159+
160+
Starting from 5.25, the exceptions also get new compulsary fields for `gqlStatus` and `statusDescription`, and optional fields for the `diagnosticRecord` and `cause`.
161+
The cause field is a wrapped underlying Neo4j exception, which in turn has its own GQLSTATUS, statusdescription, diagnostic record and message. +
162+
The `getMessage()` method is kept as Java exceptions inherently have this method.
163+
And a new classification field is added to cover the division of client errors, transient errors and database errors, which today is part of the Neo4j status code.
164+
All of these fields construct the GQLSTATUS object, which is sent to the driver as part of the Failure Bolt message.
165+
Exactly how this looks, depends on the combination of driver and server versions.
166+
See <<server-driver-compatibility, Server-driver version compatibility>> for more information.
167+
168+
On the driver side, the Neo4jException is extended with the corresponding methods as on the server side.
169+
The driver receives the failure message and extracts the status code and the error message.
170+
Then, it constructs an error object with the status code, error message, and other relevant information, and sends it to the client.
171+
172+
// Starting from 2025.01, the diagnostic record also contains a `_status_parameters` field, which represens a map that contains all variable parts of the status description, such as labels, database names, Cypher clauses, etc.
173+
// This field is used to provide more detailed information about the error.
174+
175+
== Query logging
176+
177+
Since the query log is server-side and DBMS wide, multiple clients connected to the same DBMS write to the same query log.
178+
As the clients can have separate driver versions, they may have different error framework formats.
179+
180+
In Neo4j 5.25, the default JSON template for the query log is updated to include `errorInfo` entry.
181+
This entry contains `GQLSTATUS`, `statusDescription`, `classification`, `position` (if applicable), and `cause` (if applicable) with the same entries.
182+
//The `failureReason` entry is deprecated from 5.26.
183+
184+
[NOTE]
185+
====
186+
The default GQLSTATUS code 50N42 is returned when an exception does not have a GQL object. Starting from Neo4j 5.25, GQL objects are added to exceptions; therefore, you can expect many 50N42 codes. However, it’s important not to rely on this default code, as future Neo4j versions might change it by adding an appropriate GQL object to the exception. Additionally, GQL codes for external procedures are not yet stable.
187+
====
188+
189+
// Starting from Neo4j 2025.01, a new JSON template is available for the query log, which is the default set in server_log.xml.
190+
// It contains the `errorInfo` entry, but not the `failureReason` entry, which is switched off by default.
177191

178192

179193
[[server-driver-compatibility]]
180-
== Server-driver version compatibility
194+
== Server-driver version compatibility
195+
196+
The server and driver communicate with each other through the Bolt protocol.
197+
During the handshake process, they agree on using the newest possible Bolt protocol version that both the server and the driver support.
198+
For more information on the Bolt versions supported by different server versions, see the link:https://neo4j.com/docs/bolt/current/bolt-compatibility[Bolt Protocol documentation].
199+
200+

modules/ROOT/pages/index.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ The Neo4j 5 Status Codes manual includes all status codes that a Neo4j server ma
1313

1414
Starting from 5.23 for notifications and 5.25 for errors, the Neo4j DBMS supports the GQL standard. +
1515
GQL is the new link:https://www.iso.org/home.html[ISO] International Standard query language for graph databases.
16-
Cypher®, Neo4j’s query language, supports most mandatory and a substantial portion of the optional GQL features (as defined by the ISO/IEC 39075:2024(en) - Information technology - Database languages - GQL Standard).
16+
Cypher®, Neo4j’s query language, supports most mandatory and a substantial portion of the optional GQL features (as defined by the link:https://www.iso.org/standard/76120.html[ISO/IEC 39075:2024(en) - Information technology - Database languages - GQL Standard]).
1717
For more information, see link:https:https://neo4j.com/docs/cypher-manual/current/appendix/gql-conformance/[Cypher Manual -> GQL conformance].
1818

19-
As part of this GQL compliance, Cypher now also include status codes that a GQL-compliant DBMS returns to indicate the outcome of a request.
19+
As part of this GQL compliance, Cypher now also includes status codes that a GQL-compliant DBMS returns to indicate the outcome of a request.
2020
For more information on GQL status code framewoks for notifications and errors, see xref:notifications/index.adoc[] and xref:errors/index.adoc[].
2121

2222
This manual details all status codes that a Neo4j DBMS may return, including both GQL-compliant and legacy status codes.

0 commit comments

Comments
 (0)