Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cassandra clusters specify initial token for large startup speedup #844

Merged
merged 4 commits into from Oct 11, 2022

Conversation

rukai
Copy link
Member

@rukai rukai commented Oct 6, 2022

The shotover-int-tests/cassandra:4.0.6 image no longer sets a CMD, it now falls back to CMD ["cassandra", "-f"], which is the safest default.
None of our docker-compose.ymls actually use that fallback though and instead overwrite it in various ways as detailed below:

Cluster tests

We make use of shotover-int-tests/cassandra:4.0.6 to set some config we previously relied on bitnami for and then use the custom command to set initial_token, which even bitnami didn't offer.

In order to keep the token list more readable we do some weird things with environment variables.
The token list is set to the docker-compose env var CASSANDRA_INITIAL_TOKENS.
Then the container uses that environment variable at runtime.
We have to use $$ to escape the $ otherwise docker-compose will substitute the variable with an empty string, rather than letting the container do the subsitution.

Manually specifying the tokens allows cassandra cluster init to skip a lot of waiting around and takes the time for initialization to complete on my machine from 70s to 15s

It will also allow us to improve the quality of the integration tests as we will be able to make assertions on the tokens returned in system.local.
This will be done in a follow up though.

The tokens were chosen by extracting them from the naturally randomly generated tokens of a real cluster.
Possibly 128 tokens per node is excessive and it would be easier to deal with if we reduced it to say 16per node, but I'll leave that for a potential follow up.

The dc1 -> Mars change in test_cassandra_peers_rewrite_cassandra4 was needed because its docker-compose.yml was setting CASSANDRA_DC: Mars which was previously unused by the bitnami image, but now that we are using the official image as a base the CASSANDRA_DC field is being properly picked up.

Single instance tests

The only change here was to set the command: cassandra -f -Dcassandra.skip_wait_for_gossip_to_settle=0 -Dcassandra.initial_token=0
I think this is an improvement as setting the command explicitly shows the mild hack these tests use to speed up initialization.

@rukai rukai force-pushed the initial_tokens branch 4 times, most recently from aedddd5 to 1c8a6fc Compare October 6, 2022 01:43
@rukai rukai marked this pull request as ready for review October 6, 2022 04:06
@rukai rukai enabled auto-merge (squash) October 11, 2022 03:21
@rukai rukai merged commit 95e2090 into shotover:main Oct 11, 2022
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.

None yet

3 participants