Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Bolt 3.0 and 4.0 #57

Open
wants to merge 80 commits into
base: main
Choose a base branch
from
Open

Enable Bolt 3.0 and 4.0 #57

wants to merge 80 commits into from

Conversation

majensen
Copy link

This PR enables a large portion of Bolt protocol versions 3.0 and 4.0. Additional functionality is also added to the shell client to take advantage of explicit transactions (3.0+ :begin :commit and :rollback) and of having multiple databases (4.0+ :dbname).

majensen added 30 commits May 10, 2020 12:04
hey this is a fork
transaction.h
transaction.c
define tx object that is analogous to result_stream object
* tx object filled out
* api-level functions:
  * neo4j_begin_tx(connection,timeout,mode)
  * neo4j_run_in_tx(tx, statement, params) - easy, just use result_stream.c functions
  * neo4j_commit_tx(tx)
  * neo4j_rollback_tx(tx)

* receive callbacks for each of begin, commit, rollback
* new NEO4J_TRANSACTION_FAILED errno

Some working decisions made on how to store server argvs in tx
structure. Leaving as neo4j_* types; getters could convert to strings

* Need to destroy tx, presume that should happen under the hood in commit and
rollback. If tx is gone, tho, need to communicate final status back to
user some other way.
New messages (HELLO, GOODBYE, BEGIN, COMMIT, ROLLBACK) all included at
this point.

To do: deal with RESET substituting for ACK_FAILURE in 3.0
but it's WIP

adhering better to @cleishm's object patterns
(if bolt 2, the old arguments are preserved)
This gives a successful connection to neo4j:3.5
even if it's empty, for bolt 3+
highlight this as a fork
catch expired transaction error in run results
and update the transaction.
Add functioning :begin, :commit, :rollback commands
Manage protocol major and minor versions in protocol negotiation.
Attach database name to config object - preserves the neo4j_run API
Most of this has to do with enabling the RUN message to accept 3
arguments (statement, parameters, and the "extra" arg) rather than
2. The extra arg is a neo4j_map that can transmit the desired database
name in the "db" key value.

A :dbname command is added to the shell.

Negotiation is updated to accept v4.

bolt v4 is not fully implemented yet.
Several messages (RUN, PULL, DISCARD) have an additional or
"extra" map argument in 4.0. This should not be a problem for
the machinery of neo4j-client. It is a matter of
* creating a map with the required infomation
* setting the next available slot in the request _argv[] array to
  this map
* setting the argument count req->argc to the new size of _argv =
  argv.

Such a message queues ok; logging at TRACE level indicates that the
arguments are intact. However, when the request comes up for sending
(via connection.c:send_requests()) -- that is, when it is pulled off
the request queue in the connection object -- the new map is trashed.
This is evident via an error from the serializer (called in
neo4j_connection_send), that indicates that a map key is not a
neo4j_string -- even though that map was successfully printed by the
logger in neo4j_session_run(), when the request was created/enqueued.

Sample log output against a real running 4.0 server:
``
TRACE [connection]: enqu BEGIN (0x7fdcc3e002a0) in 0x7fdcc3d200b0
DEBUG [connection]: sent BEGIN (0x7fdcc3e002a0) in 0x7fdcc3d200b0
DEBUG [connection]: rcvd SUCCESS in response to BEGIN (0x7fdcc3e002a0)
TRACE [connection]: enqu RUN{"CREATE (n:booga {thing:1})", {}, {db:"neo4j"}} (0x7fdcc3e00380) in 0x7fdcc3d200b0
TRACE [connection]: enqu PULL {n:-1,qid:-1} (0x7fdcc3e00460) in 0x7fdcc3d200b0
DEBUG [connection]: sent RUN (0x7fdcc3e00380) in 0x7fdcc3d200b0
ERROR [connection]: Error sending message on 0x7fdcc3d200b0: Map contains key of non-String type
TRACE [connection]: draining RUN (0x7fdcc3e00380) from queue on 0x7fdcc3d200b0
TRACE [connection]: draining PULL_ALL (0x7fdcc3e00460) from queue on 0x7fdcc3d200b0
Segmentation fault: 11
``
Now set transation timeout value to 0 to inhibit timeout, set to -1
to fallback to server-side config timeout set.
also, checks work for all versions; leaving version set to 4.
Add slot in shell state object for dbname and manage it there (not
config)
Remove dbname from config
Make dbname a noop for a version 3 server (rather than barfing)
majensen added 30 commits March 22, 2023 23:32
to coincide with Neo4j browser's
in version negotiation - enable all minor versions for v4 and v5
by offering ranges per
https://neo4j.com/docs/bolt/current/bolt/handshake/#bolt-version43
add structure based type definitions, constructors,
and accessors
update supported versions in negotiation
add NEO4J_ELEMENTID type throughout the type system
- an element id is treated as a neo4j_string under the hood
with new supported version string
Feat neo4j 5.0 - all tests pass
which causes an obscure error at the server
remove hard-coded supported versions
version_spec structure to describe versions
config struct contains supported version list
protocol negotiation uses config version list
config structure holds version specification array
parse simple version string comma-separated list to set
add config accessor to set via version string
added options to shell - versions, --support to take a version string
to customize client-server handshake
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants