Skip to content

Commit fd3a4bc

Browse files
committed
Merge branch 'upstream-main'
2 parents dd0bbd9 + c3f95dd commit fd3a4bc

366 files changed

Lines changed: 21713 additions & 1862 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test-python-bindings.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
runs-on: ubuntu-latest
3939
steps:
4040
- name: Checkout code
41-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
41+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
4242

4343
- name: Set up Python
4444
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
@@ -62,7 +62,7 @@ jobs:
6262
runs-on: ubuntu-latest
6363
steps:
6464
- name: Checkout code
65-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
65+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
6666

6767
- name: Set up Docker Buildx
6868
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
@@ -170,7 +170,7 @@ jobs:
170170

171171
steps:
172172
- name: Checkout code
173-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
173+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
174174

175175
- name: Set up Python
176176
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0

.github/workflows/test-python-examples.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
runs-on: ubuntu-24.04
5757
steps:
5858
- name: Checkout code
59-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
59+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
6060

6161
- name: Set up Docker Buildx
6262
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4.1.0
@@ -160,7 +160,7 @@ jobs:
160160

161161
steps:
162162
- name: Checkout code
163-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
163+
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
164164

165165
- name: Download JARs artifact
166166
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ repos:
4848
args: ["-i", "4", "-ci", "-sr", "-w"]
4949
files: ^bindings/python/.*\.sh$
5050
- repo: https://github.com/rbubley/mirrors-prettier
51-
rev: v3.8.3
51+
rev: v3.8.4
5252
hooks:
5353
- id: prettier
5454
types: [ java, xml ]
5555
additional_dependencies:
56-
- prettier@3.8.3
56+
- prettier@3.8.4
5757
- prettier-plugin-java@2.9.7
5858
- prettier-plugin-xml
5959
args:

ATTRIBUTIONS.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,36 @@ The following table lists runtime dependencies bundled with ArcadeDB distributio
234234

235235
| Group ID | Artifact ID | Version | License | Homepage |
236236
|----------|-------------|---------|---------|----------|
237-
| io.micrometer | micrometer-core | 1.16.2 | Apache 2.0 | https://micrometer.io/ |
238-
| io.micrometer | micrometer-observation | 1.16.2 | Apache 2.0 | https://micrometer.io/ |
237+
| io.micrometer | micrometer-core | 1.16.5 | Apache 2.0 | https://micrometer.io/ |
238+
| io.micrometer | micrometer-observation | 1.16.5 | Apache 2.0 | https://micrometer.io/ |
239+
| io.micrometer | micrometer-registry-otlp | 1.16.5 | Apache 2.0 | https://micrometer.io/ |
239240
| org.hdrhistogram | HdrHistogram | 2.2.2 | Public Domain / CC0 | https://hdrhistogram.github.io/HdrHistogram/ |
240241

242+
### Distributed Tracing (Optional)
243+
244+
Used only by the optional `tracing` module (OpenTelemetry distributed tracing). Confined to that
245+
plugin; not on the core/server compile classpath.
246+
247+
| Group ID | Artifact ID | Version | License | Homepage |
248+
|----------|-------------|---------|---------|----------|
249+
| io.micrometer | micrometer-tracing | 1.7.0 | Apache 2.0 | https://micrometer.io/ |
250+
| io.micrometer | micrometer-tracing-bridge-otel | 1.7.0 | Apache 2.0 | https://micrometer.io/ |
251+
| io.opentelemetry | opentelemetry-sdk | 1.62.0 | Apache 2.0 | https://opentelemetry.io/ |
252+
| io.opentelemetry | opentelemetry-api | 1.62.0 | Apache 2.0 | https://opentelemetry.io/ |
253+
| io.opentelemetry | opentelemetry-context | 1.62.0 | Apache 2.0 | https://opentelemetry.io/ |
254+
| io.opentelemetry | opentelemetry-sdk-trace | 1.62.0 | Apache 2.0 | https://opentelemetry.io/ |
255+
| io.opentelemetry | opentelemetry-sdk-common | 1.62.0 | Apache 2.0 | https://opentelemetry.io/ |
256+
| io.opentelemetry | opentelemetry-exporter-otlp | 1.62.0 | Apache 2.0 | https://opentelemetry.io/ |
257+
| io.opentelemetry | opentelemetry-exporter-otlp-common | 1.62.0 | Apache 2.0 | https://opentelemetry.io/ |
258+
| io.opentelemetry | opentelemetry-exporter-common | 1.62.0 | Apache 2.0 | https://opentelemetry.io/ |
259+
| io.opentelemetry | opentelemetry-exporter-sender-okhttp | 1.62.0 | Apache 2.0 | https://opentelemetry.io/ |
260+
| io.opentelemetry | opentelemetry-extension-trace-propagators | 1.62.0 | Apache 2.0 | https://opentelemetry.io/ |
261+
| io.opentelemetry.semconv | opentelemetry-semconv | 1.41.1 | Apache 2.0 | https://opentelemetry.io/ |
262+
| com.squareup.okhttp3 | okhttp | 5.3.2 | Apache 2.0 | https://square.github.io/okhttp/ |
263+
| com.squareup.okio | okio | 3.16.4 | Apache 2.0 | https://square.github.io/okio/ |
264+
| org.jetbrains.kotlin | kotlin-stdlib | 2.2.21 | Apache 2.0 | https://kotlinlang.org/ |
265+
| org.jetbrains | annotations | 13.0 | Apache 2.0 | https://github.com/JetBrains/java-annotations |
266+
241267
---
242268

243269
## Test Dependencies

NOTICE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,29 @@ This product includes software developed by FasterXML, LLC.
173173

174174
================================================================================
175175

176+
This product includes Micrometer Tracing (optional tracing module only).
177+
178+
Micrometer Tracing
179+
Copyright (c) 2017-Present VMware, Inc. All Rights Reserved.
180+
181+
https://micrometer.io/
182+
183+
Micrometer Tracing contains modified portions of:
184+
- 'io.netty.util.internal.logging' from Netty (Copyright 2013 The Netty Project, Apache 2.0, https://netty.io)
185+
- 'StringUtils.isBlank()' from Apache Commons Lang (Copyright 2001-2019 The Apache Software Foundation, Apache 2.0)
186+
- 'JsonUtf8Writer' from Moshi (Copyright 2010 Google Inc., Apache 2.0, https://github.com/square/moshi)
187+
- the 'org.springframework.lang' package from the Spring Framework (Copyright 2002-2019 the original author or authors, Apache 2.0)
188+
189+
================================================================================
190+
191+
This product includes OpenTelemetry Java (optional tracing module only).
192+
193+
OpenTelemetry Java
194+
Copyright The OpenTelemetry Authors
195+
196+
https://opentelemetry.io/
197+
198+
================================================================================
199+
176200
For the complete list of third-party components and their licenses, see the
177201
ATTRIBUTIONS.md file in the root directory of this distribution.

bolt/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<parent>
2626
<groupId>com.arcadedb</groupId>
2727
<artifactId>arcadedb-parent</artifactId>
28-
<version>26.6.1</version>
28+
<version>26.7.1-SNAPSHOT</version>
2929
<relativePath>../pom.xml</relativePath>
3030
</parent>
3131

bolt/src/main/java/com/arcadedb/bolt/BoltNetworkExecutor.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.arcadedb.database.Database;
3939
import com.arcadedb.database.DatabaseContext;
4040
import com.arcadedb.database.DatabaseInternal;
41+
import com.arcadedb.database.ProtocolContext;
4142
import com.arcadedb.exception.CommandParsingException;
4243
import com.arcadedb.index.Index;
4344
import com.arcadedb.index.TypeIndex;
@@ -123,6 +124,9 @@ private enum State {
123124
// Transaction state
124125
private boolean explicitTransaction = false;
125126

127+
// GQL session state for this connection (SESSION SET/RESET/CLOSE parameters).
128+
private final BoltSession session = new BoltSession();
129+
126130
/**
127131
* Current result set for streaming results.
128132
* Thread-safety: This class is designed to handle a single connection in a dedicated thread.
@@ -162,6 +166,7 @@ public BoltNetworkExecutor(final ArcadeDBServer server, final Socket socket, fin
162166

163167
@Override
164168
public void run() {
169+
ProtocolContext.set("bolt");
165170
try {
166171
state = State.NEGOTIATION;
167172

@@ -215,6 +220,7 @@ public void run() {
215220
} catch (final Exception e) {
216221
LogManager.instance().log(this, Level.SEVERE, "BOLT connection error", e);
217222
} finally {
223+
ProtocolContext.clear();
218224
cleanup();
219225
}
220226
}
@@ -479,6 +485,11 @@ private void handleReset() throws IOException {
479485
}
480486
}
481487

488+
// NOTE: do not clear the GQL session parameters here. The Bolt RESET message is connection-level
489+
// housekeeping the driver sends when recycling a pooled connection, not a user request to reset GQL
490+
// session state; clearing here would drop SESSION SET parameters between auto-commit queries. GQL
491+
// session parameters are cleared only by an explicit SESSION RESET / SESSION CLOSE statement.
492+
482493
explicitTransaction = false;
483494
currentResultSet = null;
484495
currentFields = null;
@@ -530,7 +541,8 @@ private void handleRun(final RunMessage message) throws IOException {
530541
firstRecordTime = 0;
531542
syntheticResults = null;
532543

533-
// Ensure database is open (maps "system"/"neo4j" to default database)
544+
// Ensure database is open (maps "system"/"neo4j" to default database). This also attaches the
545+
// connection's GQL session to the thread context, which the engine reads for SESSION statements.
534546
if (!ensureDatabase())
535547
return;
536548

@@ -944,8 +956,11 @@ private boolean ensureDatabase() throws IOException {
944956
if (user != null) {
945957
final DatabaseContext.DatabaseContextTL ctx =
946958
DatabaseContext.INSTANCE.getContextIfExists(((DatabaseInternal) database).getDatabasePath());
947-
if (ctx != null)
959+
if (ctx != null) {
948960
ctx.setCurrentUser(user.getDatabaseUser(database));
961+
// Attach this connection's GQL session so SESSION statements and param merging can reach it.
962+
ctx.setQuerySession(session);
963+
}
949964
}
950965
return true;
951966
}
@@ -976,8 +991,12 @@ private boolean ensureDatabase() throws IOException {
976991
state = State.FAILED;
977992
return false;
978993
}
979-
if (user != null)
980-
DatabaseContext.INSTANCE.init((DatabaseInternal) database).setCurrentUser(user.getDatabaseUser(database));
994+
if (user != null) {
995+
final DatabaseContext.DatabaseContextTL ctx = DatabaseContext.INSTANCE.init((DatabaseInternal) database);
996+
ctx.setCurrentUser(user.getDatabaseUser(database));
997+
// Attach this connection's GQL session so SESSION statements and param merging can reach it.
998+
ctx.setQuerySession(session);
999+
}
9811000
return true;
9821001
} catch (final Exception e) {
9831002
final String message = e.getMessage() != null ? e.getMessage() : "Unknown error";
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright © 2021-present Arcade Data Ltd (info@arcadedata.com)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-FileCopyrightText: 2021-present Arcade Data Ltd (info@arcadedata.com)
17+
* SPDX-License-Identifier: Apache-2.0
18+
*/
19+
package com.arcadedb.bolt;
20+
21+
import com.arcadedb.query.QuerySession;
22+
23+
import java.util.Collections;
24+
import java.util.HashMap;
25+
import java.util.Map;
26+
27+
/**
28+
* The per-connection {@link QuerySession} for the Bolt protocol: it carries the session parameters set with
29+
* GQL {@code SESSION SET} so later commands on the same connection see them.
30+
* <p>
31+
* A Bolt connection runs in a single dedicated thread, so this state needs no synchronization. The Bolt
32+
* connection and its transaction lifecycle are governed by the Bolt protocol (BEGIN/COMMIT/ROLLBACK/RESET
33+
* messages and the driver's own session), so here {@code SESSION CLOSE} only clears the session parameters -
34+
* it does not tear down the connection or its transaction.
35+
*
36+
* @author Luca Garulli (l.garulli@arcadedata.com)
37+
*/
38+
public class BoltSession implements QuerySession {
39+
private final Map<String, Object> parameters = new HashMap<>();
40+
// Cached live read-only view over 'parameters' (reflects mutations), so getParameters() allocates nothing.
41+
private final Map<String, Object> parametersView = Collections.unmodifiableMap(parameters);
42+
43+
@Override
44+
public void setParameter(final String name, final Object value) {
45+
parameters.put(name, value);
46+
}
47+
48+
@Override
49+
public Map<String, Object> getParameters() {
50+
return parametersView;
51+
}
52+
53+
@Override
54+
public void reset() {
55+
parameters.clear();
56+
}
57+
58+
@Override
59+
public void close() {
60+
// The Bolt connection/transaction lifecycle is governed by the protocol; the session only owns its
61+
// parameters, so closing it clears them.
62+
parameters.clear();
63+
}
64+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright © 2021-present Arcade Data Ltd (info@arcadedata.com)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
* SPDX-FileCopyrightText: 2021-present Arcade Data Ltd (info@arcadedata.com)
17+
* SPDX-License-Identifier: Apache-2.0
18+
*/
19+
package com.arcadedb.bolt;
20+
21+
import com.arcadedb.GlobalConfiguration;
22+
import com.arcadedb.server.BaseGraphServerTest;
23+
import io.micrometer.core.instrument.Metrics;
24+
import io.micrometer.core.instrument.Timer;
25+
import org.junit.jupiter.api.AfterEach;
26+
import org.junit.jupiter.api.Test;
27+
import org.neo4j.driver.AuthTokens;
28+
import org.neo4j.driver.Config;
29+
import org.neo4j.driver.Driver;
30+
import org.neo4j.driver.GraphDatabase;
31+
import org.neo4j.driver.Session;
32+
import org.neo4j.driver.SessionConfig;
33+
34+
import static org.assertj.core.api.Assertions.assertThat;
35+
36+
/**
37+
* Verifies that queries executed over a Bolt connection are tagged with protocol="bolt"
38+
* in the arcadedb.query.duration Micrometer timer.
39+
*/
40+
public class BoltQueryMetricsIT extends BaseGraphServerTest {
41+
42+
@Override
43+
public void setTestConfiguration() {
44+
super.setTestConfiguration();
45+
GlobalConfiguration.SERVER_PLUGINS.setValue("Bolt:com.arcadedb.bolt.BoltProtocolPlugin");
46+
}
47+
48+
@AfterEach
49+
@Override
50+
public void endTest() {
51+
GlobalConfiguration.SERVER_PLUGINS.setValue("");
52+
super.endTest();
53+
}
54+
55+
private Driver getDriver() {
56+
return GraphDatabase.driver(
57+
"bolt://localhost:7687",
58+
AuthTokens.basic("root", DEFAULT_PASSWORD_FOR_TESTS),
59+
Config.builder()
60+
.withoutEncryption()
61+
.build()
62+
);
63+
}
64+
65+
@Test
66+
void boltQueriesTaggedWithBoltProtocol() {
67+
try (Driver driver = getDriver()) {
68+
try (Session session = driver.session(SessionConfig.forDatabase(getDatabaseName()))) {
69+
session.run("RETURN 1 AS one").consume();
70+
}
71+
}
72+
73+
final Timer timer = Metrics.globalRegistry.find("arcadedb.query.duration").tag("protocol", "bolt").timer();
74+
assertThat(timer).isNotNull();
75+
assertThat(timer.count()).isGreaterThanOrEqualTo(1L);
76+
}
77+
}

0 commit comments

Comments
 (0)