Skip to content

CASSANDRA-21019 – 6.0 – Separate memtable memory usage tracking from limit checking - #5049

Closed
michaelsembwever wants to merge 4 commits into
apache:cassandra-6.0from
thelastpickle:mck/21019/6.0
Closed

CASSANDRA-21019 – 6.0 – Separate memtable memory usage tracking from limit checking#5049
michaelsembwever wants to merge 4 commits into
apache:cassandra-6.0from
thelastpickle:mck/21019/6.0

Conversation

@michaelsembwever

Copy link
Copy Markdown
Member

No description provided.

Brings this branch in line with the review of the trunk PR,
apache#5050, where the comments were left.

Identify nested writes by write context, not by the updateIndexes flag.
Index build, index cleanup during compaction and stale entry purge all write
with updateIndexes == false, each on its own context, so each must still wait
for pool room. CassandraWriteContext now marks the outermost memtable write,
and ColumnFamilyStore.apply routes a write on an already-marked context to
putNested. Replaces MemtableNestedPutSkipsRoomWaitTest, which mutated the
shared MEMORY_POOL counters, with NestedMemtableWriteTest. Reverts the
ColumnFamilyStore.apply and TableWriteHandler javadoc that described
updateIndexes as the nesting signal.

Reject memtable_offheap_space: 0 at startup when memtable_allocation_type is
offheap_buffers or offheap_objects. awaitRoom skips a sub-pool whose limit is
0, which is needed for the heap-only allocation types, but which would leave
off-heap memtable memory unlimited for these two. Such a node could not make
progress on writes before this fix, so no working deployment has that config.
Documented in cassandra.yaml and NEWS.txt, with tests in
DatabaseDescriptorTest.

Correct the comments the reviewer read as inaccurate: awaitRoom's zero-limit
guard no longer claims that such a pool is never allocated from or never
signalled, and MemtablePool.limit says the same; put() is gated per
PartitionUpdate rather than per mutation, and its wait is unconditional, so a
deletion or a write that loses on timestamp waits too; putNested's
precondition is a barrier on Keyspace.writeOrder, which is shared by every
table, so the flush that deadlocks need not be of the memtable being written.
markExtraOnHeapUsed and markExtraOffHeapUsed no longer promise to block.

Unlike trunk, this branch keeps the OpOrder.Group parameter on
SubAllocator.allocate, SubAllocator.adjust, Memtable.markExtraOnHeapUsed and
Memtable.markExtraOffHeapUsed. The group is unused now that these calls never
wait, but removing it would change a published interface inside a release
series. The javadoc says so at each one.
… in checkSpaceAndPut()

Brings this branch level with mck/21019/trunk, which took two further comments on apache#5050 after the previous squash.

Rename the API so that the method an implementer writes is the plain one. Memtable.put is now the ungated write, AbstractAllocatorMemtable.performPut is gone, and the entry point a write starting a mutation calls is Memtable.checkSpaceAndPut. ColumnFamilyStore.apply, AccordKeyspace, TrieMemtableShardLockDeadlockTest and the three memtable implementations follow. Behaviour is unchanged: the same call sites gate, and a nested write still reaches put() directly.

Add the MemtableAllocatorAwaitRoomTest case for the other half of the invariant. Accounting an allocation must record and return while the pool is over its limit rather than park, which is the path markExtraOnHeapUsed takes.

Trunk's remaining review commit also drops the now-unused OpOrder.Group from SubAllocator.allocate, SubAllocator.adjust, Memtable.markExtraOnHeapUsed and Memtable.markExtraOffHeapUsed. This branch does not, for the reason recorded in the previous squash: those are published methods inside a release series.

Assisted-by: Claude Code:claude-opus-5
@michaelsembwever

Copy link
Copy Markdown
Member Author

committed as 2152f78

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants