Skip to content

If transaction rollback throws, it obscures the true cause #1203

@tylerbrandt

Description

@tylerbrandt

Issues are used to track bugs and feature requests.
Need help or have a general question? Ask on Stack Overflow (tag sqlite.swift).

Build Information

  • Include the SQLite.swift version, commit or branch experiencing the issue.

0.14.1

  • Mention Xcode and OS X versions affected.

Xcode 14.2 / macOS 13.1

  • How do do you integrate SQLite.swift in your project?
    • manual
    • CocoaPods
    • Carthage
    • Swift Package manager

Swift Package manager (actually a fork based on 0.14.1, but it is present in latest code as well)

General guidelines

  • Be as descriptive as possible.
  • Provide as much information needed to reliably reproduce the issue.
  • Attach screenshots if possible.
  • Better yet: attach GIFs or link to video.
  • Even better: link to a sample project exhibiting the issue.

We recently ran into an issue where a small fraction of our users were logging an error "cannot rollback - no transaction is active (code: 1)" for a particular transaction, but we couldn't figure out why until we got access to one of the problematic DBs and could run it in debug mode with breakpoints. The line throwing (confirmed via breakpoint) was:

try self.run(rollback)

It turned out that the issue was that the "database disk image is malformed" (not sure how this happened), an error which only surfaced on attempting to commit the transaction (at least in our case). However, since it was causing try self.run(rollback) itself to throw, SQLite.swift was throwing out the "cannot rollback" error, and it took us a long time to track down the root cause.

sqlite-swift-transaction-rollback

Ideally it would always report the caught error, even if the rollback fails, in a way that client code can read.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions