OF-3364: Limit MUC history reload query at the database level - #3487
Conversation
MUCPersistenceManager#loadHistory previously fetched all rows since the configured reload window and then scrolled/trimmed the ResultSet client-side to keep only the last maxNumber messages. This relied on scrollable, TYPE_SCROLL_INSENSITIVE result sets, which are not reliably supported across all database backends (e.g. disabled outright for CockroachDB), and could transfer far more data than was ultimately retained for rooms with long histories. Instead, build the query dynamically using DbConnectionManager's result-set-limit facilities (LIMIT / TOP / FETCH FIRST ... ROWS ONLY, per database type) so the limit is pushed down to the database. Also adds debug logging around the reload window and returned row count to make future over-fetching easier to spot.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
Merge Risk: ⚪ Minimal · up to MUC history loading now limits database results directly while retaining chronological message order, reducing unnecessary data transfer without an identified merge-blocking behavior risk. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
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 |
|
Successfully created backport PR for |
MUCPersistenceManager#loadHistory previously fetched all rows since the configured reload window and then scrolled/trimmed the ResultSet client-side to keep only the last maxNumber messages.
This relied on scrollable, TYPE_SCROLL_INSENSITIVE result sets, which are not reliably supported across all database backends (e.g. disabled outright for CockroachDB), and could transfer far more data than was ultimately retained for rooms with long histories.
Instead, build the query dynamically using DbConnectionManager's result-set-limit facilities (LIMIT / TOP / FETCH FIRST ... ROWS ONLY, per database type) so the limit is pushed down to the database.
Also adds debug logging around the reload window and returned row count to make future over-fetching easier to spot.