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(server): mget crash on same key get #2474

Merged
merged 6 commits into from
Jan 28, 2024
Merged

fix(server): mget crash on same key get #2474

merged 6 commits into from
Jan 28, 2024

Conversation

adiholden
Copy link
Collaborator

@adiholden adiholden commented Jan 25, 2024

fix: #2465
the bug: on cache mode mget bumps up items. When executing mget with the same key several times i.e mget key key we will invalidate the iterator when we bump up the item in dash table.
the fix: bump up/down items only once by using bumped_items set
This PR also reverts c225113
and updates the bumped stats and bumped_items set if the item was bumped

Signed-off-by: adi_holden <adi@dragonflydb.io>
Signed-off-by: adi_holden <adi@dragonflydb.io>
@adiholden adiholden requested review from romange and kostasrim and removed request for romange January 25, 2024 11:04
kostasrim
kostasrim previously approved these changes Jan 25, 2024
@@ -279,6 +279,39 @@ TEST_F(StringFamilyTest, MGetCachingModeBug2276) {
EXPECT_GT(bumps2, bumps1);
}

TEST_F(StringFamilyTest, MGetCachingModeBug2465) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice! I was about to ask for a test and you pushed :)

romange
romange previously approved these changes Jan 25, 2024
@@ -121,7 +121,7 @@ class PrimeBumpPolicy {
: bumped_items_(bumped_items) {
}
// returns true if key can be made less important for eviction (opposite of bump up)
bool CanBumpDown(const CompactObj& obj) const {
bool CanBump(const CompactObj& obj) const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please update comment as well

@@ -494,18 +494,18 @@ class SetResultBuilder {

SinkReplyBuilder::MGetResponse OpMGet(bool fetch_mcflag, bool fetch_mcver, const Transaction* t,
EngineShard* shard) {
auto keys = t->GetShardArgs(shard->shard_id());
DCHECK(!keys.empty());
auto args = t->GetShardArgs(shard->shard_id());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please still keep the 'keys' name here?

Signed-off-by: adi_holden <adi@dragonflydb.io>
@adiholden adiholden dismissed stale reviews from romange and kostasrim via bcfab05 January 25, 2024 11:54
Signed-off-by: adi_holden <adi@dragonflydb.io>
Signed-off-by: adi_holden <adi@dragonflydb.io>
@adiholden adiholden requested a review from romange January 28, 2024 09:45
@adiholden adiholden merged commit 9f4c435 into main Jan 28, 2024
10 checks passed
@adiholden adiholden deleted the fix_2465 branch January 28, 2024 09:45
romange added a commit that referenced this pull request Nov 9, 2024
This pr #2474 introduced iterator protection by
tracking which keys where bumped up during the transaction operation.
This was done by managing keys view set. However, this can be simplified
using fingerprints. Also, fingerprints do not require that the original keys exist.

In addition, this #3241 PR introduces FetchedItemsRestorer that tracks bumped set and
saves it to protect against fiber context switch. My claim is that it's redundant.
Since we only keep the auto-laundering iterators, when a fiber preempts these iterators recognize it
(see IteratorT::LaunderIfNeeded) and refresh themselves anyway.

To summarize: fetched_items_ protect us from iterator invalidation during atomic scenarios,
and auto-laundering protects us from everything else, so fetched_items_ can be cleared in that case.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
romange added a commit that referenced this pull request Nov 13, 2024
This pr #2474 introduced iterator protection by
tracking which keys where bumped up during the transaction operation.
This was done by managing keys view set. However, this can be simplified
using fingerprints. Also, fingerprints do not require that the original keys exist.

In addition, this #3241 PR introduces FetchedItemsRestorer that tracks bumped set and
saves it to protect against fiber context switch. My claim is that it's redundant.
Since we only keep the auto-laundering iterators, when a fiber preempts these iterators recognize it
(see IteratorT::LaunderIfNeeded) and refresh themselves anyway.

To summarize: fetched_items_ protect us from iterator invalidation during atomic scenarios,
and auto-laundering protects us from everything else, so fetched_items_ can be cleared in that case.

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
romange added a commit that referenced this pull request Nov 13, 2024
* chore: simplify BumpUps deduplication

This pr #2474 introduced iterator protection by
tracking which keys where bumped up during the transaction operation.
This was done by managing keys view set. However, this can be simplified
using fingerprints. Also, fingerprints do not require that the original keys exist.

In addition, this #3241 PR introduces FetchedItemsRestorer that tracks bumped set and
saves it to protect against fiber context switch. My claim is that it's redundant.
Since we only keep the auto-laundering iterators, when a fiber preempts these iterators recognize it
(see IteratorT::LaunderIfNeeded) and refresh themselves anyway.

To summarize: fetched_items_ protect us from iterator invalidation during atomic scenarios,
and auto-laundering protects us from everything else, so fetched_items_ can be cleared in that case.
---------

Signed-off-by: Roman Gershman <roman@dragonflydb.io>
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.

Periodic crash on new version
3 participants