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

Assume fast tombstone is true and fix bug in VersionMapImpl::follow_version_chain #366

Merged
merged 6 commits into from
Jun 9, 2023

Conversation

vasil-pashov
Copy link
Collaborator

@vasil-pashov vasil-pashov commented May 11, 2023

Resolves: #174

Changes

  • Remove all branches involving fast tombstone property assuming it's always true.
  • Fix a bug in follow version chain functionality.

Bug description
Up to now the code assumes that there are no active versions after a tombstone_all key and stops following the version chain after encountering a tombstone_all key type. This is not true when we use prune_previous_versions. Imagine the following calls:

  1. Add version 0 for a symbol sym
  2. Add version 1 for the symbol sym
  3. Prune previous versions

This would result in the following version chain:

  1. (key_type: tombstone_all, version_id: 0)
  2. (key_type: version, version_id: 0)
  3. (key_type: index, version_id: 1)
  4. (key_type: version, version_id: 1)
  5. (key_type: index, version_id 0)

Where we have a live version (version 1) after the tombstone_all key.

The bug does not appear when using write + prune because in that case we first add the tombstone_all key and after that we write the new version.

Solution
In case there is tombstone_all key, in VersionMapImpl::follow_version_chain we need to keep track of the oldest index which was read and stop reading only if tombstone_all_->version_id() is greater or equal to the version_id of the oldest index.

@@ -879,9 +875,13 @@ class VersionMapImpl {
std::optional<AtomKey> first_key_to_tombstone = std::nullopt,
std::shared_ptr<VersionMapEntry> entry = nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am starting to wonder if the first_key_to_tombstone argument is safe before this change even @willdealtry

Calls using it basically assumes the version map has not changed without checking the timeout.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think in the case where we're writing version 5 with prune previous, we always want to tombstone from version 4 backwards, otherwise we might end up deleting the version we just wrote.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yes, that's what it was for.

Would you agree that, ideally, we should check_reload and then locate the version key in the VersionMapEntry again? (I.e. not accepting the entry argument.)

(Not that we should make that change in this PR

@vasil-pashov vasil-pashov marked this pull request as draft May 31, 2023 12:29
@vasil-pashov vasil-pashov force-pushed the refactor-fast-tombstone branch 3 times, most recently from 10876a7 to 34edd66 Compare June 7, 2023 16:45
@vasil-pashov vasil-pashov changed the title Assume fast tombstone is true. Assume fast tombstone is true and fix bug in VersionMapImpl::follow_version_chain Jun 8, 2023
@vasil-pashov vasil-pashov marked this pull request as ready for review June 8, 2023 07:53
@vasil-pashov vasil-pashov changed the title Assume fast tombstone is true and fix bug in VersionMapImpl::follow_version_chain Assume fast tombstone is true and fix bug in VersionMapImpl::follow_version_chain #174 Jun 8, 2023
@vasil-pashov vasil-pashov changed the title Assume fast tombstone is true and fix bug in VersionMapImpl::follow_version_chain #174 Assume fast tombstone is true and fix bug in VersionMapImpl::follow_version_chain Jun 8, 2023
Vasil Pashov added 4 commits June 8, 2023 11:45
Remove all branches involving fast tombstone property assuming it's
always true.
…isting symbol with no active versions. Now it throws only if the symbol does not exist.
the first tombstone_all key is reached. We may have tombstone_all key
which deletes versions way down on the chain. Instead we should stop
when the current key version is <= tombstone_all version.
@@ -879,9 +875,13 @@ class VersionMapImpl {
std::optional<AtomKey> first_key_to_tombstone = std::nullopt,
std::shared_ptr<VersionMapEntry> entry = nullptr) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think in the case where we're writing version 5 with prune previous, we always want to tombstone from version 4 backwards, otherwise we might end up deleting the version we just wrote.

cpp/arcticdb/version/version_utils.hpp Outdated Show resolved Hide resolved
cpp/arcticdb/version/version_map.hpp Show resolved Hide resolved
@@ -879,9 +875,13 @@ class VersionMapImpl {
std::optional<AtomKey> first_key_to_tombstone = std::nullopt,
std::shared_ptr<VersionMapEntry> entry = nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, yes, that's what it was for.

Would you agree that, ideally, we should check_reload and then locate the version key in the VersionMapEntry again? (I.e. not accepting the entry argument.)

(Not that we should make that change in this PR

cpp/arcticdb/version/version_utils.hpp Show resolved Hide resolved
cpp/arcticdb/version/version_utils.hpp Outdated Show resolved Hide resolved
* Improve debug logging
* Remove unit test
@mehertz mehertz linked an issue Jun 9, 2023 that may be closed by this pull request
@vasil-pashov vasil-pashov dismissed willdealtry’s stale review June 9, 2023 09:05

William gave verbal approval at the daily.

@vasil-pashov vasil-pashov merged commit d454f0e into master Jun 9, 2023
@vasil-pashov vasil-pashov deleted the refactor-fast-tombstone branch June 9, 2023 12:41
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.

Assume fast_tombstone_all is set when deleting data
3 participants