Skip to content

fix: initialize inbox test model before concurrent database work - #571

Merged
thomhurst merged 3 commits into
mainfrom
issue-570-ef-model
Nov 13, 2026
Merged

thomhurst merged 3 commits into
mainfrom
issue-570-ef-model

Conversation

@thomhurst

@thomhurst thomhurst commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

PostgreSQL InboxTests can race the first native EF relational-model initialization, throwing ModelNotFinalized before settlement-disposal assertions run. Add a test-context model-finalized convention that calls native GetRelationalModel during EF's existing model-construction pipeline, before the runtime model is published. Tests remain parallel; no new lock or global state is introduced.

Closes #570

Native/existing reuse: EF 10.0.15's ConfigureConventions, IModelFinalizedConvention, native relational-model construction and model cache. Upstream #39214 describes the matching check-then-act race; backport #39423 targets unreleased 10.0.16. This temporary test-context startup workaround has a removal comment; it does not reproduce EF's initialization algorithm. No broker capability is involved.

Validation: deterministic standalone pinned-EF interleaving reproduced the original exception. The new startup regression failed without the convention (relational model still lazy), then all 55 InboxTests passed on each of net10.0 and net11.0 (110 total), including real PostgreSQL committed-outcome/native-retry tests. git diff --check passed. Local platform is macOS ARM64; hosted Linux x64 remains CI validation. Full diff reviewed for reuse, correctness and performance.

No docs impact: test initialization only; no library behavior/API changes. Production per-message cost: unchanged, 0 B added. No CI rerun or threshold relaxation.

Validation evidence: /Users/tom/git/Relayer-evidence/issue-570/validation-d179ca1/; 588 source, report, log, probe and loaded binary files independently copied/length-SHA256 verified and read back against inventory.json. Retained locally while #570 is open.

Review follow-up: removed the completed batch-allocation diagnostic workflow and normal-test instrumentation in 573afcd, restoring this PR to the inbox model fix alone. The unrelated historical CI failure is tracked in #585, with its original failure log and all diagnostic outcomes preserved; its +56 B cause remains unproven. All sixteen predeclared hosted diagnostic processes passed, which does not replace or explain the failed ready-PR CI run. No CI rerun was requested. Diagnostic sources remain available in b3b0e29 and the retained artifact; no permanent workflow is needed to retain completed evidence.

Focused batch-allocation comparison after removal: 4/4 passed across net10.0 and net11.0 on macOS ARM64. Evidence: /Users/tom/git/Relayer-evidence/pr-571/573afcd-validation/; all 484 source, loaded-binary, report and log files were copied, independently compared with originals by length/SHA-256, and read back against inventory.json. The unchanged InboxTests validation above was not rerun. git diff --check passes. No production per-message change, 0 B added; no docs impact.

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b24f00dc-b380-4210-9955-f5c008982519
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@thomhurst

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T07:45:32.063588Z 573afcd Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

Review of #571: no blocking findings.

  • Scope: the change is test-only, in InboxTests.cs, with no library or API impact. Docs and performance are unaffected, which the PR states.
  • Approach: an IModelFinalizedConvention registered through ConfigureConventions builds the relational model inside EF's own model-construction pipeline, before the cached runtime model is published. It uses native EF extension points and doesn't re-implement EF's initialization. It also adds no locks, statics or [NotInParallel] limiters, so tests still run in parallel as AGENTS.md requires.
  • Regression test: Orders_model_is_ready_before_concurrent_database_work needs no database, since Host=unused never connects. It fails without the convention. It reads the RelationalModel runtime annotation, which is an EF internal name, so it could break on an EF upgrade. That is acceptable for a test tied to a temporary workaround.
  • Removal: the comment names upstream GetRelationalModel throws "The model must be finalized" when two threads make the first call at once (check-then-act on RelationalModelFactory) dotnet/efcore#39214 and the 10.0.16 backport as the removal trigger. Consider filing a follow-up issue tied to the EF bump so the workaround doesn't outlive the fix. This is non-blocking.

I did not run the tests. The PR reports 55 InboxTests passing on net10.0 and net11.0.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: d179ca1f7b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@thomhurst

Copy link
Copy Markdown
Owner Author

Both required reviews clear current head d179ca1; no review threads or blocking findings remain. Claude’s optional follow-up suggestion is non-blocking and declined: the removal trigger is already recorded beside the workaround, so no additional code or tracking issue is needed.

Validation evidence was rehashed against its original inventory and copied to /Users/tom/git/Relayer-evidence/pr-571/d179ca1f7b2f7f934ea032ba83508152852dccdf/; all 588 file lengths and SHA-256 hashes match. This archive is outside removable worktrees and retained locally until the PR closes. No tests rerun because the reviewed code is unchanged.

@thomhurst
thomhurst marked this pull request as ready for review November 13, 2026 07:09
@thomhurst
thomhurst enabled auto-merge (squash) November 13, 2026 07:09
@thomhurst
thomhurst marked this pull request as draft November 13, 2026 07:29
auto-merge was automatically disabled November 13, 2026 07:29

Pull request was converted to draft

@github-actions

Copy link
Copy Markdown

Review of #571

Blocking: the PR contains unrelated, undisclosed changes. The title and description cover only the PostgreSQL InboxTests model-finalization fix for #570. The diff also adds:

  • .github/workflows/batch-allocation-control.yml and .github/scripts/batch_allocation_control.py, a new hosted workflow that builds a native CLR profiler and runs 16 trials.
  • Diagnostic instrumentation in tests/Relayer.Tests/BatchPipelineTests.cs: NativeAllocationRegion.Load/Begin/End and a Console.WriteLine in a production test.
  • A Compile Include of tools/FrozenConcurrentProbe/NativeAllocationRegion.cs in Relayer.Tests.csproj.

The description does not mention any of this. It says 'test initialization only' and 'No docs impact', which is inaccurate for a new CI workflow that uploads src/, tests/ and a runtime copy as 90-day artifacts. The script's own docstring says it belongs to a different investigation ("Fixed-count Linux diagnostic for #571").

Why this matters:

  • A reviewer approving the Postgres convention is also approving CI infrastructure and a change to the shape of an unrelated allocation test.
  • The Postgres fix must land independently of the batch-allocation investigation. If the diagnostic is reverted or stalls, it should not take the inbox race fix with it.
  • The Console.WriteLine and NativeAllocationRegion hooks stay in the normal test path (bufferedSends) even though the comment says 'never normal CI'. NativeAllocationRegion.Load() runs on every CI run of that test.

Suggestion: split this into two PRs. Keep only InboxTests.cs here, closing #570. Move the batch-allocation diagnostic to its own draft PR and issue, with an accurate description and a retention and artifact scope that matches what it needs. Uploading all of src/ and tests/ is excessive.

The InboxTests change itself looks sound.

@thomhurst

Copy link
Copy Markdown
Owner Author

@codex review

The earlier waiting blocker has ended: ready CI run 43383708766 failed the unrelated batch allocation comparison (+56 B on net10.0); InboxTests and net11.0 passed. Commit b3b0e29 adds a bounded hosted exact-callback investigation using the existing profiler, without relaxing the assertion, rerunning CI for green, or claiming the failure is fixed. Local focused comparison passes 4/4 across both targets. The PR is back in draft for new-head review.

Hosted diagnostic: https://github.com/thomhurst/Relayer/actions/runs/43386487904 . It records eight fixed original/callback process pairs, all outcomes and executable inputs; callback results are separate instrumented observations, not attribution of the historical +56 B window. Inspect that run and both current-head reviews next. The PR body records validation and evidence retention. No linked prerequisite, superseding implementation or finished parent removes this CI failure; no duplicate #299/#348 workaround was added.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: b3b0e29459

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@thomhurst

Copy link
Copy Markdown
Owner Author

Disposition of Claude’s review: separation of the completed diagnostic from the inbox fix is accepted and addressed in 573afcd. This PR now changes only InboxTests.cs; the diagnostic workflow/script, compile include, NativeAllocationRegion hooks and console output are removed. No broad source/runtime artifact workflow will remain on main from this PR. Although the description had been updated after the review started, scope separation is preferable now that capture is complete.

The historical ready CI run 43383708766 is terminal failed, so the old waiting blocker has ended. Its unrelated +56 B allocation failure remains unexplained in #585; no failure is suppressed or called fixed. The bounded investigation captured all sixteen passing original/callback process outcomes, but those cannot attribute the failing historical window. The original failure log, diagnostic sources and all 2,010 hash-verified hosted-manifest files are retained independently under #585’s evidence root and the uploaded artifact. #299/#348’s +40 B mechanism does not establish this cause. No CI rerun was requested.

Validation for this removal: focused batch comparison 4/4 passed on net10.0/net11.0; git diff --check passes. All 484 local validation files were copied and length/SHA-256 compared with originals, then read back at /Users/tom/git/Relayer-evidence/pr-571/573afcd-validation/. Existing unchanged inbox evidence remains retained at the documented paths. Full final diff reviewed for reuse, correctness and performance. Production per-message cost unchanged, 0 B; no docs impact.

@codex review

@github-actions

Copy link
Copy Markdown

Reviewed the head of #571 (test-only change in InboxTests.cs).

  • The IModelFinalizedConvention calls native GetRelationalModel inside EF's own model-construction pipeline, before the model is cached. That removes the first-use race (GetRelationalModel throws "The model must be finalized" when two threads make the first call at once (check-then-act on RelationalModelFactory) dotnet/efcore#39214) without a lock or global state, so tests stay parallel (AGENTS.md D17 and the test-isolation rules).
  • The static lambda avoids a capture, and the comment names the upstream issue and the removal condition (upgrade to 10.0.16).
  • The regression test needs no database (Host=unused) and asserts the relational model is built eagerly.
  • No production code, API or docs are affected, and per-message cost is unchanged. The PR states 'no docs impact' and gives the cost line, as AGENTS.md requires.
  • I did not build or run the tests; the PR reports 55 InboxTests passing on both TFMs, and hosted CI will confirm on Linux.

No actionable findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 573afcdb8d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@thomhurst

Copy link
Copy Markdown
Owner Author

The earlier wait on run 43383708766 has ended. Its failed allocation comparison was investigated in the subsequent bounded diagnostic and remains explicitly tracked in #585; no rerun or relaxed assertion is requested here. Current head 573afcd contains only InboxTests.cs and both required reviewers clear that exact head. All review surfaces were inspected; no threads or undispositioned findings remain. There is no prerequisite dependency, superseding PR or finished parent that requires a different resolution route.

Reverified retained validation inventories: all 484 files under /Users/tom/git/Relayer-evidence/pr-571/573afcd-validation/ and all 588 files under /Users/tom/git/Relayer-evidence/pr-571/d179ca1f7b2f7f934ea032ba83508152852dccdf/ match their recorded lengths and SHA-256 hashes. Prior independent original-to-archive comparisons are recorded above. Code is unchanged, so no local tests were repeated. Promoting the reviewed head for fresh required CI through the protected wrapper.

@thomhurst
thomhurst marked this pull request as ready for review November 13, 2026 07:44
@thomhurst
thomhurst enabled auto-merge (squash) November 13, 2026 07:44
@thomhurst
thomhurst merged commit 7a3e443 into main Nov 13, 2026
21 checks passed
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.

PostgreSQL inbox test fails with EF model initialization error on net11.0

1 participant