Repository navigation
Description
Summary
ServerIsNotTheLeaderException states the rule in its own javadoc, on the helper the fix family was built around:
The leader refusal a wire protocol must answer as a redirect rather than as a retryable conflict ... Found anywhere
along the cause chain, because the engine wraps what it raises (a commit failure, a planner failure).
and leaderSentence() says why it exists at all:
the sentence a wire protocol appends to its error text for a refusal
redirectInfound, so every transport words it
the same way.
The Redis arm of that change adds the second half of the rule, which is the part that matters here:
Appended AFTER concealment, as the gRPC transport does: it is an address the cluster put there, not engine detail,
and the only thing that makes the refusal actionable.
So the invariant is: a refusal that names a leader leaves every transport naming that leader, in every server mode,
and never as the transport's ordinary retryable conflict. grep -rln ServerIsNotTheLeader */src/main answers the
census: server, grpcw, bolt, postgresw, redisw, mongodbw. mcp and gremlin are empty.
MCP. MCPHttpHandler extends AbstractServerHttpHandler, so the shared classification is right there:
AbstractServerHttpHandler:1087 turns a named leader refusal into a 400 carrying the leader address in
exceptionArgs. The MCP surface never reaches it, because MCPDispatcher.handleToolsCall catches the exception
itself, three arms down, in catch (final Exception e), and answers an in-band JSON-RPC tool error built from
failureMessage(...). That path:
- drops the address.
failureMessageusese.getMessage(), and the message of a leader refusal carries no address
(ServerIsNotTheLeaderExceptionholds it in a field; onlytoString()appends it). So even in development mode the
client is told "Changes to the schema must be executed on the leader server" and not which node that is. - removes the refusal entirely in production mode.
failureMessagecallsclientMessage, which for a concealing
server returnsArcadeDBServer.CONCEALED_ERROR_MESSAGEfor every category other than the argument exceptions
handled above it. A leader refusal isErrorCategory.RETRY, notSECURITYand notMCPToolArgumentException, so it
is concealed: the caller cannot tell a follower refusing leader-only work from a disk error. Redis explicitly refused
that outcome ("appended after concealment ... the only thing that makes the refusal actionable"); MCP has no such
arm. - leaves the retry loop pointed at the same node. Every MCP write runs inside
MCPToolUtils.collectInTransaction,
i.e.Database.transaction(...), which re-runs its block on aNeedRetryException;ServerIsNotTheLeaderException
extendsNeedRetryException, so the follower is retriedarcadedb.txRetriestimes before the concealed answer goes
out. That is the same "the client retries the same follower instead of being redirected" that A leader refusal reaches a Bolt, MongoDB or Postgres client as an ordinary write conflict, so the client retries the same follower instead of being redirected #9845's own title
names, one level lower.
The MCP caller is an autonomous agent, which is the case this matters most for: it has no topology discovery, it reads
only the text of the tool error, and it is the one client that cannot be expected to know to call server_status and
re-resolve a host for itself.
Gremlin Server. The same shape with a different ladder. ConcealingWebSocketChannelizer.ErrorConcealer rewrites
the status message of SERVER_ERROR, SERVER_ERROR_TEMPORARY, SERVER_ERROR_EVALUATION and
SERVER_ERROR_SERIALIZATION to CONCEALED_ERROR_MESSAGE in production mode, and a script whose write is refused by a
follower lands in exactly those codes. There is no redirectIn arm before the rewrite and no leader sentence after
it, so a production Gremlin Server answers a leader refusal with the placeholder and a development one with the bare
message, neither naming the leader.
Where (HEAD 5100e4b)
mcp/src/main/java/com/arcadedb/mcp/MCPDispatcher.java:457
} catch (final Exception e) {
return toolError(id, failureMessage("tools/call '" + toolName + "'", e));
}and :475
private String failureMessage(final String operation, final Exception e) {
if (ErrorConcealment.isConcealing(server))
return clientMessage(operation + " -> " + e.getMessage(), e);server/src/main/java/com/arcadedb/server/ErrorConcealment.java:97 - what a concealing server answers
return ArcadeDBServer.CONCEALED_ERROR_MESSAGE;server/src/main/java/com/arcadedb/server/http/handler/AbstractServerHttpHandler.java:1087 - the shared answer the
MCP route inherits and never reaches
final ServerIsNotTheLeaderException notTheLeader = firstOf(e, cause, ServerIsNotTheLeaderException.class);
if (notTheLeader != null && notTheLeader.getLeaderAddress() != null && !notTheLeader.getLeaderAddress().isBlank()) {
return new ErrorClassification(400, "Cannot execute command", notTheLeader, notTheLeader.getLeaderAddress(), ErrorLogKind.USER);
}redisw/src/main/java/com/arcadedb/redis/RedisNetworkExecutor.java:505 - the arm every member of the family has and
these two do not
static String withLeaderRedirect(final String text, final Throwable error) {
final ServerIsNotTheLeaderException refusal = ServerIsNotTheLeaderException.redirectIn(error);
return refusal != null ? text + ". " + refusal.leaderSentence() : text;
}gremlin/src/main/java/com/arcadedb/server/gremlin/ConcealingWebSocketChannelizer.java:78 - isServerFailure, the
codes a leader refusal arrives under, rewritten with no redirect arm.
mcp/src/main/java/com/arcadedb/mcp/tools/MCPToolUtils.java:320 - the retry loop a refusal is spent inside
(collectInTransaction -> Database.transaction).
ha-raft/src/main/java/com/arcadedb/server/ha/raft/RaftReplicatedDatabase.java:3924 - the canonical refusal, the one
every #9845 test is written against, which names the leader whenever the HA plugin knows one
private ServerIsNotTheLeaderException schemaChangesNeedTheLeader() {
final String leaderAddr = raftHAServer != null ? raftHAServer.getLeaderHttpAddress() : null;
return new ServerIsNotTheLeaderException("Changes to the schema must be executed on the leader server",
leaderAddr != null ? leaderAddr : "");
}Repro
Not run against a cluster: an HA cluster plus an MCP transport is the fixture, and the module's own tests for this
family are unit tests over the mapping function for exactly that reason (#9870 is open against the absence of an
end-to-end one). The check that matches how every existing member is pinned is a unit test of the same shape as
Issue9845RedisLeaderRefusalTest:
- give
MCPDispatchera seam for the tool-failure text (it already hasfailureMessage, package-private would do),
feed itnew TransactionException("commit", new ServerIsNotTheLeaderException("Changes to the schema must be executed on the leader server", "arcadedb-0:2480"))with the server concealing, and assert the answer ends with
The leader is server 'arcadedb-0:2480'. Today it is exactlyCONCEALED_ERROR_MESSAGE. - the same assertion for
ConcealingWebSocketChannelizer's rewrite.
Issue9845RedisLeaderRefusalTest.theMessageNamesTheLeaderEvenWhenConcealed is that assertion, already written, for
the transport that has the arm.
FAMILY: the transports that answer a follower's leader refusal
| transport | entry point | leader refusal answered as | names the leader | survives production concealment |
|---|---|---|---|---|
HTTP /api/v1/* |
AbstractServerHttpHandler.classify |
400 + exceptionArgs = address |
yes | yes |
| gRPC | GrpcErrorMapper.toStatusRuntimeException |
status + LeaderRedirectProtocol trailers |
yes | yes |
| Bolt | BoltNetworkExecutor (#9845) |
a NotALeader code + leaderSentence() |
yes | yes |
| PostgreSQL | PostgresNetworkExecutor (#9845) |
error field + leaderSentence() |
yes | yes |
| Redis | RedisNetworkExecutor (#9845) |
READONLY + leaderSentence() |
yes | yes |
| MongoDB | MongoDBDatabaseWrapper.wireException (#9845) |
NotWritablePrimary (10107) + leaderSentence() |
yes | yes |
/ws insert |
WebSocketInsertProtocol (#9868) |
NOT_LEADER + address |
yes | yes |
| gRPC streaming insert chunk | - | DB_ERROR |
no | no (#9930, already open) |
| MCP tool call | MCPDispatcher.handleToolsCall |
in-band JSON-RPC tool error | no | no |
| Gremlin Server script | ConcealingWebSocketChannelizer.ErrorConcealer |
SERVER_ERROR_* |
no | no |
Suggested fix
The duplicated piece is already extracted: ServerIsNotTheLeaderException.redirectIn(error) plus leaderSentence().
Both surfaces need the two lines that every other member has, in the one place each builds its client text:
// MCPDispatcher.failureMessage / clientMessage, after concealment
final ServerIsNotTheLeaderException refusal = ServerIsNotTheLeaderException.redirectIn(e);
return refusal != null ? text + ". " + refusal.leaderSentence() : text;and the same before ErrorConcealer rewrites a SERVER_ERROR_* status message.
What would stop a ninth transport from missing it is not the two patches but a test that asks the question of all of
them at once, which is what #9870 is open for. The shape that would hold: one parameterised test over the list of
"things that turn a Throwable into client text", each handed the same
new TransactionException("commit", refusal("arcadedb-0:2480")) and asserted to produce text containing the address,
with a concealing server. That is a list the module boundary makes awkward (each transport is its own Maven module),
so the cheaper version that still pins the rule is a check in the server module that
ServerIsNotTheLeaderException.redirectIn has a caller in every module that registers a wire protocol plugin, failing
when a new one appears without it. Either way the assertion belongs to the rule ("every transport names the leader"),
not to the six cells that currently do.
Scope / confidence
Refutation attempted:
(a) that MCP cannot reach a leader refusal because a follower forwards writes to the leader. It forwards through
RaftReplicatedDatabase.command() for a DDL or non-idempotent statement, and that forward itself raises this
exception in the cases the #9845 family exists for: the leader's HTTPS endpoint unreachable
("Cannot forward the command: " + dial.refusal(), naming the leader), the address resolved for the leader being this
node's own, and a write a peer already forwarded. recordFileChanges refuses outright, with
schemaChangesNeedTheLeader(). MCP's execute_command accepts DDL (MCPPermissions.isAllowSchemaChange, checked in
ExecuteCommandTool.checkPermission), so it reaches both. None of this is MCP-specific, which is the point: the other
six transports reach the same exception by the same routes and answer it properly.
(b) that the agent can find the leader another way. server_status does report HA state (ServerInfo.toJSON), so a
caller that already suspects a leader problem can resolve the address. That does not help the case this is about: in
production mode the tool error does not say a leader problem happened at all, so there is nothing to prompt the second
call, and the whole point of leaderSentence() is that the address rides on the refusal.
(c) that an in-band JSON-RPC tool error is the wrong place for routing information. It is the only place: the MCP
transport answers HTTP 200 for a tool failure by construction (MCPHttpHandler.execute returns
response.httpStatus(), which is 200 for a dispatched call), so the text of the tool error is the entire channel.
Redis, Postgres and Mongo are in the same position and append the sentence to their error text.
(d) that concealing the address is deliberate, because production mode hides server internals. The Redis arm of #9845
answers this in its own comment, quoted above: the address is "an address the cluster put there, not engine detail".
gRPC was already doing it. Two members of the family decided this explicitly and in the same direction.
(e) that the Gremlin half is covered by #9639/#9317, which are about that wire's concealment. Those made the Gremlin
Server conceal engine text, which is the opposite direction; neither adds a redirect, and grep -rn ServerIsNotTheLeader gremlin/src is empty.
(f) that ErrorCategory.of might not read a wrapped refusal as RETRY, so redirectIn would answer null anyway and
the arm would be dead. It does: ServerIsNotTheLeaderException extends NeedRetryException, and
Issue9845RedisLeaderRefusalTest asserts the wrapped form (new TransactionException("commit", refusal(LEADER)))
maps to READONLY.
Activity
refactor(#9962,#9960): Postgres reuses RunningQuery.Client.of; docume…
refactor(#9960): name the concealed Gremlin message before building t…
Merge pull request #9980 from ArcadeData/fix/9962-9960-mcp-gremlin-cl…
lvca commentedon Oct 14, 2026
Fixed by #9980 (26.11.1).
When a cluster follower refuses work that only the leader can do, MCP tool errors and Gremlin Server errors now name the leader, like every other protocol already did:
This also applies in production mode, where the rest of the error text stays hidden: the leader address is added after the generic message, so a client or an AI agent knows where to retry. For the Gremlin Server the address shown is the leader's HTTP address; connect to its Gremlin port.
Follow-up: #9995 (the server still retries such a refusal a few times on the same node before answering).
❤️ 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.
fix(ArcadeData#9962,ArcadeData#9960): every list queries entry names …
fix(#9962,#9960): every list queries entry names its client, and MCP …
refactor(#9962,#9960): Postgres reuses RunningQuery.Client.of; docume…
refactor(#9960): name the concealed Gremlin message before building t…