Skip to content

docs: Document transaction failure exceptions#572

Open
loopassembly wants to merge 2 commits into
serverpod:mainfrom
loopassembly:docs/transaction-failure-exceptions
Open

docs: Document transaction failure exceptions#572
loopassembly wants to merge 2 commits into
serverpod:mainfrom
loopassembly:docs/transaction-failure-exceptions

Conversation

@loopassembly

Copy link
Copy Markdown

Summary

  • Add guidance for exceptions thrown when transactions fail.
  • Document that database-rejected queries inside a transaction surface as DatabaseQueryException.
  • Show how to compare DatabaseQueryException.code with PgErrorCode.serializationFailure and PgErrorCode.deadlockDetected.
  • Fix the transactions isolation table markdown formatting and a PostgreSQL typo in the touched page.

Verification

  • npx --yes --cache ./.npm-cache markdownlint-cli docs/06-concepts/06-database/08-transactions.md
  • git diff --check

I did not run a docs build because serverpod_docs/AGENTS.md says not to run build commands locally.

Closes serverpod/serverpod#3920

Copilot AI review requested due to automatic review settings June 3, 2026 09:06

Copilot AI 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.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds guidance on handling exceptions thrown during transactions and clarifies how to detect/retry on common PostgreSQL concurrency errors, while also tightening up the transaction isolation table formatting/spelling.

Changes:

  • Documented how Serverpod rolls back/rethrows on transaction callback exceptions and how database rejections surface as DatabaseQueryException.
  • Added a Dart example for checking DatabaseQueryException.code against PgErrorCode (e.g., serialization failure, deadlock).
  • Updated the transaction isolation table header formatting and corrected “PostgresSQL” → “PostgreSQL”.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/06-concepts/06-database/08-transactions.md Outdated
Comment thread docs/06-concepts/06-database/08-transactions.md
@loopassembly

Copy link
Copy Markdown
Author

Thanks for the review notes. I pushed a small follow-up commit (69a1619) to keep the PostgreSQL error-code appendix link label on one line.

I also checked the table comment. The table is already using normal single-pipe Markdown syntax, and the latest title, markdown-lint, and Docusaurus test-build checks are all green now.

@Swiftaxe Swiftaxe left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you! Looks really good and accurate. Just added a couple of nit comments.


## Transaction failure exceptions

When the transaction callback throws an exception, Serverpod rolls back the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This line is a repetition of line 7, and can be omitted.

When the transaction callback throws an exception, Serverpod rolls back the
transaction and rethrows that exception.

When the database rejects a query inside the transaction, Serverpod throws a

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The lines hard-wrap at 72 characters. Unwrap to match the rest of the file. (e.g. remove the invisible break line character).

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.

Transaction failures throw which specific exceptions?

3 participants