Repository navigation
fix(join): keep only the newest over-long join labels per adapter - #1040
Conversation
8.3.7 recorded every over-long `alias.column` label in a static map that was never pruned. Join aliases are the caller's, so a Swoole worker that serves joins under ever-new long aliases kept every label it was asked for, for its whole life. The map is now per adapter and keeps the newest 1024 labels, oldest evicted first. Resetting it per read is not safe: find() can call getDocument() through getJunctionName() and SQLite's full-text lookup before it remaps its rows, which would drop the outer read's labels. Eviction only drops the oldest, a read's own labels are the newest when its rows are remapped, and an adapter runs one statement at a time, so a read never loses its own. The bound is the memory a worker can afford, not a limit on queries: a read needs at most a few labels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
What
Bug: 8.3.7 (feat(join): accept Appwrite table IDs as join aliases #1039) labels a joined column whose
alias.columnlabel is longer than the engine keeps (PostgreSQL: 63 bytes) as$join_<md5>. It records the original label in a static map that is never pruned. Join aliases are chosen by the caller, so a long-lived Swoole worker serving joins under ever-new long aliases keeps every label it was ever asked for, and its memory grows without bound. Reported in review on chore(deps): bump utopia-php/database to 8.3.8 (join aliases from table IDs) appwrite/appwrite#14612.Fix: the map is now per adapter instance and keeps the newest 1024 labels, evicting the oldest first.
Why not reset the map per read:
find()can callgetDocument()partway through, viagetJunctionName()and SQLite's full-text table lookup, before it remaps its own rows. A reset there would drop the outer read's labels.Why eviction is safe:
So a read never loses its own labels.
Before / after
tests/unit/Adapter/JoinLabelRetentionTest.phpuses SQLite with an 8-byte label limit, so every joined label goes through the digest path:main)Every overlong label ever read is still held(1,100+ labels)pintandphpstanpass locally. The full adapter matrix runs in CI.🤖 Generated with Claude Code
Summary by CodeRabbit