Skip to content

feat: automatically set a default_sequence_kind on DDL failure#824

Open
olavloite wants to merge 5 commits into
mainfrom
feat/716-auto-default-sequence-kind
Open

feat: automatically set a default_sequence_kind on DDL failure#824
olavloite wants to merge 5 commits into
mainfrom
feat/716-auto-default-sequence-kind

Conversation

@olavloite

@olavloite olavloite commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Introduces default_sequence_kind connection property. When DDL execution fails due to a missing sequence kind (detected via regex parsing of the Spanner error message), the driver automatically runs ALTER DATABASE to configure default_sequence_kind, and retries the remaining DDL statements.

Fixes #716

@olavloite olavloite requested a review from a team as a code owner June 11, 2026 12:59

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces automatic handling for DDL statement failures caused by a missing default sequence kind. When such an error is encountered and a 'default_sequence_kind' connection property is configured, the driver automatically executes an 'ALTER DATABASE' statement to set the default sequence kind and retries the remaining DDL statements. The changes also include corresponding unit tests and updates to the in-memory test server. The review feedback suggests simplifying the regular expression used to detect the missing sequence kind error by removing a redundant '.*' prefix.

Comment thread conn.go Outdated
@olavloite

Copy link
Copy Markdown
Collaborator Author

Nice feature. When DDL execution fails due to a missing sequence kind, the driver automatically runs ALTER DATABASE to set the default sequence kind and retries the remaining statements.

However, there is a bug in the error/metadata handling:
If a DDL batch of size > 1 fails, the default sequence kind is set, and the driver retries. If the retry succeeds for some statements and then fails again, the returned BatchError computes successful statement counts only from the first execution (op.Metadata()), completely ignoring the statements that succeeded during the retry. We should combine the counts or track the retry operation's metadata to report accurate progress.

@olavloite olavloite force-pushed the feat/716-auto-default-sequence-kind branch from 1dcccfe to ec646da Compare June 12, 2026 14:37
@olavloite

Copy link
Copy Markdown
Collaborator Author

Nice feature. When DDL execution fails due to a missing sequence kind, the driver automatically runs ALTER DATABASE to set the default sequence kind and retries the remaining statements.

However, there is a bug in the error/metadata handling: If a DDL batch of size > 1 fails, the default sequence kind is set, and the driver retries. If the retry succeeds for some statements and then fails again, the returned BatchError computes successful statement counts only from the first execution (op.Metadata()), completely ignoring the statements that succeeded during the retry. We should combine the counts or track the retry operation's metadata to report accurate progress.

Done

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.

Automatically set a default_sequence_kind

1 participant