Skip to content

fix(db): avoid coroutine leak in sync DSN resolver (#2325 to stage) - #2361

Merged
dylan-savage merged 4 commits into
stagefrom
fix/stage-rr-2318-dsn-coroutine-leak
Sep 18, 2026
Merged

dylan-savage merged 4 commits into
stagefrom
fix/stage-rr-2318-dsn-coroutine-leak

Conversation

@krishhgg

@krishhgg krishhgg commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

"## Summary\n\n- port #2325 to the current stage release line\n- reject synchronous DSN and filesystem operations from an active event loop before constructing their coroutines\n- preserve the existing resolver and filesystem contracts while preventing unawaited-coroutine warnings\n- cover the duplicated filesystem helper so all ten call sites defer coroutine creation\n\n## Type\n\nfix (stage port)\n\n## Testing\n\n- [x] Tests added or updated\n- [ ] ./builder test:fast lint:check surfaces:check not run locally; GitHub CI is the final repository-wide gate\n- [ ] Engine-dependent suites not run locally; focused engine-free pytest coverage passed\n\ntext\ntool_filesystem focused unit suites: 120 passed; hardened regression: 35 passed\nruff check + ruff format --check: passed\ndevelop/stage range-diff: all 4 commits equivalent\n\n\n## Checklist\n\n- [x] Commit messages follow conventional commits\n- [x] No secrets or credentials included\n- [x] Docs updated in the same change (not applicable; internal lifecycle behavior only)\n- [x] Breaking changes documented (not applicable; no breaking changes)\n\n## Agent context\n\nOpenAI Codex (gpt-5.6-sol) / T3 Code, autonomous under explicit approval. Focused tests and develop/stage patch parity were verified locally; engine-dependent builder suites remain delegated to GitHub CI.\n\n## Paired PR\n\nDevelop: #2325\n\n## Release Coordination\n\nMerge with the release owner so the SaaS engine pin advances in the same release window.\n\n## Linked Issue\n\nFixes #2318\n\n\n\n\n## Summary by CodeRabbit\n\n- Bug Fixes\n - Improved reliability for filesystem and database operations when called from applications that already have an active asynchronous event loop.\n - Prevented premature asynchronous operation creation in these scenarios, reducing runtime errors and resource warnings.\n - Added safeguards to ensure affected operations fail cleanly and predictably when used in unsupported event-loop contexts.\n\n\n"

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 8 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: c93916c5-a88b-4824-a363-5c8ae2958a72

📥 Commits

Reviewing files that changed from the base of the PR and between fd0c04f and f62ce76.

📒 Files selected for processing (2)
  • nodes/src/nodes/tool_filesystem/IInstance.py
  • nodes/test/tool_filesystem/test_sink_lanes.py

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 2d7ddbfe-5856-4aeb-a3ae-5c0104872bfa

📥 Commits

Reviewing files that changed from the base of the PR and between 562ec48 and fd0c04f.

📒 Files selected for processing (2)
  • nodes/test/test_rocketride_db.py
  • packages/ai/src/ai/common/rocketride_db.py

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

_run_async now checks for an active event loop before creating the resolver coroutine. resolve_rocketride_dsn passes the resolver callable and client ID separately. The regression test verifies that no coroutine is created when resolution is rejected.

Changes

RocketRide DB resolution

Layer / File(s) Summary
Preflight guard and regression test
packages/ai/src/ai/common/rocketride_db.py, nodes/test/test_rocketride_db.py
_run_async now accepts an async callable and its arguments. resolve_rocketride_dsn supplies the resolver and client ID separately. The regression test checks that the resolver creates no coroutine when a running event loop causes RuntimeError.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to fd0c0

The synchronous resolver retains its expected behavior while avoiding coroutine creation when called from an active event loop. No actionable merge risk remains.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive For #2318, packages/ai/src/ai/common/rocketride_db.py checks asyncio.get_running_loop() before it calls async_fn(*args), and then uses asyncio.run. The updated regression test uses `created ==… Provide the shared DB test result with runtime warnings treated as errors. The result must confirm that the relevant tests pass without unawaited-coroutine warnings.
✅ Passed checks (3 passed)
Check name Status Explanation
Out of Scope Changes check ✅ Passed The reviewed changes are limited to the shared RocketRide DB async bridge and its running-event-loop regression test. These changes directly implement #2318 and support all three stated RocketRide DB …
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: preventing a coroutine leak in the synchronous DSN resolver. It is concise and relevant to the pull request.
Full details: Linked Issues check

Explanation

For #2318, packages/ai/src/ai/common/rocketride_db.py checks asyncio.get_running_loop() before it calls async_fn(*args), and then uses asyncio.run. The updated regression test uses created == [] to verify that the resolver callable does not create a coroutine on the rejected path. The shared helper serves rocketride_sql, rocketride_vector, and rocketride_graph, so the implementation covers the stated components. The code preserves the normal synchronous path and raises RuntimeError for a running loop. No test execution result is available to establish that the shared DB tests pass with runtime warnings treated as errors.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@github-actions

Copy link
Copy Markdown
Contributor
🤖 Internal: Discord sync marker

Auto-managed by the Discord notification workflow. Stores the linked Discord message ID and forum thread ID. Do not edit or delete.

@github-actions github-actions Bot added module:nodes Python pipeline nodes module:ai AI/ML modules labels Sep 18, 2026
@krishhgg

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

asclearuc
asclearuc previously approved these changes Sep 18, 2026

@asclearuc asclearuc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kgarg2468 — this is a clean fix. Deferring coroutine construction until after the running-loop pre-check is the right shape, and the rewritten test_rejects_running_event_loop_before_creating_coroutine proves the coroutine is never built rather than only that the call raises, which is the part that actually matters.

This is the byte-identical port of #2325 onto stage (I compared the two diffs; they match exactly), so the review below is the same one I left on #2325.

Note on CI: the three Build jobs were still running when I wrote this, so the review is against code whose build and test results are not in yet. Nothing is red.

Approve

One non-blocking should fix is inline: tool_filesystem has a second copy of _run_async with the same defect. CodeRabbit's Major on the missing regression docstring is addressed in 85ae5b78 and its thread is resolved; nothing outstanding there.

@krishhgg

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Pull request base or head changed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@krishhgg

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@krishhgg

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@krishhgg
krishhgg requested a review from asclearuc September 18, 2026 20:07
@krishhgg

Copy link
Copy Markdown
Collaborator Author

@asclearuc this final head is the exact four-commit stage port of merged develop #2325. CodeRabbit is clean, CI is green, the focused filesystem/DSN regressions pass, and there are no unresolved threads. Please re-review the final head.

@dylan-savage
dylan-savage merged commit b5a504c into stage Sep 18, 2026
25 of 26 checks passed
@dylan-savage
dylan-savage deleted the fix/stage-rr-2318-dsn-coroutine-leak branch September 18, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:ai AI/ML modules module:nodes Python pipeline nodes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants