Skip to content

mgr/smb: gracefully handle transient sqlitedb errors - #69702

Merged
phlogistonjohn merged 1 commit into
ceph:mainfrom
avanthakkar:fix-smb-sqlite-error-handling
Jul 10, 2026
Merged

phlogistonjohn merged 1 commit into
ceph:mainfrom
avanthakkar:fix-smb-sqlite-error-handling

Conversation

@avanthakkar

@avanthakkar avanthakkar commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

This PR intends to handle sqlite db error during PG transient state or when db is unavailable or can't be locked in by translating sqlite3.DatabaseError into a generic StoreUnavailable in sqlite_store.py and handle it in cli.py and module.py instead of letting it surface as an unhandled exception.

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

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.

Comment thread src/pybind/mgr/smb/module.py Resolved
@avanthakkar
avanthakkar force-pushed the fix-smb-sqlite-error-handling branch from a3f861e to ee25d62 Compare June 26, 2026 09:02
@avanthakkar
avanthakkar marked this pull request as ready for review June 26, 2026 09:03
@avanthakkar
avanthakkar requested review from a team as code owners June 26, 2026 09:03
@avanthakkar avanthakkar changed the title mgr/smb: retry and gracefully handle transient sqlitedb errors mgr/smb: gracefully handle transient sqlitedb errors Jun 26, 2026
@avanthakkar

Copy link
Copy Markdown
Contributor Author

jenkins windows test

@avanthakkar

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@rapanigrahi

rapanigrahi commented Jul 7, 2026 •

Copy link
Copy Markdown

i think we have handled this issue in all_resources() and _apply_res() and i also think that we need to handle this exception _find_in_store() code path.(WDYT).

i agree with John's comment as well that it will be batter to handle exception in db layer instead upper layer.

@avanthakkar

Copy link
Copy Markdown
Contributor Author

i think we have handled this issue in all_resources() and _apply_res() and i also think that we need to handle this exception _find_in_store() code path.(WDYT).

i agree with John's comment as well that it will be batter to handle exception in db layer instead upper layer.

It's already addressed please check latest version of PR

@rapanigrahi

Copy link
Copy Markdown

@avanthakkar Thanks for clarifying me.

@rapanigrahi rapanigrahi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

@avanthakkar

Copy link
Copy Markdown
Contributor Author

i think we have handled this issue in all_resources() and _apply_res() and i also think that we need to handle this exception _find_in_store() code path.(WDYT).

i agree with John's comment as well that it will be batter to handle exception in db layer instead upper layer.

Well every database operation in SqliteStore  like  find_entries, contents, etc.. goes through the _db() context manager which already catches sqlite3.DatabaseError (parent class of sqlite3.InternalError) and converts it to StoreUnavailable. So the path you're describing  _check_share_resource → _share_name_in_use → find_in_store → _find_in_store  cannot leak a raw sqlite3 exception. It's already wrapped before it exits the store layer. StoreUnavailable is then caught at all the top-level handlers in cli.py and module.py. There's no uncovered path here.

@phlogistonjohn

Copy link
Copy Markdown
Contributor

Teuthology Run: https://pulpito-ng.ceph.com/runs/phlogistonjohn-2026-07-09_21:50:32-orch-wip-phlogistonjohn-testing-1-2026-07-09-1415-distro-default-trial
(6) failures out of 64 tests.
4 well-known flakes for ctdb_status
1 failure to connect to AD
1 failure to connect to share

Teuthology Re-run: https://pulpito-ng.ceph.com/runs/phlogistonjohn-2026-07-09_23:10:58-orch-wip-phlogistonjohn-testing-1-2026-07-09-1415-distro-default-trial
3 failures out of 6 re-run tests.
All repeat failures were the well-known flakes for ctdb_status

@phlogistonjohn

Copy link
Copy Markdown
Contributor

@avanthakkar please check if this needs to be backported, and if so, please create a tracker. Otherwise please disregard and let me know if you're ready to merge.

Translate sqlite3.DatabaseError into a generic StoreUnavailable in
sqlite_store.py and handle it in cli.py and module.py instead of
letting it surface as an unhandled exception

Fixes: https://tracker.ceph.com/issues/78125
Signed-off-by: Avan Thakkar <[email protected]>
@avanthakkar
avanthakkar force-pushed the fix-smb-sqlite-error-handling branch from ee25d62 to 4ae80fb Compare July 10, 2026 06:00
@avanthakkar

Copy link
Copy Markdown
Contributor Author

@avanthakkar please check if this needs to be backported, and if so, please create a tracker. Otherwise please disregard and let me know if you're ready to merge.

I've created tracker with backports mentioned and also updated commit message with tracker link so doesn't require rerun of teuthology

@phlogistonjohn
phlogistonjohn merged commit 980b012 into ceph:main Jul 10, 2026
17 of 21 checks passed
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