Repository navigation
Conversation
Build and traverse the package dependency graph once while preserving the previous stable cleanup order. Refresh cached package function expressions after dependent function invalidation so DISCARD PACKAGE cannot retain freed package pointers. Assisted-by: OpenAI:Codex
📝 WalkthroughWalkthroughChangesPL/iSQL package cleanup now uses hash-backed dependency traversal and stable topological sorting. Regression coverage validates layered, independent, and cyclic Package dependency cleanup
Estimated code review effort: 4 (Complex) | ~60 minutes Suggested reviewers: 🚥 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 |
|
Hello! Thanks for the work. Just to confirm — is the main goal of this PR the package-cleanup performance optimization? A few initial review comments:
Thanks again! |
Assisted-by: OpenAI:gpt-5
|
Thanks for the clear review. Yes, the goal of this PR is now solely the package-cleanup performance optimization. I addressed both points:
After the split, the package-reset module passes 5/5 tests, and the committed benchmark also runs end to end. |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/pl/plisql/src/pl_package.c (1)
2582-2584: 🩺 Stability & Availability | 🔴 Critical | ⚡ Quick winDead assignment defeats the parent_func refresh.
pfunc = &psource->source;on Line 2582 is immediately clobbered bypfunc = (PLiSQL_function *) funcexpr->parent_func;on Line 2584, so the first assignment has no effect.psourcehere comes from a freshPackageCacheLookup, i.e. it's the up-to-date pointer, whilefuncexpr->parent_funcis the value cached on theFuncExprat an earlier compile — potentially stale/dangling after aDISCARD PACKAGE+ recompile cycle. As written, the function unconditionally discards the fresh value and falls back to the (possibly stale) cached one. Per the PR discussion, this class of fix ("stale parent_func refreshes") was flagged as an out-of-scope correctness change that should move to its own PR with a dedicated before/after regression test — this specific instance looks incomplete/ineffective as committed and should be re-examined there.🐛 Likely intended fix (subject to confirming the actual staleness contract)
- pfunc = &psource->source; - - pfunc = (PLiSQL_function *) funcexpr->parent_func; + /* funcexpr->parent_func may be stale after a DISCARD PACKAGE + recompile; + * refresh it from the freshly-looked-up package source. */ + pfunc = &psource->source; + funcexpr->parent_func = (Node *) pfunc;🤖 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 `@src/pl/plisql/src/pl_package.c` around lines 2582 - 2584, Remove the dead assignment to pfunc in the surrounding package function refresh logic, or complete the intended stale parent_func refresh consistently: use the fresh &psource->source value from PackageCacheLookup rather than immediately overwriting it with funcexpr->parent_func. Keep this correctness change scoped to a dedicated follow-up with regression coverage if that behavior is not part of this PR.
🧹 Nitpick comments (1)
src/pl/plisql/src/pl_package.c (1)
572-791: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winAdd an order-sensitive assertion for the cyclic discard case. The current
src/oracle_test/modules/test_package_reset/sql/test_discard_dependencies.sqlcoverage only checks thatDISCARD PACKAGEsucceeds; it doesn’t pin the fallback ordering for cyclic or external-dependency packages.🤖 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 `@src/pl/plisql/src/pl_package.c` around lines 572 - 791, Add an order-sensitive assertion in test_discard_dependencies.sql for the cyclic/external-dependency discard scenario, verifying the packages are discarded in the expected fallback order while preserving the existing success check.
🤖 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.
Outside diff comments:
In `@src/pl/plisql/src/pl_package.c`:
- Around line 2582-2584: Remove the dead assignment to pfunc in the surrounding
package function refresh logic, or complete the intended stale parent_func
refresh consistently: use the fresh &psource->source value from
PackageCacheLookup rather than immediately overwriting it with
funcexpr->parent_func. Keep this correctness change scoped to a dedicated
follow-up with regression coverage if that behavior is not part of this PR.
---
Nitpick comments:
In `@src/pl/plisql/src/pl_package.c`:
- Around line 572-791: Add an order-sensitive assertion in
test_discard_dependencies.sql for the cyclic/external-dependency discard
scenario, verifying the packages are discarded in the expected fallback order
while preserving the existing success check.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d7471fee-364e-45c7-bc97-b6ebee21d45d
📒 Files selected for processing (4)
src/oracle_test/modules/test_package_reset/benchmark_discard_package_chain.sqlsrc/oracle_test/modules/test_package_reset/expected/test_discard_dependencies.outsrc/oracle_test/modules/test_package_reset/sql/test_discard_dependencies.sqlsrc/pl/plisql/src/pl_package.c
💤 Files with no reviewable changes (2)
- src/oracle_test/modules/test_package_reset/expected/test_discard_dependencies.out
- src/oracle_test/modules/test_package_reset/sql/test_discard_dependencies.sql
|
Follow-up on the latest automated review:
So no code change is needed in this performance branch for those two observations. |
Summary
This PR is now performance-only. The pre-existing cache correctness issue identified during review was split into #1453 with its own regression test and issue.
Performance background
I did not encounter this in a production deployment, so I do not want to imply a real-world incident. Source inspection showed that the previous cleanup repeatedly scanned the remaining package list, making reverse-ordered dependency chains quadratic. The benchmark is an explicitly synthetic worst case intended to make the complexity and scaling reproducible; ordinary installations with fewer cached packages or shallower dependency graphs will see a smaller effect.
The reproducer is committed at
src/oracle_test/modules/test_package_reset/benchmark_discard_package_chain.sql. Run it from an IvorySQLpsqlclient against the base and patched revisions, for example:Only
DISCARD PACKAGEis timed. Package bodies are created in reverse order and each body depends on its predecessor.The 3,200-package synthetic case is about 483x faster, while the patched 3,200-to-6,400 result is close to linear scaling.
Verification
make -C src/oracle_test/modules/test_package_reset oracle-check NO_TEMP_INSTALL=1— 5/5 passedpackage_count=10after the split to verify that the reproducer runs end to endgit diff --checkFixes #1426
AI assistance disclosure
This contribution was prepared with OpenAI Codex using GPT-5. The agent assisted with source and test inspection, issue scoping, drafting code and tests, running verification, benchmarking, and preparing the PR description. I directed the scope, reviewed the resulting changes against the source and test results, and remain responsible for the submission.