Skip to content

feat(sqlitetest): inject rollback failures - #90

Merged
SirLouen merged 4 commits into
gopherium:mainfrom
Doomguy-BFG9000:fix/sqlitetest-rollback
Oct 18, 2026
Merged

SirLouen merged 4 commits into
gopherium:mainfrom
Doomguy-BFG9000:fix/sqlitetest-rollback

Conversation

@Doomguy-BFG9000

@Doomguy-BFG9000 Doomguy-BFG9000 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add one-shot rollback fault injection to sqlitetest
  • always execute the underlying rollback so the transaction still ends
  • verify dbkit.InTx joins body and rollback errors

Fixes #88.

Verification

Summary by CodeRabbit

  • Testing
    • Expanded coverage for transaction rollback failures, including cases where both the transaction body and rollback return errors.
    • Added checks that simulated rollback failures are reported and failed transactions leave no inserted data behind.
  • Chores
    • Updated the database toolkit dependency to a newer version.

@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 20c100da-95fc-4115-951f-6b67a583c969
📥 Commits

Reviewing files that changed from the base of the PR and between 62c829f and 0600e62.

📒 Files selected for processing: 4
  • dbkit/sqlite/CHANGELOG.md
  • dbkit/sqlite/intx_test.go
  • dbkit/sqlite/sqlitetest/faults.go
  • dbkit/sqlite/sqlitetest/faults_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The SQLite test fault helper now supports one-shot rollback failures and joins the injected error with the driver rollback result. Tests cover rollback behavior, concurrent use, and dbkit.InTx error composition. The SQLite module now requires dbkit v0.3.0.

Changes: SQLite rollback fault injection

Layer / File(s) Summary
Add rollback fault injection
dbkit/sqlite/sqlitetest/faults.go, dbkit/sqlite/sqlitetest/faults_test.go, dbkit/sqlite/CHANGELOG.md
Faults stores and clears a pending rollback error. faultTx.Rollback joins that error with the driver result. Tests cover one-shot faults, commit interactions, and concurrent rollback and connection faults. The changelog documents the helper.
Verify InTx error composition
dbkit/sqlite/go.mod, dbkit/sqlite/intx_test.go
The module requires dbkit v0.3.0. A test verifies that dbkit.InTx returns an error matching both the body error and the rollback error, and that a later transaction succeeds.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Suggested reviewers: sirlouen

Merge Risk: ⚪ Minimal · up to 0600e

The SQLite rollback-fault feature is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 3 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: adding rollback failure injection to sqlitetest.
Linked Issues check Passed The changes satisfy the coding requirements in #88. Faults.FailNextRollback(err error) provides one-shot rollback injection. faultTx.Rollback consumes the injected error and still calls the underl…
Out of Scope Changes check Passed The changes remain within #88. The dbkit 0.3.0 dependency enables the required InTx test. Production code, tests, and changelog entries directly support rollback fault injection and its verification…
Full details: Linked Issues check

Explanation

The changes satisfy the coding requirements in #88. Faults.FailNextRollback(err error) provides one-shot rollback injection. faultTx.Rollback consumes the injected error and still calls the underlying rollback. Tests cover one-shot behavior, driver rollback errors, concurrent use, and transaction termination. The dbkit/sqlite test verifies that dbkit.InTx returns an error matching both the body error and the rollback error, leaves no rows, and permits a later transaction.

Full details: Out of Scope Changes check

Explanation

The changes remain within #88. The dbkit 0.3.0 dependency enables the required InTx test. Production code, tests, and changelog entries directly support rollback fault injection and its verification. No unrelated change is shown.

Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 3 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

codescene-access[bot]

This comment was marked as outdated.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable new defects were found.

Summary

Adds one-shot rollback failures to sqlitetest while still calling the real rollback.

  • SQLite tests can inject one rollback error without leaving transactions open.

No actionable new issues were found. Tests were not run during this review.

Reviews (2) · Last reviewed commit: "docs(dbkit/sqlite): note FailNextRollbac..." · Reviewed by Greptile

@codescene-access codescene-access Bot 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.

Gates Passed
4 Quality Gates Passed

See analysis details in CodeScene

Quality Gate Profile: Clean Code Collective
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@SirLouen
SirLouen merged commit 0c78c12 into gopherium:main Oct 18, 2026
37 checks passed
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.

Let sqlitetest fail the next rollback

2 participants