Repository navigation
Description
Split out of #7382, which put the gRPC InsertBidirectional control frames (start / chunk / commit / rollback) on /ws.
#7382 landed the server-side frames and nothing else. Three gaps remain, all in the same protocol pass and all
verified by the same hand-written WebSocket IT, so they are tracked here together rather than as three separate
edits to WebSocketInsertProtocol / WebSocketInsertSession.
This issue absorbs #7405 (frame size caps) and #7406 (Java client).
1. The session cannot join an externally-managed transaction
gRPC's Start message carries a TransactionContext transaction field, and #6795 made insertBidirectional
honour it: rows sent under an externally-begun transaction join it, and the caller's own rollback undoes them.
InsertOptions.TransactionMode.NONE ("caller manages externally") is the mode that goes with it.
The /ws session has no way to name an existing transaction. POST /api/v1/begin mints an HTTP session id
(arcadedb-session-id) whose TransactionContext lives in HttpSessionManager, so the plumbing exists on the
HTTP side - what is missing is a start frame field that resolves it, plus the ownership check that a /ws
client may only adopt a session its own principal opened.
Until then transactionMode: "none" is refused at start with a message pointing here, rather than silently
begun as a server-managed transaction.
What is missing:
startframe accepts a"sessionId"-style reference to an HTTP session transaction (name TBD, e.g.
transactionId).- The session skips
begin/commit/rollbackentirely for that mode: the HTTP/commitor/rollback
call owns the lifecycle, exactly asInsertContext.externalTransactiondoes on the gRPC side. - Ownership enforcement:
HttpSessionManager.getSessionById(user, id)already refuses a session owned by another
principal; the/wspath must go through it rather than around it. - A rejection - not a silent fall-through to a server-managed transaction - when the referenced transaction is
unknown or expired, mirroring gRPC'sFAILED_PRECONDITION.
2. A text frame is buffered whole with no size cap (was #7405)
WebSocketReceiveListener extends Undertow's AbstractReceiveListener without overriding
getMaxTextBufferSize(), which defaults to -1 - unbounded. Every text frame is therefore accumulated in full,
on the heap, before onFullTextMessage sees it, and a client that never sends the final fragment holds that
buffer for as long as the connection lives.
That has always been true of the subscribe / unsubscribe frames, where the exposure is small because a
legitimate frame is a few hundred bytes and there was no reason to send a large one. #7382 changes the size of
the hole rather than opening it: a chunk frame legitimately carries a whole batch of records, so clients now
have a reason to send multi-megabyte frames and the server has no way to say "not that big". An authenticated
client can pin an arbitrary amount of heap per connection.
What is missing:
- A cap on the accumulated text-frame size for
/ws, refused with a protocol-level close or anerrorframe
rather than anOutOfMemoryError. - A separate, larger cap for the insert
chunkframe than for the control frames, if one number cannot serve
both. - A
GlobalConfigurationsetting for it, so an operator running a bulk loader can raise it deliberately. - A companion cap on rows per chunk, which is the number a client actually reasons about.
Notes: authentication happens at the HTTP upgrade, so this is not reachable anonymously - it is a
resource-exhaustion hole for an authenticated principal, not an unauthenticated one. Undertow's
WebSocketChannel also carries setMaximumBufferSize; whether the cap belongs on the listener or on the channel
at handshake time is part of the work.
3. There is no client: RemoteDatabase cannot open a session (was #7406)
#7382 is server-side only. RemoteDatabase has no method that opens a /ws insert session, so the only way to
use the feature from Java is to bring an Undertow (or JDK 11 WebSocket) client and hand-write the frames -
which is what the new IT does.
The gRPC side has the counterpart: RemoteGrpcDatabase.insertBidirectional* wraps the duplex call, holds the
session, and hands the caller a per-chunk acknowledgement callback. RemoteGraphBatch is the equivalent for the
HTTP /batch endpoint and grew a progress callback in #7311.
What is missing:
- A
RemoteDatabase-level entry point that opens the/wssession, sends chunks, surfaces eachbatchAckto a
callback, and lets the caller decidecommit/rollbackafter seeing them. That "decide after seeing the
acks" is the whole point of the control frames, and it is the partRemoteGraphBatch's progress callback
structurally cannot offer. - The same for the Python, Go and JS clients, or an explicit note that they are out of scope.
- Documentation of the frame shapes outside the server class javadoc, since OpenAPI cannot describe
/ws(which
is why it is deliberately absent from the generated document).
Why these three are one issue
All three land in server/src/main/java/com/arcadedb/server/http/ws/ - (1) and (2) both change what start and
chunk accept at the same decode point in WebSocketInsertProtocol, and (3) is the client that must send both
the new start field and chunks inside the new caps. Split, they mean three passes over the same protocol class
and three hand-written WebSocket ITs; (3)'s test is also the natural verification for (1).
Verification
- A
/wssession started against a live HTTP session transaction, whose rows do not survive
POST /api/v1/rollbackon that session. - The same rows surviving
POST /api/v1/commit. - A
/wsstartnaming another user's session id refused. - A text frame larger than the configured cap closed/refused without the server retaining the partial buffer.
- A
chunkframe at the cap still accepted. - A Java test that loads records through the
RemoteDatabaseentry point, rolls back after the first ack, and
finds the database empty. - The same test committing and finding every record.
Activity
[-]A /ws insert session cannot join an externally-managed transaction, so InsertOptions.NONE has no counterpart[/-][+]Complete the /ws insert session: external transaction, frame size caps, and a Java client[/+]feat(#7403): external transaction, frame size caps and a Java client …
robfrank commentedon Sep 17, 2026
Fixed in #7811. All three gaps this issue tracks (it absorbed #7405 and #7406) are closed.
1. External transaction. A
startframe now accepts a top-leveltransactionId- thearcadedb-session-idthatPOST /api/v1/beginreturned - which is what makestransactionMode: "none"meaningful instead of refused. The session writes into that transaction and never begins, commits or rolls it back; its own transaction field stays null, so all four teardown paths (thecommitframe, connection close, the idle sweep, server shutdown) are no-ops on the caller's transaction by construction rather than by four separate guards. Resolution goes through the ownership gate, so you can only adopt a transaction your own principal opened, and each chunk runs under the same lock and idle clock an HTTP command on that transaction takes. Thecommitframe answersoutcome: "detached"rather than claiming a commit - your HTTP/commitis what makes the rows durable.2. Frame size caps (was #7405). Undertow's unbounded text-buffer limit is replaced with two budgets plus a row cap:
arcadedb.server.wsMaxControlFrameSize(64 KB, until the connection dispatches astart),arcadedb.server.wsMaxInsertFrameSize(16 MB, after it), andarcadedb.server.wsMaxInsertChunkRows(100,000). The bound is enforced as the frame is read, not after it is whole. A rows-per-chunk breach leaves the session open so you can split and resend; a byte breach is a1009 TOO_BIGclose. All three are re-read per frame, so raising one on a running server does not require reconnecting loaders;0restores the old behaviour.3. Java client (was #7406).
database.newInsertSession()returns aRemoteInsertSessionbuilt on the JDK's own WebSocket - no new dependency - that surfaces every batch ack before you decide commit or rollback, withjoinCurrentTransaction()wiring it to gap 1.4. Found while testing:
WebSocketReceiveListener.onClosehas never calledsupersince the class was written in 2021, so the closing handshake never completed and the server just stopped answering. Worth 30 seconds per connection to any client that waits for it - the new client's IT went from 182 s to 1.7 s with the one-line fix.Still open
/wsinsert session: #7807.startand nevercommitkeeps the 16 MB budget on that connection even if thestartwas refused (bounded, where it was unbounded before, and further bounded by the 64-frames-in-flight cap from A truly bidirectional insert session has no HTTP counterpart: the Start/Commit control frames belong on /ws #7382); nothing prevents two/wssessions on two connections naming the sametransactionId(same principal, serialized by the session lock, and the gRPC path has the same property); and a/wschunk does not attach the session as the thread'sQuerySession, so ISO GQL session parameters are not merged into the key-lookup SQL - harmless today because that SQL binds positional parameters only.❤️ 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.
build(java17): undertow-core 2.4.3.Final for the WebSocket frame caps