On 6/7/23 17:39, Mark Rotteveel wrote:
> On 07-06-2023 15:39, 'Alex Peshkoff' via firebird-devel wrote:
>> On 6/7/23 14:33, Mark Rotteveel wrote:
>>> I'm trying to switch from blr_quad to blr_blob2 in Jaybird, but when
>>> I do so, executing server-side batches result in error "Unknown blob
>>> ID 0:1 in the batch message" (335545197).
>>>
>>> Jaybird currently does not use the batch API to *create* blobs, it
>>> just populates blob ids of blobs created separately.
>>
>> Do you emulate registerBlob() call over the wire? Do you use
>> op_batch_regblob? (Hmm - no idea how could it work without
>> op_batch_regblob but ask anyway...)
>
> OK, sending op_batch_regblob and registering the blob id as itself
> does the trick. But honestly, I would think - as proven by the fact it
> works with blr_quad - this shouldn't be necessary.
>
That's because blr_quad is never used internally by firebird to
represent blobs. In batch code I do not work with BLR, I work with SQL
types, where SQL_BLOB and SQL_QUAD are different types. And all
BLOB-specific processing is performed only for SQL_BLOB, cause I have no
idea what exactly represents SQL_QUAD - blob or unaligned 64-bit number.
Therefore yes, when using quad one can put IDs of existing blobs into it
and everythig will work.
> Also, it works no matter which value of TAG_BLOB_POLICY I use (even
> invalid values!),
Yes, because quad is not blob. BTW, invalid values default to 0 (no
blobs at all), but for quads it's ok too.
> so that is a bit confusing.
>
> Another thing I found curious is why op_batch_regblob only registers
> one blob at a time. Why not allow it to register multiple blobs at
> once? I know it uses deferred packets, but it feels a bit inefficient
> nonetheless.
Certainly. Moeover, using traditional BLOB API is very inefficient,
specially when compared with batch. For huge blobs it does not matter
much cause sending huge data will require much more resources (including
time) compared with sending deferred packet (and even open/close blob
over the wire!), but for small BLOB sending it using native batch tools
is much better than traditional BLOBs API. Be sure - compared with
traditional API use of registerBlob() does not matter from efficiency
POV. I've checked with gbak's restore (using localhost: access) of
artificial database with single table, containing many small blobs. In
that case restore using batch runs approximately 10 times faster than
non-batched gbak. So if you care about batch performance please do not
use traditional API for BLOBs.
>
> Also, I see in the Firebird code that there is a limit of 64 pending
> deferred packets. Is that a real limit, or is that to prevent other
> issues, and if so, what issues?
OOM on client, very slow run and problems with error recovery in
applications (all for really huge query of packets, do not remember
details better).
64 appeared to be good compromise.