Skip to content

ADR 032: Advertised Address #612

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

Draft
wants to merge 12 commits into
base: 5.0
Choose a base branch
from

Conversation

StephenCathcart
Copy link
Contributor

@StephenCathcart StephenCathcart commented Dec 4, 2024

Update driver to handle the advertised_address field returned in the SUCCESS message during the LOGON process. This ensures the driver correctly identifies the actual server it connects to, allowing improved connection reuse and reducing unnecessary connection churn when operating behind a load balancer or proxy.

Bolt logs (notice the "Transferring connection from" log):

2024-12-04 09:54:40.892   INFO  [pool 1] Created
2024-12-04 09:54:40.892   INFO  [router 1] Created {context: map[address:cathcart-devcore.databases.neo4j-dev.io:7687]}
2024-12-04 09:54:40.892   INFO  [driver 1] Created { target: cathcart-devcore.databases.neo4j-dev.io:7687 }
2024-12-04 09:54:40.892  DEBUG  [session 2] Created
2024-12-04 09:54:40.892  DEBUG  [session 2] connection acquisition timeout is 1m0s, resolved deadline is: 2024-12-04 09:55:40.892878 +0000 GMT m=+60.001365513
2024-12-04 09:54:40.892   INFO  [router 1] Reading routing table from initial router: cathcart-devcore.databases.neo4j-dev.io:7687
2024-12-04 09:54:40.892  DEBUG  [pool 1] Trying to borrow connection from [cathcart-devcore.databases.neo4j-dev.io:7687]
2024-12-04 09:54:40.892   INFO  [pool 1] Connecting to cathcart-devcore.databases.neo4j-dev.io:7687
2024-12-04 09:54:40.950   BOLT  C: <MAGIC> 0X6060B017
2024-12-04 09:54:40.950   BOLT  C: <HANDSHAKE> 0X00080805 0X00020404 0X00000104 0X00000003
2024-12-04 09:54:40.974   BOLT  S: <HANDSHAKE> 0X00000805
2024-12-04 09:54:40.974   BOLT  C: HELLO {"bolt_agent":{"language":"Go/go1.20.3","platform":"darwin; amd64","product":"neo4j-go/5.27.0"},"routing":{"address":"cathcart-devcore.databases.neo4j-dev.io:7687"},"user_agent":"Go Driver/5.27.0"}
2024-12-04 09:54:40.974   BOLT  C: LOGON {"credentials":"<redacted>","principal":"neo4j","scheme":"basic"}
2024-12-04 09:54:40.995   BOLT  S: SUCCESS {"server":"Neo4j/2024.12-aura","connection_id":"bolt-27442","hints":{"connection.recv_timeout_seconds":60,"ssr.enabled":true,"telemetry.enabled":true}}
2024-12-04 09:54:40.997   BOLT  [bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] S: SUCCESS {}
2024-12-04 09:54:40.997   INFO  [bolt5 bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] Connected
2024-12-04 09:54:40.997   INFO  [bolt5 bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] Retrieving routing table
2024-12-04 09:54:40.997   BOLT  [bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] C: ROUTE {"address":"cathcart-devcore.databases.neo4j-dev.io:7687"} null {"db":"neo4j"}
2024-12-04 09:54:41.020   BOLT  [bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] S: SUCCESS {"routing_table":{"ttl":10,"db":"neo4j","routers":["p-cathcart-f4c4-0002.devcore-orch-0001.neo4j-dev.io:7687","p-cathcart-f4c4-0003.devcore-orch-0001.neo4j-dev.io:7687","p-cathcart-f4c4-0001.devcore-orch-0001.neo4j-dev.io:7687"],"readers":["p-cathcart-f4c4-0001.devcore-orch-0001.neo4j-dev.io:7687","p-cathcart-f4c4-0003.devcore-orch-0001.neo4j-dev.io:7687"],"writers":["p-cathcart-f4c4-0002.devcore-orch-0001.neo4j-dev.io:7687"]}}
2024-12-04 09:54:41.020  DEBUG  [pool 1] Transferring connection from cathcart-devcore.databases.neo4j-dev.io:7687 to advertised server p-cathcart-f4c4-0002.devcore-orch-0001.neo4j-dev.io:7687
2024-12-04 09:54:41.020  DEBUG  [pool 1] Returning connection to p-cathcart-f4c4-0002.devcore-orch-0001.neo4j-dev.io:7687 {alive:true}
2024-12-04 09:54:41.020  DEBUG  [bolt5 bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] Resetting connection internal state
2024-12-04 09:54:41.020  DEBUG  [router 1] New routing table for 'neo4j', TTL 10
2024-12-04 09:54:41.020  DEBUG  [pool 1] Trying to borrow connection from [p-cathcart-f4c4-0002.devcore-orch-0001.neo4j-dev.io:7687]
2024-12-04 09:54:41.020   BOLT  [bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] C: TELEMETRY 3
2024-12-04 09:54:41.020   BOLT  [bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] C: BEGIN {"db":"neo4j"}
2024-12-04 09:54:41.020   BOLT  [bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] C: RUN "RETURN 1" {} {}
2024-12-04 09:54:41.020   BOLT  [bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] C: PULL {"n":1000}
2024-12-04 09:54:41.042   BOLT  [bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] S: SUCCESS {}
2024-12-04 09:54:41.043   BOLT  [bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] S: SUCCESS {}
2024-12-04 09:54:41.044   BOLT  [bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] S: SUCCESS {"fields":["1"]}
2024-12-04 09:54:41.045   BOLT  [bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] S: RECORD [1]
2024-12-04 09:54:41.045   BOLT  [bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] S: SUCCESS {"db":"neo4j"}
2024-12-04 09:54:41.045   BOLT  [bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] C: COMMIT
2024-12-04 09:54:41.067   BOLT  [bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] S: SUCCESS {"bookmark":"FB:kcwQwwvW7LUdQdS+Y3dAUMpvkAOQ"}
2024-12-04 09:54:41.067  DEBUG  [pool 1] Returning connection to p-cathcart-f4c4-0002.devcore-orch-0001.neo4j-dev.io:7687 {alive:true}
2024-12-04 09:54:41.067  DEBUG  [bolt5 bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] Resetting connection internal state
2024-12-04 09:54:41.067  DEBUG  [router 1] Cleaning up
2024-12-04 09:54:41.067  DEBUG  [session 2] Closed
2024-12-04 09:54:41.067   INFO  [pool 1] Closed
2024-12-04 09:54:41.067   INFO  [driver 1] Closed
2024-12-04 09:54:41.067   INFO  [bolt5 bolt-27442@cathcart-devcore.databases.neo4j-dev.io:7687] Close

Depends on:

@StephenCathcart
Copy link
Contributor Author

@StephenCathcart StephenCathcart changed the title ADR XXX: Advertised Address ADR 032: Advertised Address Dec 4, 2024
Copy link

@AndyHeap-NeoTech AndyHeap-NeoTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks to make sense to me. One comment but nothing to prevent merge.

@@ -1,6 +1,6 @@
{
"testkit": {
"uri": "https://github.com/neo4j-drivers/testkit.git",
"ref": "5.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only temporarily! Needs to be reverted before merging the PR!

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.

3 participants