wernerdv commented on code in PR #13554:
URL: https://github.com/apache/ignite/pull/13554#discussion_r4004787189
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/freelist/AbstractFreeList.java:
##########
@@ -701,10 +713,29 @@ private int writeWholePages(T row, IoStatisticsHolder
statHolder) throws IgniteC
* @throws IgniteCheckedException If failed.
*/
private int writeSinglePage(T row, int written, IoStatisticsHolder
statHolder) throws IgniteCheckedException {
+ // TOCTOU closure: the size-aware reserve (ensureFreeSpaceForInsert,
invoked from RowStore.addRow/addRows
+ // before this write) accumulates enough real empty pages but does not
pin them to this thread - a concurrent
+ // writer can consume them between the reserve and this allocation.
When the free list cannot hand out a page,
+ // re-reserve on the remaining size and retry before allocating a
brand-new page; otherwise the race surfaces
+ // as a raw IgniteOutOfMemoryException (wrapped into
CorruptedFreeListException in the batch path).
+ //
+ // The re-reserve is an inline demand-eviction: reached from the
BPlusTree.invoke row-creation closure, it may
+ // re-entrantly remove other entries from the same data tree. That is
safe because the closure runs with no
Review Comment:
Partially correct.
The premise — "BPlusTree.invoke holds the leaf write lock while running the
closure" — is not supported by the code: BPlusTree.invokeDown releases the leaf
read lock when read(...) returns and takes the leaf write lock only afterwards
(in tryInsert/tryReplace/tryRemoveFromLeaf). Your broader point stands: entry
tryLock covers only entry-level ordering and does not make eviction page-level
lock-free.
The cross-tree (data→pending vs pending→data) residual risk with the TTL
worker is real and documented in the code comment; a full fix is out of scope.
Please correct me if I'm wrong.
--
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]