makssent commented on PR #39081:
URL: https://github.com/apache/shardingsphere/pull/39081#issuecomment-4956605653

   I've also been working on BLOB support in the Firebird proxy (#39050). The 
original issue only covered `op_seek_blob`, but since this PR implements the 
full BLOB flow, I'd like to share two bugs I ran into while testing BLOB 
scenarios - both reproduce on this branch as well:
   
   **1. The deferred BLOB handle `0xFFFF` (INVALID_OBJECT) is not resolved.**
   
   Jaybird 5.0.7+ pipelines BLOB operations: it sends `op_put_segment` / 
`op_info_blob` / `op_get_segment` right after `op_create_blob2` / 
`op_open_blob2` without waiting for the response, using the placeholder 
`0xFFFF` (`INVALID_OBJECT`) in place of the not-yet-known handle. The Firebird 
server substitutes the handle of the most recently created object in this case, 
while the proxy looks up `0xFFFF` literally:
   
   - on write, `op_put_segment` finds no blob and silently drops the segment → 
the row is inserted with **empty BLOBs**;
   - on read, `op_get_segment` returns empty data and never reports the 
end-of-blob state (`p_resp_object = 2`), so the client's read loop **never 
terminates**.
   
   Reproducible with Jaybird 5.0.10: INSERT stores empty BLOBs, and a 
subsequent SELECT of a BLOB column hangs.
   
   **2. The `op_get_segment` response declares the alignment padding as part of 
the data.**
   
   The response data must be `[2-byte little-endian length][segment bytes]`, 
with the 4-byte alignment padding written **outside** the declared length. 
Currently the declared length includes the padding, so Jaybird reads the 
padding as data and runs past the buffer on any segment whose length % 4 == 1 
or 3:
   
   ```
   java.lang.ArrayIndexOutOfBoundsException: Index 26 out of bounds for length 
26
       at org.firebirdsql.gds.VaxEncoding.iscVaxInteger2(VaxEncoding.java:165)
       at 
org.firebirdsql.gds.ng.wire.version10.V10InputBlob.getSegment(V10InputBlob.java:136)
       at 
org.firebirdsql.jdbc.field.FBBlobField.getBytesInternal(FBBlobField.java:149)
   ```
   
   Reproducible with Jaybird 5.0.6 by reading back a 21-byte BLOB (2 + 21 = 23 
bytes of payload, 3 bytes of padding, declared length 26). Segments whose 
length % 4 == 0 or 2 survive by luck — that's why small ASCII test payloads 
often pass. Large BLOBs always fail: the client requests chunks of 32765 bytes 
(32765 % 4 == 1).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to