The good news is that I believe I have found a way around the problem. The bad news is that I think I have found another minor bug.

The workaround for variable message sizes is to compute the "used" buffer size after each call to IBatch::add by ensuring that getAlignedLength() is refreshed for each message buffer and adding this to the running total. It is then possible to identify when the buffer will overflow before IBatch::add is called and take appropriate action.

The minor bug is that if TAG_BUFFER_BYTES_SIZE is set to > 256MB no error status is reported on a call to createBatch. Instead, you only know you have a problem when an error is returned from IBatch::add - looks like the buffer size is simply limited to 256MB.

On 21/08/2021 12:35, Tony Whyman wrote:

On 20/08/2021 16:18, Alex Peshkoff via Firebird-devel wrote:
On 8/20/21 4:01 PM, Tony Whyman wrote:


You can specify such limit - use IBatch::TAG_BUFFER_BYTES_SIZE parameter in batch parameters block when creating a batch, default is 16Mb, hard limit - 256Mb. Ywo such buffers will be available - one for messages data, other - for blobs.
Well, in theory OOM can take place later, but that is abnormal case.
Alternatively, I could also work with an IBatch method that told me the minimum number of guaranteed calls to IBatch::add (for a given message buffer size). Other suggestions are welcome.

Divide what you've requested in TAG_BUFFER_BYTES_SIZE by getAlignedLength() of your message. But be aware that this will not work when/if we move to variable message size and string field with unrestricted length.


And this is where the problem lies. We need a long term strategy.

One possible strategy would be to choose a number (e.g. 100), multiply it by getAlignedLength() and then set TAG_BUFFER_BYTES_SIZE to either the assumed default (16MB) or a larger value if 100* getAlignedLength() > 16MB.

The problem is that, as you note, this will fail "when/if we move to variable message size". Perhaps a getMaxAlignedLength() is needed, or a TAG to force fixed alignment?



Firebird-Devel mailing list, web interface at https://lists.sourceforge.net/lists/listinfo/firebird-devel



Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to