Skip to content

mgr/smb: fix sqlite3.InternalError crash on lost RADOS lock - #71094

Merged
NitzanMordhai merged 3 commits into
ceph:mainfrom
NitzanMordhai:wip-nitzan-sqlite3-crash-lock
Aug 25, 2026
Merged

NitzanMordhai merged 3 commits into
ceph:mainfrom
NitzanMordhai:wip-nitzan-sqlite3-crash-lock

Conversation

@NitzanMordhai

@NitzanMordhai NitzanMordhai commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

FileSize() returned SQLITE_NOTFOUND instead of SQLITE_IOERR_FSTAT on a failed stat(), which Python's sqlite3 module can't map and surfaces as an unhandled sqlite3.InternalError, crashing the calling mgr module. Also harden db_ready() to catch sqlite3.DatabaseError, and add a probability-based fault injector plus thrash-suite coverage for it.

Fixes: https://tracker.ceph.com/issues/79526

Assisted-by: IBM-Bob:ClaudeSonnet

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@github-actions

Copy link
Copy Markdown

Config Diff Tool Output

+ added: cephsqlite_inject_stat_error_probability (global.yaml.in)

The above configuration changes are found in the PR. Please update the relevant release documentation if necessary.
Ignore this comment if docs are already updated. To make the "Check ceph config changes" CI check pass, please comment /config check ok and re-run the test.

@NitzanMordhai
NitzanMordhai force-pushed the wip-nitzan-sqlite3-crash-lock branch from 261f44a to d3e89d4 Compare August 17, 2026 09:45

@batrick batrick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please break these into separate commits by component.

Comment thread src/SimpleRADOSStriper.cc Outdated
if (blocklisted.load()) {
auto p = ((CephContext*)ioctx.cct())->_conf.get_val<double>(
"cephsqlite_inject_stat_error_probability");
if (blocklisted.load() || rand() % 10000 < p * 10000.0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This rand is heavy. Only do it if cephsqlite_inject_stat_error_probability is non-zero.

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.

Done

@NitzanMordhai
NitzanMordhai force-pushed the wip-nitzan-sqlite3-crash-lock branch 2 times, most recently from d3e89d4 to a734b23 Compare August 18, 2026 12:06
@NitzanMordhai

Copy link
Copy Markdown
Contributor Author

Please break these into separate commits by component.

Done. Thanks for the review!

@NitzanMordhai
NitzanMordhai requested a review from batrick August 18, 2026 12:07

@batrick batrick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

otherwise LGTM

Comment thread src/common/options/global.yaml.in Outdated
desc: Probability that SimpleRADOSStriper::stat() fails with a fake I/O error,
for testing
default: 0
with_legacy: true

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

with_legacy is discouraged for new configs

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

load the config in makestriper

Comment thread src/SimpleRADOSStriper.cc Outdated
if (p && rand() % 10000 < p * 10000.0) {
d(5) << "stat failed due to injected error" << dendl;
return -EIO;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this actually does not need to be done here, you can move the injection to libcephsqlite

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.

Done, moved it into libcephsqlite, but now we have to call get config each time. i don't think it's too bad, we are doing it for most of the configs.

@NitzanMordhai
NitzanMordhai force-pushed the wip-nitzan-sqlite3-crash-lock branch from a734b23 to c109efa Compare August 18, 2026 15:03
@NitzanMordhai
NitzanMordhai requested a review from batrick August 18, 2026 15:05

@batrick batrick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

one last thing...

Comment thread src/libcephsqlite.cc Resolved
Comment thread src/libcephsqlite.cc Resolved
Comment thread src/libcephsqlite.cc Resolved
…) failure

FileSize() returned SQLITE_NOTFOUND instead of SQLITE_IOERR_FSTAT on a
failed stat(), which Python's sqlite3 module can't map and surfaces as
an unhandled sqlite3.InternalError, crashing the calling mgr module.
Access() had the same gap, silently reporting an existing file as
missing instead of returning an I/O error.

Add cephsqlite_inject_stat_error_probability plus a regression test
that exercises this deterministically.

Fixes: https://tracker.ceph.com/issues/79526
Signed-off-by: Nitzan Mordechai <[email protected]>
Assisted-by: IBM-Bob:ClaudeSonnet
db_ready() only caught MgrDBNotReady, so a raw sqlite3.DatabaseError
from the db property still crashed the calling module. set_kv()/get_kv()
had the same gap; give them the same @MgrModuleRecoverDB retry
protection devicehealth already uses for its own db access.

Fixes: https://tracker.ceph.com/issues/79526
Signed-off-by: Nitzan Mordechai <[email protected]>
Assisted-by: IBM-Bob:ClaudeSonnet
…hing

Wire the new fault injector into thrashosds-health.yaml at a low
probability so teuthology suites with osd thrasher also add to
ignorelist the expected log messages it can produce.

Fixes: https://tracker.ceph.com/issues/79526
Signed-off-by: Nitzan Mordechai <[email protected]>
@NitzanMordhai
NitzanMordhai force-pushed the wip-nitzan-sqlite3-crash-lock branch from c109efa to 4960356 Compare August 18, 2026 16:52
@NitzanMordhai
NitzanMordhai requested a review from batrick August 18, 2026 16:54
@batrick

batrick commented Aug 19, 2026

Copy link
Copy Markdown
Member

jenkins test make check arm64

@batrick

batrick commented Aug 19, 2026

Copy link
Copy Markdown
Member

/config check ok

@NitzanMordhai

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath7-testing-20260824.015917-main.

@NitzanMordhai

Copy link
Copy Markdown
Contributor Author

@NitzanMordhai

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@NitzanMordhai
NitzanMordhai merged commit 453c283 into ceph:main Aug 25, 2026
7 of 8 checks passed
@NitzanMordhai
NitzanMordhai deleted the wip-nitzan-sqlite3-crash-lock branch August 25, 2026 10:00
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.

3 participants