-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make SafeDelete faster for large blocks; TSDB block repair case (#1056)
* bucket verify: repair out of order labels * verify repair: correctly order series in the index on rewrite When we have label sets that are not in the correct order, fixing that changes the order of the series in the index. So the index must be rewritten in that new order. This makes this repair tool take up a bunch more memory, but produces blocks that verify correctly. * Fix the TSDB block safe-delete function The directory name must be the block ID name exactly to verify. A temp directory or random name will not work here. * verify repair: fix duplicate chunk detection Pointer/reference logic error was eliminating all chunks for a series in a given TSDB block that wasn't the first chunk. Chunks are now referenced correctly via pointers. * PR feedback: use errors.Errorf() instead of fmt.Errorf() * Allow safe-delete to use previously downloaded TSDB block If we have just downloaded a TSDB block for repair, we create a brand new block that is fixed. The original block can be used as the data we upload in SafeDelete() to save time/bandwidth rather than re-download it from the storage bucket. * Use errors.New() Some linters catch errors.Errorf() as its not really part of the errors package. * Repair duplicate series in a TSDB block Where duplicate series means two series with an identical label set. This code just drops any duplicate series that is encountered after the first. No merging or anything fancy. * Liberally comment this for loop We're comparing items by pointers, using Go's range variables is misleading here and we need not fall into the same trap. * Take advantage of sort.Interface This prevents us from having to re-implement label sorting. * PR Feedback: Comments are full sentences. * PR Feedback * PR Feedback: Handle other possible Stat() errors * PR Feedback: Add TODO for future metric of dropped series in block * PR feedback: Make SafeDelete() more explicit When we want to SafeDelete an already downloaded TSDB block, be very explicit about that use case. * PR Feedback: refactor SafeDelete Be extra explicit about using existing tempdirs. Added note about future improvements for verifying if we have an intact tsdb block. * Use lset.String() rather than fmt.Sprintf() * SafeDelete(): Make comments match function behavior The tempdir value is ignored if useExistingTempdir is false. * PR feedback: comments in pkg/verifier/safe_delete.go Co-Authored-By: Bartek Płotka <bwplotka@gmail.com> * PR feedback: comments in pkg/verifier/safe_delete.go Co-Authored-By: Bartek Płotka <bwplotka@gmail.com> * PR Feedback: comments in pkg/block/index.go * Update pkg/verifier/safe_delete.go Co-Authored-By: Bartek Płotka <bwplotka@gmail.com> * PR feedback: split SafeDelete() into multiple functions * PR Feedback: Log the upstream PR with this TODO * PR Feedback: clean up function signatures
- Loading branch information
Showing
4 changed files
with
101 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters