Compare ActiveRecord connection cache entries by identity#5890
Conversation
|
👋 Hey @marcotc, please fill "Change log entry" section in the pull request description. If changes need to be present in CHANGELOG.md you can state it this way **Change log entry**
Yes. A brief summary to be placed into the CHANGELOG.md(possible answers Yes/Yep/Yeah) Or you can opt out like that **Change log entry**
None.(possible answers No/Nope/None) Visited at: 2026-06-11 07:23:15 UTC |
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: f561415 | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-06-11 07:51:30 Comparing candidate commit f561415 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 48 metrics, 1 unstable metrics.
|
ivoanjo
left a comment
There was a problem hiding this comment.
👍 LGTM
One thing I'd suggest clarifying in the PR description is that it claims
We're running this fix in production for ~2 weeks without a single segfault. Previously, segfaults ocurred on a daily basis.
and this description came from #5719 which is a different change from this one.
I do agree that they are in theory equivalent. The problem is the Ruby VM in theory shouldn't segfault when doing this, yet it does. So this workaround is about what happens in practice so at least to me I think we should be clear that we expect the workaround to work, but have not actually been able to reproduce the original bug and thus to validate it.
Maybe this is a small detail, but I think it's important to clarify it if we need to revisit the issue in the future.
| # as large change around the crash site was done in that version (https://github.com/ruby/ruby/pull/14039/changes#diff-884a5a8a369ef1b4c7597e00aa65974cec8c5f54f25f03ad5d24848f64892869R1743), | ||
| # where `RClass.cc_table` (the NULL dereferenced pointer) became a GC-managed object, |
There was a problem hiding this comment.
Minor: This comment looks unfinished? (And I'm not sure it's actually related to our crash?)
There was a problem hiding this comment.
It's related to the crash site.
I only typed , instead of ..
I'll fix it.
I'll reread it today to see if it's not clear.
|
As we have an upcoming release, and we've tested and also approved the previous PR, I'm going to go ahead and merge this PR to make sure it's ready and validated for the release. I'd still advise:
|
|
Nice. |
Originally #5719, by @dmilisic (thank you!).
What does this PR do?
Fix #5718 Segmentation fault in CachingResolver
Motivation:
Ocasional segfaults after upgrading from ddtrace (v1) to datadog (v2)
Change log entry
Yes. Compare ActiveRecord connection cache entries by identity
Additional Notes:
When using rails with multiple threads, each thread will have its own connection configuration Hash with a different
object_id. So we can expect more cache entries, but we eliminate the overhead of comparing hashes.An equivalent workaround (#5719) ran successfully in production for ~2 weeks without a segfault. Previously, segfaults occurred on a daily basis.
How to test the change?
Segmentation faults are difficult to reproduce. There should be no change in behaviour.