Skip to content

CASSANDRA-21644 Fix concurrent SAI vector inserts failing once jvector's per-graph pool limit is exceeded - #5102

Open
JeremiahDJordan wants to merge 4 commits into
apache:cassandra-5.0from
JeremiahDJordan:CASSANDRA-21644-5.0
Open

CASSANDRA-21644 Fix concurrent SAI vector inserts failing once jvector's per-graph pool limit is exceeded#5102
JeremiahDJordan wants to merge 4 commits into
apache:cassandra-5.0from
JeremiahDJordan:CASSANDRA-21644-5.0

Conversation

@JeremiahDJordan

Copy link
Copy Markdown
Contributor

Fix concurrent SAI vector inserts failing once jvector's per-graph pool limit is exceeded.

…aph pool limit

patch by Jeremiah Jordan; reviewed by XXX for CASSANDRA-21644
…ol limit is exceeded

patch by Jeremiah Jordan; reviewed by XXX for CASSANDRA-21644
…urrent writers

Review update: TrieMemtable and the locking ShardedSkipListMemtable serialize updates per shard, so when they have no
more shards than jvector's per-builder limit there is nothing for the semaphore to bound. Add
Memtable.limitsConcurrentWritesTo(int), false by default, and let OnHeapGraph leave the semaphore out when it is true.

patch by Jeremiah Jordan; reviewed by XXX for CASSANDRA-21644

@maedhroz maedhroz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good, but the one gap I think we have now is that, because we use Mockito, VectorMemoryIndexTest actually never tests the non-semaphore happy path. Let's parameterize to have limitsConcurrentWritesTo() return an appropriate value based on how many threads we're actually firing?

commit log span tracking) and `AbstractAllocatorMemtable` (adds memory management via the `Allocator` class, together
with flush triggering on memory use and time interval expiration).

A memtable that serializes writes, for example per shard, can say so through `limitsConcurrentWritesTo`. Secondary

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
A memtable that serializes writes, for example per shard, can say so through `limitsConcurrentWritesTo`. Secondary
A memtable that serializes writes, for example per shard, can say so through `limitsConcurrentWritesTo()`. Secondary

nit

public boolean limitsConcurrentWritesTo(int maxWriters)
{
return boundaries.shardCount() <= maxWriters;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't put this in AbstractShardedMemtable because of Locking?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. The base ShardedSkipListMemtable does not lock, so is unbounded. Only the Locking one limits it, so can return true of the shard count is low enough.

{
if (graphInsertPermits != null)
graphInsertPermits.release(1);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The alternative to this null-checking stuff would be to have some kind of no-op Semaphore, but that does feel like overkill.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. I think that would be overkill and I did not see a reason to replace the null check with a boolean check.

Review update: the mocked memtable always answered false to limitsConcurrentWritesTo(), so the tests never took the
path where OnHeapGraph relies on the memtable and creates no semaphore. Have the mock answer according to the number
of writer threads each test actually uses, so the tests within jvector's limit skip the semaphore and the test beyond
it exercises it. The memtable implementations themselves are covered by MemtableConcurrentWriteLimitTest. Also the
doc nit.

patch by Jeremiah Jordan; reviewed by XXX for CASSANDRA-21644
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.

2 participants