Cursor with multiple batches is closed twice
aburmeis opened this issue · comments
When watching documents from the server using a cursor, this works fine if not reading to the end or the result size is below the batch size.
When fetching multiple bulks including the last, it seems the server closes the cursor itself and ArangoCursorImpl.close() tries this again resulting in a server error. It seems the allowRetry set to true in the constructor leads to an unused close()-call even it the result has no more documents.
If the enforced close is needed for retry, maybe passing the flag to the constructor directly from the options.getOptions().getAllowRetry() in ArangoDatabaseImpl.createCursor() would have less side effects.
Hi @aburmeis ,
thanks for reporting this.
When closing the cursor, the closing request is sent only if the following condition is met:
and I think this is OK.
But the real problem is the (wrong) way used to derive allowRetry:
since also non-retriable AQL cursors could return the nextBatchId attribute.
To fix it, allowRetry should be set based on the AQL cursor creation options.
This needs to be fixed both in ArangoCursorImpl and ArangoCursorAsyncImpl.