Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds overflow prevention for Datascript 32-bit transaction IDs in the reactive store. Introduces ChangesDatascript TX-ID Reset
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
server/src/instant/reactive/store.clj (1)
462-464: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winRe-check the threshold while holding the conn lock.
Concurrent callers can all pass the pre-lock threshold check, then serialize multiple full DB rebuilds even after the first reset lowered
:max-tx. Re-check inside the same lock before rebuilding to avoid a reset storm on a large store.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@server/src/instant/reactive/store.clj` around lines 462 - 464, Re-check the tx reset threshold inside the same lock before rebuilding, because `reset-conn-tx!` can be entered by multiple concurrent callers after they all pass the outer `:max-tx` check. Update the `reset-conn-tx!` flow in `store.clj` so the threshold comparison against `ds-tx-reset-threshold` is performed again while holding the conn lock, and only trigger the full DB rebuild if `:max-tx` is still above the threshold and `flags/conn-tx-reset-disabled?` is false.server/test/instant/reactive/store_test.clj (1)
490-519: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the threshold gate and disable flag.
This test covers direct reset, but the production path is
maybe-reset-conn-tx!plusconn-tx-reset-disabled?. Add focused assertions for “resets over threshold” and “does not reset when disabled” so the safety switch is covered.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@server/test/instant/reactive/store_test.clj` around lines 490 - 519, The current test only covers rs/reset-conn-tx!, but it does not exercise the production gate in maybe-reset-conn-tx! or the disable flag check in conn-tx-reset-disabled?. Add focused test coverage that verifies a connection is reset when the tx count exceeds the threshold, and that no reset happens when the disable flag is enabled, using rs/maybe-reset-conn-tx! and rs/conn-tx-reset-disabled? so both safety paths are covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@server/src/instant/reactive/store.clj`:
- Around line 452-455: Preserve the conn’s :max-eid when rebuilding the
Datascript store from d/datoms in the store reset path, since init-db recomputes
it from live datoms and can reuse a retracted highest eid. Update the rebuild
logic around the conn reset to carry forward the previous max-eid value, and
verify the behavior in a regression test that exercises a fully retracted
highest eid so the next transaction does not collide with stale cache keys.
---
Nitpick comments:
In `@server/src/instant/reactive/store.clj`:
- Around line 462-464: Re-check the tx reset threshold inside the same lock
before rebuilding, because `reset-conn-tx!` can be entered by multiple
concurrent callers after they all pass the outer `:max-tx` check. Update the
`reset-conn-tx!` flow in `store.clj` so the threshold comparison against
`ds-tx-reset-threshold` is performed again while holding the conn lock, and only
trigger the full DB rebuild if `:max-tx` is still above the threshold and
`flags/conn-tx-reset-disabled?` is false.
In `@server/test/instant/reactive/store_test.clj`:
- Around line 490-519: The current test only covers rs/reset-conn-tx!, but it
does not exercise the production gate in maybe-reset-conn-tx! or the disable
flag check in conn-tx-reset-disabled?. Add focused test coverage that verifies a
connection is reset when the tx count exceeds the threshold, and that no reset
happens when the disable flag is enabled, using rs/maybe-reset-conn-tx! and
rs/conn-tx-reset-disabled? so both safety paths are covered.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 34bdefe2-f64e-4935-85d4-0b230bfa2dc0
📒 Files selected for processing (3)
server/src/instant/flags.cljserver/src/instant/reactive/store.cljserver/test/instant/reactive/store_test.clj
Datascript uses 32-bit integers for tx-ids. Given enough transactions we will exhaust that. This PR makes it so that when we are within ~1M tx-ids from our max we reset the app's tx-id back to the starting point.
Start / max values come from https://github.com/tonsky/datascript/blob/master/src/datascript/db.cljc