Skip to content

fix(spanner): harden sync system test instance scrubbing and teardown - #19259

Draft
ohmayr wants to merge 3 commits into
mainfrom
fix/spanner-sync-teardown-scrub
Draft

ohmayr wants to merge 3 commits into
mainfrom
fix/spanner-sync-teardown-scrub

Conversation

@ohmayr

@ohmayr ohmayr commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Context & Problem

Spanner sync system test teardown can leak instances or crash when shared_instance creation times out, when backups or drop-protected databases remain, when scrub_referencing_databases calls nonexistent db.delete(), or when parallel CI runs race on NotFound.

Summary of Changes

  • Fix scrub_referencing_databases() to call db.drop() instead of db.delete().
  • Disable database drop protection before scrubbing backups and handle NotFound on list_databases(), db.reload(), and list_backups().
  • Guard created label integer parsing in cleanup_old_instances() against ValueError.
  • Wrap shared_instance creation wait and yield in try/finally calling scrub_instance_ignore_not_found().

Why This Approach

Fixes concrete teardown bugs in the existing sync helpers and fixture without touching production client code or async test files.

Intentionally Out of Scope

  • Modifying production Spanner client code
  • Async system test cleanup and instance-creation test labeling (tracked in separate PRs)

Verification

nox -s lint mypy-3.14 unit-3.14 unit-3.10 cover and two independent Owl review passes

Spanner sync system test teardown can leak instances or crash when shared_instance creation times out, when backups or drop-protected databases remain, when scrub_referencing_databases calls nonexistent db.delete(), or when parallel CI runs race on NotFound.

@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 improves the robustness of the system test cleanup and setup processes. It updates database deletion to use drop(), handles potential NotFound exceptions when scrubbing instance backups, wraps the database drop protection disabling in a try-except block, and handles ValueError when parsing instance creation times. Additionally, it refactors the shared_instance fixture in conftest.py to ensure instances are properly scrubbed in a finally block. The review feedback suggests making the database cleanup in scrub_instance_ignore_not_found even more robust by catching all exceptions during reload and update operations, preventing a single failure from aborting the entire cleanup process and causing resource leaks.

This branch has not been deployed

No deployments
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.

1 participant