Repository navigation
Description
Summary
Noticed while fixing #8062, and deliberately left out of that PR because it is a different invariant: #8062 is about the retry loop re-running a whole transaction BLOCK, this is about the transport re-sending a single COMMAND.
RemoteHttpComponent.httpCommand wraps every send in its own retry loop and retries on IOException. An IOException is raised for a read timeout and for a connection reset as readily as for "the server was never reached", so a POST /api/v1/command whose request the server received and applied, but whose response never made it back, is sent again. The statement runs twice.
Where (HEAD 642f431)
network/src/main/java/com/arcadedb/remote/RemoteHttpComponent.java:406:
} catch (final IOException | ServerIsNotTheLeaderException e) {
lastException = e;
if (!autoReconnect || retry + 1 >= maxRetry)
break;
if (connectionStrategy == CONNECTION_STRATEGY.FIXED || stickyPinned) {
LogManager.instance()
.log(this, Level.WARNING, "Remote server (%s:%d) seems unreachable, retrying...",
connectToServer.getFirst(), connectToServer.getSecond());
} else {The FIXED/sticky arm falls through to the next loop iteration and re-sends the identical request to the identical server. (The non-sticky arm is safe inside a transaction: it clears the session and raises TransactionException("Server failover during active transaction").)
The server has the machinery to refuse a replay - IdempotencyCache, keyed on the X-Request-Id request header - but this driver never sends that header:
$ grep -n "X-Request-Id\|HEADER_REQUEST_ID" network/src/main/java/com/arcadedb/remote/*.java
(no output)
and AbstractServerHttpHandler excludes session-bound POSTs from the cache by design anyway (exchange.getRequestHeaders().getFirst(SESSION_ID_HEADER) == null is part of the idempotentPost condition), because a session-scoped request's outcome is not settled until the client commits.
Repro
Point a RemoteDatabase with CONNECTION_STRATEGY.FIXED at a server, run an INSERT, and make the response - not the request - fail (drop the connection after the server has applied the statement, or set a read timeout shorter than the statement takes). The row is inserted twice and the call returns success.
Suggested fix
Two independent halves, either of which narrows it:
- Do not retry a send that may have been applied. Java's
HttpClientraisesHttpConnectTimeoutExceptionfor a connection that was never established and a plainHttpTimeoutException/IOExceptiononce the request is on the wire; only the former is provably safe to replay for a non-idempotent method. APOST/DELETEthat failed after the request was written should propagate rather than loop. - Make it safe to retry when it does: send
X-Request-Idand let the server'sIdempotencyCacheanswer the replay. That needs the cache to cover session-bound POSTs, which today it deliberately does not.
Scope / confidence
Code read, with the greps above. The failure needs a response-side network failure, so it is not reproducible by a plain unit test without a proxy or a fault-injecting handler. Falsifiable by showing that the FIXED/sticky arm cannot be reached with a request the server already applied.
Activity
fix(#8136): do not re-send a remote command whose response was lost a…
robfrank commentedon Sep 30, 2026
Fixed in #8527. The remote HTTP client retried a request on any I/O error, including a read timeout or connection reset that happens after the server already received and applied a command, so a lost response could make the same write run twice (on the same server, or on the next one in the cluster). Now a request that may write is retried or failed over only when the error proves it never reached the server (the connection was never established); otherwise the client raises a
RemoteExceptionsaying the server may already have applied it. Read-only queries andGETrequests are still retried as before. With the default settingscommand()already made a single attempt, so the visible change is for setups witharcadedb.network.sameServerErrorRetry> 0 or HA failover retries.Still open:
X-Request-Idthe server can deduplicate: Remote HTTP driver: send X-Request-Id so a write whose response was lost can be retried safely (follow-up to #8136) #8526transaction()re-run the block: gRPC client: a CommitTransaction whose response is lost maps to NeedRetryException, so RemoteDatabase.transaction() re-runs and re-commits the block #8525❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.