Skip to content

fix: wait for rows split across packets, stop trapping when a stream fails - #12

Merged
datlechin merged 2 commits into
tablepro-mainfrom
fix/3241-split-rows-and-stream-error-trap
Oct 2, 2026
Merged

datlechin merged 2 commits into
tablepro-mainfrom
fix/3241-split-rows-and-stream-error-trap

Conversation

@datlechin

Copy link
Copy Markdown
Member

Why

TablePro #3241: browsing an Oracle table with SDO_GEOMETRY and BLOB columns ended the host process. When a TNS packet ended inside a row's last field (the LONG RAW trailer of a BLOB, or a NULL object's flags), the non-throwing skips read what had arrived and reported the row complete. The rest of the field was then read as a message ID, the connection failed mid-stream, and delivering that failure called back into cancel(for:) while the stream was still attached, which hit the cancelStatementStream precondition. Any close() while rows were streaming hit the same trap.

Change

  • Every read and skip in the backend message decoders throws when its bytes have not arrived, so the decoder retries the message with the next packet (as upstream Throw on all skips if not enough bytes are readable yet lovetodream/oracle-nio#123 and python-oracledb do). Reader moves throw instead of trapping.
  • The row stream marks itself consumed before finishing the async sequence, the handler detaches the stream before delivering an error, and a cancel or row request after the statement ended does nothing (the postgres-nio fixes for its #347).
  • An undecodable message fails as messageDecodingFailure; a NULL object decodes as NULL; the LONG trailer is read on fetched rows only; an impossible IO-vector bind count is rejected.

Verified

New unit tests fail on tablepro-main and pass here. On Oracle 21c XE and 23ai, including real MDSYS.SDO_GEOMETRY, the reporter's browse query returns all 1000 rows where it crashed before.

Not in this PR

  • OracleConnectionTests.oobCheckWorks fails and hangs on tablepro-main too.

…ng when a stream fails

A row whose last field ended in the next TNS packet was reported complete, because the
skips for the LONG/LONG RAW trailer, the object version and flags, and the row header
read what had arrived and returned without asking for more. The rest was then read as
a message ID, the connection failed mid-stream, and delivering that failure called
back into cancel(for:) while the stream was still attached, which hit the
"cancel stream without active statement" precondition and ended the host process.

- Every skip and read in the backend message decoders throws when its bytes have not
  arrived, so the decoder retries the message with the next packet (upstream lovetodream#123).
- throwingSkipRawBytesChunked treats 0xFF as NULL and drops the 254-byte precheck
  that left a short chunked value waiting forever.
- Reader moves in message decoders throw instead of trapping on a short buffer.
- OracleRowStream marks itself consumed before it finishes the async sequence, the
  channel handler detaches the stream before delivering an error, and a cancel or row
  request after the statement ended is ignored (postgres-nio #351, #456, #566).
- A message the decoder cannot read fails as messageDecodingFailure, not as a lost
  connection.
- A NULL object decodes as NULL.
…e bind counts

An OUT bind of type LONG or LONG RAW ends with its actual byte count, not the null indicator and return code a fetched LONG carries, so the trailer is read only for fetched rows. The bind count in an IO vector is computed without UInt32 overflow and rejected when the statement could not have bound that many.
@datlechin
datlechin merged commit 0da69f8 into tablepro-main Oct 2, 2026
@datlechin
datlechin deleted the fix/3241-split-rows-and-stream-error-trap branch October 2, 2026 14:33
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.

1 participant