Skip to content

fix(database): serialize Schema.Create in TestEntSchemaParity - #1214

Merged
kalbasit merged 1 commit into
mainfrom
fix-ent-schema-parity-race
May 23, 2026
Merged

kalbasit merged 1 commit into
mainfrom
fix-ent-schema-parity-race

Conversation

@kalbasit

Copy link
Copy Markdown
Owner

TestEntSchemaParity runs t.Parallel() alongside TestClient_Close and
TestWithTransaction_*, all of which call Ents Schema.Create against
the package-level migrate.Tables slice. Atlas mutates that slice
during setupTables/realm, so the unsynchronised parallel calls trip
go test -race.

Wrap m.Create with the same database.SchemaCreateMu mutex the other
parallel helpers (freshSchemaSQLite, etc.) already use. The two tests
now serialise their schema bootstrap and race-detector stops firing.

Co-Authored-By: Claude Opus 4.7 [email protected]

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working go Pull requests that update go code labels May 21, 2026
This was referenced May 21, 2026
@kalbasit

kalbasit commented May 21, 2026 •

Copy link
Copy Markdown
Owner Author

This change is part of the following stack:

Change managed by git-spice.

kalbasit added a commit that referenced this pull request May 22, 2026
Replace context.Background() with t.Context() so the schema-create call
is bound to the test lifetime. Drops the now-unused context import.

Addresses gemini-code-assist comment from PR #1214
(PRRT_kwDONV6tZs6D3PyX); the original test_schema_parity file was folded
into client_test.go but the same pattern lives in freshSchemaSQLite.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the fix-cache-tx-retry-on-duplicate-key branch from d7964f3 to 4d9dffe Compare May 22, 2026 21:42
@kalbasit
kalbasit force-pushed the fix-ent-schema-parity-race branch from 5eafc92 to 8c6e692 Compare May 22, 2026 21:42
kalbasit added a commit that referenced this pull request May 22, 2026
Replace context.Background() with t.Context() so the schema-create call
is bound to the test lifetime. Drops the now-unused context import.

Addresses gemini-code-assist comment from PR #1214
(PRRT_kwDONV6tZs6D3PyX); the original test_schema_parity file was folded
into client_test.go but the same pattern lives in freshSchemaSQLite.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the fix-cache-tx-retry-on-duplicate-key branch from 4d9dffe to b5e1526 Compare May 22, 2026 21:54
@kalbasit
kalbasit force-pushed the fix-ent-schema-parity-race branch from 8c6e692 to a9871de Compare May 22, 2026 21:54
kalbasit added a commit that referenced this pull request May 22, 2026
Replace context.Background() with t.Context() so the schema-create call
is bound to the test lifetime. Drops the now-unused context import.

Addresses gemini-code-assist comment from PR #1214
(PRRT_kwDONV6tZs6D3PyX); the original test_schema_parity file was folded
into client_test.go but the same pattern lives in freshSchemaSQLite.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the fix-cache-tx-retry-on-duplicate-key branch from b5e1526 to 4f6983d Compare May 22, 2026 23:02
@kalbasit
kalbasit force-pushed the fix-ent-schema-parity-race branch from a9871de to 66a7315 Compare May 22, 2026 23:02
kalbasit added a commit that referenced this pull request May 22, 2026
Replace context.Background() with t.Context() so the schema-create call
is bound to the test lifetime. Drops the now-unused context import.

Addresses gemini-code-assist comment from PR #1214
(PRRT_kwDONV6tZs6D3PyX); the original test_schema_parity file was folded
into client_test.go but the same pattern lives in freshSchemaSQLite.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the fix-cache-tx-retry-on-duplicate-key branch from 4f6983d to a0916be Compare May 22, 2026 23:16
@kalbasit
kalbasit force-pushed the fix-ent-schema-parity-race branch from 66a7315 to 27bd57a Compare May 22, 2026 23:16
kalbasit added a commit that referenced this pull request May 22, 2026
Replace context.Background() with t.Context() so the schema-create call
is bound to the test lifetime. Drops the now-unused context import.

Addresses gemini-code-assist comment from PR #1214
(PRRT_kwDONV6tZs6D3PyX); the original test_schema_parity file was folded
into client_test.go but the same pattern lives in freshSchemaSQLite.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the fix-cache-tx-retry-on-duplicate-key branch from a0916be to 8068305 Compare May 22, 2026 23:28
@kalbasit
kalbasit force-pushed the fix-ent-schema-parity-race branch from 27bd57a to 289a2b5 Compare May 22, 2026 23:28
kalbasit added a commit that referenced this pull request May 22, 2026
Replace context.Background() with t.Context() so the schema-create call
is bound to the test lifetime. Drops the now-unused context import.

Addresses gemini-code-assist comment from PR #1214
(PRRT_kwDONV6tZs6D3PyX); the original test_schema_parity file was folded
into client_test.go but the same pattern lives in freshSchemaSQLite.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the fix-cache-tx-retry-on-duplicate-key branch from 8068305 to 4426c69 Compare May 22, 2026 23:54
@kalbasit
kalbasit force-pushed the fix-ent-schema-parity-race branch from 289a2b5 to 334b47e Compare May 22, 2026 23:54
kalbasit added a commit that referenced this pull request May 22, 2026
Replace context.Background() with t.Context() so the schema-create call
is bound to the test lifetime. Drops the now-unused context import.

Addresses gemini-code-assist comment from PR #1214
(PRRT_kwDONV6tZs6D3PyX); the original test_schema_parity file was folded
into client_test.go but the same pattern lives in freshSchemaSQLite.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the fix-cache-tx-retry-on-duplicate-key branch from 4426c69 to e3a1d74 Compare May 23, 2026 00:07
@kalbasit
kalbasit force-pushed the fix-ent-schema-parity-race branch from 334b47e to 08e7741 Compare May 23, 2026 00:07
kalbasit added a commit that referenced this pull request May 23, 2026
Replace context.Background() with t.Context() so the schema-create call
is bound to the test lifetime. Drops the now-unused context import.

Addresses gemini-code-assist comment from PR #1214
(PRRT_kwDONV6tZs6D3PyX); the original test_schema_parity file was folded
into client_test.go but the same pattern lives in freshSchemaSQLite.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the fix-cache-tx-retry-on-duplicate-key branch from e3a1d74 to 5c887f0 Compare May 23, 2026 00:35
@kalbasit
kalbasit force-pushed the fix-ent-schema-parity-race branch from 08e7741 to 4e5a13c Compare May 23, 2026 00:35
kalbasit added a commit that referenced this pull request May 23, 2026
Replace context.Background() with t.Context() so the schema-create call
is bound to the test lifetime. Drops the now-unused context import.

Addresses gemini-code-assist comment from PR #1214
(PRRT_kwDONV6tZs6D3PyX); the original test_schema_parity file was folded
into client_test.go but the same pattern lives in freshSchemaSQLite.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@kalbasit
kalbasit force-pushed the fix-cache-tx-retry-on-duplicate-key branch from 5c887f0 to abf51c9 Compare May 23, 2026 03:31
TestEntSchemaParity runs t.Parallel() alongside TestClient_Close and
TestWithTransaction_*, all of which call Ents Schema.Create against
the package-level migrate.Tables slice. Atlas mutates that slice
during setupTables/realm, so the unsynchronised parallel calls trip
go test -race.

Wrap m.Create with the same database.SchemaCreateMu mutex the other
parallel helpers (freshSchemaSQLite, etc.) already use. The two tests
now serialise their schema bootstrap and race-detector stops firing.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
@codecov

codecov Bot commented May 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 5.68%. Comparing base (746ea92) to head (d0d185a).

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #1214   +/-   ##
=====================================
  Coverage   5.68%   5.68%           
=====================================
  Files          6       6           
  Lines        387     387           
=====================================
  Hits          22      22           
  Misses       361     361           
  Partials       4       4           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code merge-stack size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant