Skip to content

Fix DBIx::Class ordered test CODE weaken GC stall#787

Merged
fglock merged 1 commit into
masterfrom
fix/dbic-ordered-code-weaken-gc
May 21, 2026
Merged

Fix DBIx::Class ordered test CODE weaken GC stall#787
fglock merged 1 commit into
masterfrom
fix/dbic-ordered-code-weaken-gc

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented May 21, 2026

Summary

  • Avoid running a full weak-ref reachability sweep from the hot weaken(CODE) path.
  • Keep the existing CODE-specific stale weak-ref cleanup for expired anonymous or former-stash CODE refs.
  • Fixes the DBIx::Class t/87ordered.t stall caused by repeated explicit old-GC cycles.

Investigation

jstack on the stuck t/87ordered.t child showed the main thread inside:

Runtime.gc
ScalarRefRegistry.forceGcAndSnapshot
ReachabilityWalker.sweepWeakRefs
WeakRefRegistry.weaken
Scalar::Util::weaken
DBIx::Class::Storage::BlockRunner

JFR confirmed the process was not blocked in SQL or DBIC logic: a 20s recording had 519 System.gc() / old-GC events.

Verification

  • make
  • timeout 120 ./jperl src/test/resources/unit/refcount/subquote_defer_weak_cleanup.t
  • timeout 120 ./jperl src/test/resources/unit/refcount/weaken_closure_argument.t
  • timeout 600 ./jperl -Iblib/lib -Iblib/arch t/87ordered.t from the DBIx-Class build dir

The direct DBIC check passed 1..1271 with Auto checked 5 references for leaks - none detected.

Keep the CODE weak-ref cleanup path targeted to the CODE referent instead
of running a full ReachabilityWalker sweep from WeakRefRegistry.weaken().
DBIx::Class weakens callback CODE refs in hot cursor paths, and the broad
sweep was forcing repeated explicit old-GC cycles in t/87ordered.t.

Generated with Codex (https://openai.com/codex)

Co-Authored-By: Codex <codex@openai.com>
@fglock fglock merged commit 09c334f into master May 21, 2026
2 checks passed
@fglock fglock deleted the fix/dbic-ordered-code-weaken-gc branch May 21, 2026 17:19
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