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

fix: Shard MeasurementsByContinuationToken index to avoid hotspotting #1852

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

SanjayVas
Copy link
Member

From the Cloud Spanner documentation on secondary indexes:

Be aware that using the commit timestamp column as the first part of the secondary index can create hotspots and reduce write performance.

Sharding is one of the recommendations given for how to avoid hotspotting.

@SanjayVas SanjayVas requested a review from renjiezh October 11, 2024 00:23
@wfa-reviewable
Copy link

This change is Reviewable

Copy link
Contributor

@renjiezh renjiezh left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @SanjayVas)


src/main/resources/kingdom/spanner/shard-measurements-by-continuation-token.sql line 36 at r1 (raw file):

);

RUN BATCH;

nit: empty line

Copy link
Member

@kungfucraig kungfucraig left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @SanjayVas)


src/main/resources/kingdom/spanner/shard-measurements-by-continuation-token.sql line 27 at r1 (raw file):

) STORED;

DROP INDEX MeasurementsByContinuationToken;

This is not going to roll out well.

Copy link
Member Author

@SanjayVas SanjayVas left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 3 files reviewed, 1 unresolved discussion (waiting on @kungfucraig and @renjiezh)


src/main/resources/kingdom/spanner/shard-measurements-by-continuation-token.sql line 27 at r1 (raw file):

Previously, kungfucraig (Craig Wright) wrote…

This is not going to roll out well.

True, there will be a period of time where there is no index. I thought this was acceptable in the current state of the application.

  1. We need the original index to be dropped to avoid the write hotspotting
  2. There's no way to rename an index, only drop and recreate. To get zero downtime without an index and get the original index name, it would mean two backfills.

@SanjayVas SanjayVas force-pushed the sanjayvas-shard-index branch from 5bfb5b1 to 31b8d1e Compare October 11, 2024 19:03
Copy link
Member

@kungfucraig kungfucraig left a comment

Choose a reason for hiding this comment

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

Reviewable status: 2 of 3 files reviewed, all discussions resolved (waiting on @renjiezh)


src/main/resources/kingdom/spanner/shard-measurements-by-continuation-token.sql line 27 at r1 (raw file):

Previously, SanjayVas (Sanjay Vasandani) wrote…

True, there will be a period of time where there is no index. I thought this was acceptable in the current state of the application.

  1. We need the original index to be dropped to avoid the write hotspotting
  2. There's no way to rename an index, only drop and recreate. To get zero downtime without an index and get the original index name, it would mean two backfills.

In a perfect world this change would be rolled out across three pushes, but that's not the world we live in.

So let's just flag this in the release notes.

Copy link
Collaborator

@stevenwarejones stevenwarejones left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @renjiezh)

From the [Cloud Spanner documentation on secondary indexes](https://cloud.google.com/spanner/docs/secondary-indexes):

> Be aware that using the commit timestamp column as the first part of the secondary index can create hotspots and reduce write performance.

Sharding is one of the recommendations given for how to avoid hotspotting.
@SanjayVas SanjayVas force-pushed the sanjayvas-shard-index branch from d940464 to 26384e8 Compare October 15, 2024 18:11
@SanjayVas SanjayVas merged commit f578d3b into main Oct 15, 2024
4 checks passed
@SanjayVas SanjayVas deleted the sanjayvas-shard-index branch October 15, 2024 18:49
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.

5 participants