ory / ory/x

Improve Retry Logic in sqlcon for CockroachDB Transient Errors (SQLSTATE Classes 08 & 57)

Open
#860 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feat
Dominant language
Go
Stars
111
Forks
116
PR merge metrics
No merged PRs in 30d

Description

Preflight checklist
Ory Network Project

No response

Describe your problem

Hi Ory team,

Following up on our recent joint discussions and ongoing integration between Ory and CockroachDB, we've observed transient SQL errors during load and topology changes (e.g., rolling upgrades, node restarts). These are typically in SQLSTATE classes 08 (connection exceptions) and 57 (operator intervention), and while infrequent, they can cause request retries to fail if not handled appropriately in application code.

This pattern aligns with the intent of sqlcon.IsError and may serve as a clean enhancement to that function to cover these additional SQLSTATE classes.

Describe your ideal solution

I recommend operation-level retries for transient failures, and we’ve implemented a working example of this pattern in Go:
👉 cockroach-go-with-retry

Workarounds or alternatives
  • Extend sqlcon.IsError or create a dedicated helper to catch and classify retry-able CockroachDB-specific SQL errors (notably from SQLSTATE 08xxx and 57P01).

  • Ensure this utility is integrated where SQL errors are surfaced, particularly in services that rely on Ory's SQL abstraction for persistence.

Version

v0.0.675

Additional Context

No response

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in sqlcon/error.go at sqlcon.IsError and compare its current classification with the linked CockroachDB retry example. Trace where SQL errors are surfaced in services using the SQL abstraction, then verify that SQLSTATE classes 08 and 57, including 57P01, are classified consistently for retry handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.