Skip to content

Try fix ObjectDisposedException test race condition#2241

Open
myieye wants to merge 1 commit intodevelopfrom
fix-ObjectDisposedException-test-race-condition
Open

Try fix ObjectDisposedException test race condition#2241
myieye wants to merge 1 commit intodevelopfrom
fix-ObjectDisposedException-test-race-condition

Conversation

@myieye
Copy link
Copy Markdown
Collaborator

@myieye myieye commented Apr 10, 2026

Just ran into this race condition in CI.
I thought I'd fixed this by factoring away some calls to ClearAllPools.
I'm hopeful that that did help (It certainly hasn't happened often recently) and that this last one will truly prevent this from happening.

Error: System.ObjectDisposedException : Cannot access a disposed object.
Object name: 'SQLitePCL.sqlite3'.

Failed LcmCrdt.Tests.MiniLcmTests.PublicationsTests.UpdatePublication_WithUpdateObject_Works [1 ms]
Error Message:
System.ObjectDisposedException : Cannot access a disposed object.
Object name: 'SQLitePCL.sqlite3'.
Stack Trace:
at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
at SQLitePCL.SQLite3Provider_e_sqlite3.SQLitePCL.ISQLite3Provider.sqlite3_create_function(sqlite3 db, Byte[] name, Int32 nargs, Int32 flags, Object v, delegate_function_scalar func)
at SQLitePCL.raw.sqlite3_create_function(sqlite3 db, String name, Int32 nArg, Int32 flags, Object v, delegate_function_scalar func)
at SQLitePCL.raw.sqlite3_create_function(sqlite3 db, String name, Int32 nArg, Object v, delegate_function_scalar func)
at Microsoft.Data.Sqlite.SqliteConnection.Open()
at System.Data.Common.DbConnection.OpenAsync(CancellationToken cancellationToken)
--- End of stack trace from previous location ---
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.AsyncEnumerator.InitializeReaderAsync(AsyncEnumerator enumerator, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable1.AsyncEnumerator.MoveNextAsync()
at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleAsync[TSource](IAsyncEnumerable1 asyncEnumerable, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.ShapedQueryCompilingExpressionVisitor.SingleAsync[TSource](IAsyncEnumerable1 asyncEnumerable, CancellationToken cancellationToken)
at SIL.Harmony.Db.CrdtRepository.HasCommit(Guid commitId) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\harmony\src\SIL.Harmony\Db\CrdtRepository.cs:line 109
at SIL.Harmony.DataModel.Add(Commit commit) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\harmony\src\SIL.Harmony\DataModel.cs:line 117
at SIL.Harmony.DataModel.Add(Commit commit) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\harmony\src\SIL.Harmony\DataModel.cs:line 128
at SIL.Harmony.DataModel.AddChanges(Guid clientId, IEnumerable`1 changes, Guid commitId, CommitMetadata commitMetadata) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\harmony\src\SIL.Harmony\DataModel.cs:line 98
at SIL.Harmony.DataModel.AddChange(Guid clientId, IChange change, Guid commitId, CommitMetadata commitMetadata) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\harmony\src\SIL.Harmony\DataModel.cs:line 66
at LcmCrdt.CrdtMiniLcmApi.AddChange(IChange change) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt\CrdtMiniLcmApi.cs:line 51
at LcmCrdt.CrdtMiniLcmApi.CreatePublication(Publication pub) in D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\LcmCrdt\CrdtMiniLcmApi.cs:line 179
at MiniLcm.Tests.PublicationsTestsBase.InitializeAsync() in D:\a\languageforge-lexbox\languageforge-lexbox\backend\FwLite\MiniLcm.Tests\PublicationsTestsBase.cs:line 10

@github-actions github-actions bot added the 💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related label Apr 10, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 10, 2026

📝 Walkthrough

Walkthrough

Updated the AvoidTrimming() method in LcmCrdtKernel.cs by removing the direct call to SqliteConnection.ClearAllPools() and replacing it with a DynamicDependency attribute to prevent trimming during compilation.

Changes

Cohort / File(s) Summary
Trimming Prevention
backend/FwLite/LcmCrdt/LcmCrdtKernel.cs
Removed direct invocation of SqliteConnection.ClearAllPools() from AvoidTrimming() method and added DynamicDependency attribute to preserve the method from being trimmed by AOT compilation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • Don't clear used connection pools #2217: Related refactoring of SqliteConnection.ClearAllPools handling in the same LcmCrdt backend module, but with a different approach using targeted pool clearing.

Suggested labels

💻 FW Lite

Poem

🐰 A trim that's preserved without the call,
No scissors for this code at all!
With attributes we mark what matters true,
AOT won't trim away what's due.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Try fix ObjectDisposedException test race condition' accurately describes the main change: addressing a race condition causing an ObjectDisposedException in tests by preventing SqliteConnection.ClearAllPools from being trimmed.
Description check ✅ Passed The PR description clearly relates to the changeset, explaining the race condition being fixed and detailing the specific error and previous mitigation attempts.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-ObjectDisposedException-test-race-condition

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

UI unit Tests

  1 files  ±  0   59 suites  +56   27s ⏱️ +27s
176 tests +166  176 ✅ +166  0 💤 ±0  0 ❌ ±0 
245 runs  +235  245 ✅ +235  0 💤 ±0  0 ❌ ±0 

Results for commit 2c885da. ± Comparison against base commit 73e4ecd.

@argos-ci
Copy link
Copy Markdown

argos-ci bot commented Apr 10, 2026

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Apr 10, 2026, 12:03 PM

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

Labels

💻 FW Lite issues related to the fw lite application, not miniLcm or crdt related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant