Skip to content

Implementing Bucket index sync status file #5446

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

Merged
merged 4 commits into from
Jul 11, 2023

Conversation

alanprot
Copy link
Member

@alanprot alanprot commented Jul 7, 2023

What this PR does:

This PR introduce a new file to be saved together with the bucket index with the status of the last sync (bucket index update).

The bucket sync status is used on ingesters/queriers/storegateways/compactors to halt any operation for a given tenant if the bucket index could not be updated due CMK errors.

Which issue(s) this PR fixes:
Fixes #

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

@alanprot alanprot force-pushed the bucket-index-sync-status branch 2 times, most recently from d8b1794 to a4334c5 Compare July 7, 2023 22:43
@pull-request-size pull-request-size bot added size/XL and removed size/L labels Jul 7, 2023
Signed-off-by: Alan Protasio <alanprot@gmail.com>
@alanprot alanprot force-pushed the bucket-index-sync-status branch from a4334c5 to 8490085 Compare July 7, 2023 23:17
alanprot added 3 commits July 7, 2023 16:58
Signed-off-by: Alan Protasio <alanprot@gmail.com>
Signed-off-by: Alan Protasio <alanprot@gmail.com>
Signed-off-by: Alan Protasio <alanprot@gmail.com>
@alanprot alanprot marked this pull request as ready for review July 8, 2023 00:08
@alanprot alanprot requested review from alvinlin123 and yeya24 July 11, 2023 21:02
idxs.Status = bucketindex.CustomerManagedKeyError
// Making the tenant non queryable until 3x the cleanup interval to give time to compactors and storegateways
// to reload the bucket index in case the key access is re-granted
idxs.NonQueryableUntil = time.Now().Add(3 * c.cfg.CleanupInterval).Unix()
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: can we extract the magic number 3 to some meaningfully name constant?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

if idxs, err := bucketindex.ReadSyncStatus(ctx, i.TSDBState.bucket, userID, logutil.WithContext(ctx, i.logger)); err == nil {
// Skip blocks shipping if the bucket index failed to sync due to CMK errors.
if idxs.Status == bucketindex.CustomerManagedKeyError {
level.Info(logutil.WithContext(ctx, i.logger)).Log("msg", "skipping shipping blocks due CustomerManagedKeyError", "user", userID)
Copy link
Contributor

@alvinlin123 alvinlin123 Jul 11, 2023

Choose a reason for hiding this comment

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

Should this be a warn rather than info?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@alvinlin123
Copy link
Contributor

looks good to me, thanks!

@alvinlin123 alvinlin123 merged commit 2c37922 into cortexproject:master Jul 11, 2023
qinxx108 pushed a commit to qinxx108/cortex that referenced this pull request Jul 13, 2023
* Implementing Bucket index sync status

Signed-off-by: Alan Protasio <alanprot@gmail.com>

* fixing bug when returning from cache

Signed-off-by: Alan Protasio <alanprot@gmail.com>

* Addressing some comments

Signed-off-by: Alan Protasio <alanprot@gmail.com>

* Changelog

Signed-off-by: Alan Protasio <alanprot@gmail.com>

---------

Signed-off-by: Alan Protasio <alanprot@gmail.com>
Signed-off-by: Yijie Qin <qinyijie@amazon.com>
alvinlin123 pushed a commit that referenced this pull request Jul 13, 2023
* Implementing Bucket index sync status file (#5446)

* Implementing Bucket index sync status

Signed-off-by: Alan Protasio <alanprot@gmail.com>

* fixing bug when returning from cache

Signed-off-by: Alan Protasio <alanprot@gmail.com>

* Addressing some comments

Signed-off-by: Alan Protasio <alanprot@gmail.com>

* Changelog

Signed-off-by: Alan Protasio <alanprot@gmail.com>

---------

Signed-off-by: Alan Protasio <alanprot@gmail.com>
Signed-off-by: Yijie Qin <qinyijie@amazon.com>

* Implementing multi level index cache (#5451)

Signed-off-by: Yijie Qin <qinyijie@amazon.com>

* remove the user from am state replication key

Signed-off-by: Yijie Qin <qinyijie@amazon.com>

* expose the key label

Signed-off-by: Yijie Qin <qinyijie@amazon.com>

* add Changelog

Signed-off-by: Yijie Qin <qinyijie@amazon.com>

* fix comments

Signed-off-by: Yijie Qin <qinyijie@amazon.com>

* change to use type

Signed-off-by: Yijie Qin <qinyijie@amazon.com>

* address comment

Signed-off-by: Yijie Qin <qinyijie@amazon.com>

* fix comment

Signed-off-by: Yijie Qin <qinyijie@amazon.com>

* use type instead of key

Signed-off-by: Yijie Qin <qinyijie@amazon.com>

---------

Signed-off-by: Alan Protasio <alanprot@gmail.com>
Signed-off-by: Yijie Qin <qinyijie@amazon.com>
Co-authored-by: Alan Protasio <approtas@amazon.com>
@alanprot alanprot deleted the bucket-index-sync-status branch August 16, 2023 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants