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

Allow to get the latest sequence number when creating the backup #1987

Merged
merged 4 commits into from
Jan 5, 2024

Conversation

git-hulk
Copy link
Member

@git-hulk git-hulk commented Jan 4, 2024

As mentioned in #1986, some users want to know the sequence number of the backup
for the increment backup scenario. Fortunately, rocksdb allows us to get the sequence
number when creating the checkpoint. So what we need to do is to pass the receiver.

@git-hulk git-hulk requested a review from PragmaTwice January 4, 2024 13:00
@git-hulk git-hulk requested a review from torwig January 4, 2024 13:00
tests/cppunit/storage_test.cc Outdated Show resolved Hide resolved
tests/cppunit/storage_test.cc Outdated Show resolved Hide resolved
src/storage/storage.h Show resolved Hide resolved
@git-hulk git-hulk requested a review from mapleFU January 4, 2024 13:22
@@ -363,7 +363,7 @@ Status Storage::CreateBackup() {
}

std::unique_ptr<rocksdb::Checkpoint> checkpoint_guard(checkpoint);
s = checkpoint->CreateCheckpoint(tmpdir, config_->rocks_db.write_buffer_size * MiB);
s = checkpoint->CreateCheckpoint(tmpdir, config_->rocks_db.write_buffer_size * MiB, sequence_number);
Copy link
Member

Choose a reason for hiding this comment

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

Just a question:

  // sequence_number_ptr: if it is not nullptr, the value it points to will be
  // set to a sequence number guaranteed to be part of the DB, not necessarily
  // the latest. The default value of this parameter is nullptr.

From rocksdb, seems this might a bit less than backup? Or I misunderstanding this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe, I didn't investigate when it would be less than the DB.

Copy link
Member

Choose a reason for hiding this comment

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

It was introduced here: facebook/rocksdb@3ffb3ba

Maybe we should notice user to pay-attention to that, replaying kv might not harm

Copy link
Member Author

Choose a reason for hiding this comment

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

@mapleFU I have updated the comment to address this, please take a look again.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have confirmed the implementation, it is the latest sequence number while starting to create the checkpoint, so it should be less the current backup DB if has any writes during this process.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I guess maybe it's not atomic between:

  *sequence_number = db_->GetLatestSequenceNumber();

  LiveFilesStorageInfoOptions opts;
  opts.include_checksum_info = get_live_table_checksum;
  opts.wal_size_for_flush = log_size_for_flush;

  std::vector<LiveFileStorageInfo> infos;
  {
    Status s = db_->GetLiveFilesStorageInfo(opts, &infos);

mapleFU
mapleFU previously approved these changes Jan 4, 2024
Copy link

sonarqubecloud bot commented Jan 4, 2024

Quality Gate Passed Quality Gate passed

Kudos, no new issues were introduced!

0 New issues
0 Security Hotspots
No data about Coverage
1.9% Duplication on New Code

See analysis details on SonarCloud

@git-hulk git-hulk changed the title Allow to get the latest sequence number when creating number Allow to get the latest sequence number when creating the backup Jan 5, 2024
@git-hulk git-hulk merged commit 230d972 into apache:unstable Jan 5, 2024
29 checks passed
git-hulk added a commit to git-hulk/kvrocks that referenced this pull request Jan 6, 2024
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.

3 participants