Skip to content

[Auto refresh iterator] Fix dbstress run - attempt 1 - #13408

Closed
mszeszko-meta wants to merge 4 commits into
meta:mainfrom
mszeszko-meta:fix_db_stress_for_iterator_auto_refresh_attempt_1
Closed

mszeszko-meta wants to merge 4 commits into
meta:mainfrom
mszeszko-meta:fix_db_stress_for_iterator_auto_refresh_attempt_1

Conversation

@mszeszko-meta

@mszeszko-meta mszeszko-meta commented Feb 19, 2025 •

Copy link
Copy Markdown
Contributor

This PR attempts to fix the dbstress failures post #13354. There are at least 2 high level categories of errors: 1) likely caused by wide-scope snapshot initialization (issue found by Peter), 2) lack of proper error propagation. Wrt 2), part of the problem is a real miss (we should condition auto refresh on status().ok() after calling to Next / Prev), but another part - failure in propagating dbstress-injected read error in file deletion is expected and should not be asserted on in dbstress.

Test plan

Confirmed there are no more errors after running sandcastle crashtest for each of the failing flavors:

https://www.internalfb.com/sandcastle/workflow/252201579138859344
https://www.internalfb.com/sandcastle/workflow/3233584532458171962
https://www.internalfb.com/sandcastle/workflow/1283525893806766134
https://www.internalfb.com/sandcastle/workflow/2796735368603351293
https://www.internalfb.com/sandcastle/workflow/3792030886252148966
https://www.internalfb.com/sandcastle/workflow/67553994428973733
https://www.internalfb.com/sandcastle/workflow/3886606478427208295
https://www.internalfb.com/sandcastle/workflow/1684346260642682928
https://www.internalfb.com/sandcastle/workflow/4197354852715406516
https://www.internalfb.com/sandcastle/workflow/535928355663233170
https://www.internalfb.com/sandcastle/workflow/3409224917925569737

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@mszeszko-meta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@hx235

hx235 commented Feb 19, 2025

Copy link
Copy Markdown
Contributor

@mszeszko-meta could you do oncall a favor by running some rehearsal (larger scale) stress test in CI? I will ping you with steps.

@hx235

hx235 commented Feb 19, 2025

Copy link
Copy Markdown
Contributor

After talking to author, it turns out he already ran that. Manual run here means rehearsal CI run! Very nice and proactive testing strategy @mszeszko-meta @pdillinger

@cbi42 cbi42 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm, thanks for the fix

Comment thread tools/db_crashtest.py Resolved
Comment on lines +1690 to +1691
if (!ignore_injected_read_error_in_iter &&
!SharedState::ignore_read_error && injected_error_count > 0 &&

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it possible to use the hack of IGNORE_STATUS_IF_ERROR() and SharedState::ignore_read_error to narrow the scope of ignoring injected read here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mszeszko-meta mszeszko-meta Feb 20, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fair point, @hx235. When I looked at it first time, I was a bit skeptical since it would require finding all the places where such injected read error failure can occur downstream of DoRefresh. That being said, upon reviewing all 14 cases of DoRefresh error injections [1] from T214812411, it appears that this option might be feasible as we de-facto (probably) only have to patch DBImpl::DeleteObsoleteFileImpl and WalManager::PurgeObsoleteWALFiles. The only risk here is whack-a-mole game with popping up errors (potentially across several followup PRs) + getting some more noise (breaking places that potentially already deal with this subtlety in their 'own way'). The reward would be defining more explicit contract for where failure is expected, which perhaps would help us catch other regressions. In addition, patching those call sites would not only benefit the iterator auto refresh scenario, but rather all the cases where obsolete files are being cleaned up improving the overall dbstress health. I think it's worth giving it a shot in a separate, followup PR once we stabilize the iterator auto refresh with the current, explicit check. What do you think?

[1]

DeleteObsoleteFileImpl => DeleteDBFile (5)
PurgeObsoleteWALFiles => DeleteDBFile (1)
PurgeObsoleteWALFiles => GetFileModificationTime (7)
PurgeObsoleteWALFiles => GetFileSize (1)

@hx235 hx235 Feb 20, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for looking into this. The plan is good with me!

getting some more noise (breaking places that potentially already deal with this subtlety in their 'own way').

This makes me re-think about whether IGNORE_STATUS_IF_ERROR() is still a useful practice ... opened a task for myself

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

getting some more noise (breaking places that potentially already deal with this subtlety in their 'own way').

Right now for stress test, ignore_read_error is a thread-local. So adding IGNORE_STATUS_IF_ERROR() should only impact the test thread calling it. Given we also do SharedState::ignore_read_error = false at the beginning of the function, so I believe the impact will even be constrained to the function scope.

The design in our code that leads to using IGNORE_STATUS_IF_ERROR() or other error ignore flag is the error status is not propagated properly to upper level e.g, XXXIter::, destructor... Some ignoring is for the good purpose.

I still see the value of using IGNORE_STATUS_IF_ERROR() just so we don't have two error ignore mechanism in stress test, which we don't right now.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think IGNORE_STATUS_IF_ERROR() (combined with good discipline of resetting ignore_read_error at the beginning of the function / next loop iteration) is definitely a useful practice . It allows us to assert on failures 'in general' unless we explicitly request those to be marked as ignored in the code. Here is the timeline I have in mind:

  1. Let current change bake for 2-3 days, make sure dbstress stabilizes for auto refresh feature 50% on.
  2. Send out PR to wrap identified, non-returnable statuses with IGNORE_STATUS_IF_ERROR.
  3. Bake it for 2-3 days - make sure 2) did not regress any other tests.
  4. Remove the ignore_injected_read_error_in_iter altogether.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@mszeszko-meta has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@mszeszko-meta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@mszeszko-meta
mszeszko-meta marked this pull request as ready for review February 20, 2025 16:05
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@mszeszko-meta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@mszeszko-meta
mszeszko-meta force-pushed the fix_db_stress_for_iterator_auto_refresh_attempt_1 branch from dfe4dd0 to 9faffcb Compare February 20, 2025 16:08
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@mszeszko-meta has updated the pull request. You must reimport the pull request before landing.

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@mszeszko-meta has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@mszeszko-meta
mszeszko-meta requested a review from hx235 February 20, 2025 16:09

@hx235 hx235 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm too

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@mszeszko-meta merged this pull request in 1e1c199.

DBIter::Direction direction) {
if (cfh_ != nullptr && read_options_.snapshot != nullptr && allow_refresh_ &&
read_options_.auto_refresh_iterator_with_snapshot) {
read_options_.auto_refresh_iterator_with_snapshot && status().ok()) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this could have performance implications. status() is a pretty complex call. Even with the best compiler optimizations I believe there's at least one virtual call from IteratorWrapperBase to whatever is implementing InternalIteratorBase::status(). Thus, it's probably cheaper to check the SV number first.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great catch! #13415.

facebook-github-bot pushed a commit that referenced this pull request Feb 21, 2025
Summary:
This change is addressing a valid concern raised in #13408 (comment).

Pull Request resolved: #13415

Test Plan: Existing test collateral.

Reviewed By: cbi42

Differential Revision: D69999071

Pulled By: mszeszko-meta

fbshipit-source-id: 5ebb195b2b83701e06c33bfcb19c57d9ac1c1dc6
facebook-github-bot pushed a commit that referenced this pull request Mar 12, 2025
Summary:
[Experiment]

This PR is a followup to #13408. Thick bandaid of ignoring all injected read errors in context of periodic iterator auto refreshes in db stress proved to be effective. We confirmed our theory that errors are not a really a consequence / defect related to this new feature but rather due to subtle ways in which downstream code paths handle their respective IO failures. In this change we're replacing a thick 'ignore all IO read errors' bandaid in `no_batched_ops_stress` with a much smaller, targeted patches in obsolete files purge / delete codepaths, table block cache reader, table cache lookup to make sure we don't miss signal and ensure there's a single mechanism for ignoring error injection in db stress tests.

Pull Request resolved: #13447

Reviewed By: hx235

Differential Revision: D70794787

Pulled By: mszeszko-meta

fbshipit-source-id: c5fcd4780d82357c407f53bf0bb22fc38f7bd277
ybtsdst pushed a commit to ybtsdst/rocksdb that referenced this pull request Apr 27, 2025
Summary:
This PR attempts to fix the **dbstress failures** post meta#13354. There are at least 2 high level categories of errors: 1) likely caused by wide-scope snapshot initialization ([issue found by Peter](meta#13354 (comment))), 2) lack of proper error propagation. Wrt 2), part of the problem is a real miss (we should condition auto refresh on `status().ok()` after calling to `Next` / `Prev`), but another part - [failure in propagating dbstress-injected read error](meta#13354 (comment)) in file deletion is expected and should not be asserted on in dbstress.

Pull Request resolved: meta#13408

Test Plan:
Confirmed there are no more errors after running sandcastle crashtest for each of the failing flavors:

```hcl
https://www.internalfb.com/sandcastle/workflow/252201579138859344
https://www.internalfb.com/sandcastle/workflow/3233584532458171962
https://www.internalfb.com/sandcastle/workflow/1283525893806766134
https://www.internalfb.com/sandcastle/workflow/2796735368603351293
https://www.internalfb.com/sandcastle/workflow/3792030886252148966
https://www.internalfb.com/sandcastle/workflow/67553994428973733
https://www.internalfb.com/sandcastle/workflow/3886606478427208295
https://www.internalfb.com/sandcastle/workflow/1684346260642682928
https://www.internalfb.com/sandcastle/workflow/4197354852715406516
https://www.internalfb.com/sandcastle/workflow/535928355663233170
https://www.internalfb.com/sandcastle/workflow/3409224917925569737
```

Reviewed By: cbi42

Differential Revision: D69869766

Pulled By: mszeszko-meta

fbshipit-source-id: 7a5b121218fb1dc0a37887d6fe2a5c07e2b894cf
ybtsdst pushed a commit to ybtsdst/rocksdb that referenced this pull request Apr 27, 2025
Summary:
This change is addressing a valid concern raised in meta#13408 (comment).

Pull Request resolved: meta#13415

Test Plan: Existing test collateral.

Reviewed By: cbi42

Differential Revision: D69999071

Pulled By: mszeszko-meta

fbshipit-source-id: 5ebb195b2b83701e06c33bfcb19c57d9ac1c1dc6
ybtsdst pushed a commit to ybtsdst/rocksdb that referenced this pull request Apr 27, 2025
Summary:
[Experiment]

This PR is a followup to meta#13408. Thick bandaid of ignoring all injected read errors in context of periodic iterator auto refreshes in db stress proved to be effective. We confirmed our theory that errors are not a really a consequence / defect related to this new feature but rather due to subtle ways in which downstream code paths handle their respective IO failures. In this change we're replacing a thick 'ignore all IO read errors' bandaid in `no_batched_ops_stress` with a much smaller, targeted patches in obsolete files purge / delete codepaths, table block cache reader, table cache lookup to make sure we don't miss signal and ensure there's a single mechanism for ignoring error injection in db stress tests.

Pull Request resolved: meta#13447

Reviewed By: hx235

Differential Revision: D70794787

Pulled By: mszeszko-meta

fbshipit-source-id: c5fcd4780d82357c407f53bf0bb22fc38f7bd277
SoujanyaPonnapalli pushed a commit to tyler-griggs/rocksdb that referenced this pull request Jul 20, 2025
Summary:
[Experiment]

This PR is a followup to meta#13408. Thick bandaid of ignoring all injected read errors in context of periodic iterator auto refreshes in db stress proved to be effective. We confirmed our theory that errors are not a really a consequence / defect related to this new feature but rather due to subtle ways in which downstream code paths handle their respective IO failures. In this change we're replacing a thick 'ignore all IO read errors' bandaid in `no_batched_ops_stress` with a much smaller, targeted patches in obsolete files purge / delete codepaths, table block cache reader, table cache lookup to make sure we don't miss signal and ensure there's a single mechanism for ignoring error injection in db stress tests.

Pull Request resolved: meta#13447

Reviewed By: hx235

Differential Revision: D70794787

Pulled By: mszeszko-meta

fbshipit-source-id: c5fcd4780d82357c407f53bf0bb22fc38f7bd277
Tim-Reed pushed a commit to Tim-Reed/rocksdb that referenced this pull request Oct 1, 2026
Summary:
This PR attempts to fix the **dbstress failures** post meta#13354. There are at least 2 high level categories of errors: 1) likely caused by wide-scope snapshot initialization ([issue found by Peter](meta#13354 (comment))), 2) lack of proper error propagation. Wrt 2), part of the problem is a real miss (we should condition auto refresh on `status().ok()` after calling to `Next` / `Prev`), but another part - [failure in propagating dbstress-injected read error](meta#13354 (comment)) in file deletion is expected and should not be asserted on in dbstress.

Pull Request resolved: meta#13408

Test Plan:
Confirmed there are no more errors after running sandcastle crashtest for each of the failing flavors:

```hcl
https://www.internalfb.com/sandcastle/workflow/252201579138859344
https://www.internalfb.com/sandcastle/workflow/3233584532458171962
https://www.internalfb.com/sandcastle/workflow/1283525893806766134
https://www.internalfb.com/sandcastle/workflow/2796735368603351293
https://www.internalfb.com/sandcastle/workflow/3792030886252148966
https://www.internalfb.com/sandcastle/workflow/67553994428973733
https://www.internalfb.com/sandcastle/workflow/3886606478427208295
https://www.internalfb.com/sandcastle/workflow/1684346260642682928
https://www.internalfb.com/sandcastle/workflow/4197354852715406516
https://www.internalfb.com/sandcastle/workflow/535928355663233170
https://www.internalfb.com/sandcastle/workflow/3409224917925569737
```

Reviewed By: cbi42

Differential Revision: D69869766

Pulled By: mszeszko-meta

fbshipit-source-id: 7a5b121218fb1dc0a37887d6fe2a5c07e2b894cf
Tim-Reed pushed a commit to Tim-Reed/rocksdb that referenced this pull request Oct 1, 2026
Summary:
This change is addressing a valid concern raised in meta#13408 (comment).

Pull Request resolved: meta#13415

Test Plan: Existing test collateral.

Reviewed By: cbi42

Differential Revision: D69999071

Pulled By: mszeszko-meta

fbshipit-source-id: 5ebb195b2b83701e06c33bfcb19c57d9ac1c1dc6
Tim-Reed pushed a commit to Tim-Reed/rocksdb that referenced this pull request Oct 1, 2026
Summary:
[Experiment]

This PR is a followup to meta#13408. Thick bandaid of ignoring all injected read errors in context of periodic iterator auto refreshes in db stress proved to be effective. We confirmed our theory that errors are not a really a consequence / defect related to this new feature but rather due to subtle ways in which downstream code paths handle their respective IO failures. In this change we're replacing a thick 'ignore all IO read errors' bandaid in `no_batched_ops_stress` with a much smaller, targeted patches in obsolete files purge / delete codepaths, table block cache reader, table cache lookup to make sure we don't miss signal and ensure there's a single mechanism for ignoring error injection in db stress tests.

Pull Request resolved: meta#13447

Reviewed By: hx235

Differential Revision: D70794787

Pulled By: mszeszko-meta

fbshipit-source-id: c5fcd4780d82357c407f53bf0bb22fc38f7bd277
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants