Skip to content

Improve tests - #57

Merged
maleadt merged 3 commits into
mainfrom
tb/tests
May 22, 2026
Merged

Improve tests#57
maleadt merged 3 commits into
mainfrom
tb/tests

Conversation

@maleadt

@maleadt maleadt commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Fix two bugs exposed by them.

maleadt added 3 commits May 22, 2026 10:49
Two bugs both surfacing on Julia 1.10 CI:

- `_finalize_txn` calls `mdb_txn_abort` on a dangling handle when
  `close(env)` ran first (the env close already freed the txn memory
  via `mdb_env_close`). Mirrors the existing defensive check in
  `close(::Cursor)`.

- The finalizer tests relied on `GC.gc()` to synchronously run
  finalizers, but on Julia 1.10+ finalizers may be queued to a
  separate task. Switched to explicit `finalize(...)` calls so the
  tests no longer race the GC scheduler.

Also adds a test that exercises the txn-finalized-after-env-closed
ordering directly (this was reproducing the Windows access violation).
LMDB's `mdb_env_close` requires all transactions to be closed first;
otherwise it leaves the lockfile/heap in a corrupted state and the next
env-open in the same process crashes inside `mdb_txn_renew0`. On Julia
1.10 we got away with it (different allocator behavior), but it
reliably crashed on 1.11+.

Track live transactions on the Environment as `WeakRef`s and abort any
still-open ones in `close(env)` before delegating to `mdb_env_close`.
Tests cover both the abort-on-close path and the canary case (open a
new env after misuse and confirm it survives).
@codecov

codecov Bot commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.41%. Comparing base (2910dd9) to head (caeee08).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #57      +/-   ##
==========================================
+ Coverage   82.11%   82.41%   +0.29%     
==========================================
  Files           9        9              
  Lines         755      762       +7     
==========================================
+ Hits          620      628       +8     
+ Misses        135      134       -1     

☔ 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.

@maleadt
maleadt merged commit df59a66 into main May 22, 2026
10 checks passed
@maleadt
maleadt deleted the tb/tests branch May 22, 2026 09:20
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