Skip to content

fix(sql): cache WAL txn intervals to avoid out-of-disk-space errors in case of manual and timer materialized views#5797

Merged
bluestreak01 merged 42 commits intomasterfrom
puzpuzpuz_mat_view_wal_purge
Jul 7, 2025
Merged

fix(sql): cache WAL txn intervals to avoid out-of-disk-space errors in case of manual and timer materialized views#5797
bluestreak01 merged 42 commits intomasterfrom
puzpuzpuz_mat_view_wal_purge

Conversation

@puzpuzpuz
Copy link
Copy Markdown
Contributor

@puzpuzpuz puzpuzpuz commented Jun 30, 2025

Fixes WalPurgeJob not being able to make progress in case of materialized views with manual or timer refresh. The problem due to the refresh job having to read txn intervals from WAL transactions (_event files) to perform an incremental refresh. But for manual or timer views the refresh may be triggered very infrequently (or even never) leading to old WAL segments accumulating on disk. This patch introduces a txn intervals cache to mat view state objects. The cache is refreshed on each base table transaction, so that from the WalPurgeJob's perspective manual and timer views now behave similar to the immediate ones.

The caching is done via a special timer, so it's throttled to avoid writing too many mat view state WAL transactions with cached intervals to the disk.

Also enables manual refresh type.

@puzpuzpuz puzpuzpuz self-assigned this Jun 30, 2025
@puzpuzpuz puzpuzpuz added Bug Incorrect or unexpected behavior SQL Issues or changes relating to SQL execution labels Jun 30, 2025
… in case of manual and timer materialized views
@puzpuzpuz puzpuzpuz force-pushed the puzpuzpuz_mat_view_wal_purge branch from d96baa7 to 55be4e9 Compare July 1, 2025 11:23
@puzpuzpuz puzpuzpuz changed the title chore(sql): cache WAL txn intervals to avoid out-of-disk-space errors in case of manual and timer materialized views fix(sql): cache WAL txn intervals to avoid out-of-disk-space errors in case of manual and timer materialized views Jul 1, 2025
@puzpuzpuz puzpuzpuz marked this pull request as ready for review July 2, 2025 06:38
@puzpuzpuz puzpuzpuz marked this pull request as draft July 2, 2025 10:16
@puzpuzpuz puzpuzpuz marked this pull request as ready for review July 3, 2025 12:51
@puzpuzpuz puzpuzpuz force-pushed the puzpuzpuz_mat_view_wal_purge branch from 656f45d to 1ab536c Compare July 4, 2025 14:26
ideoma
ideoma previously approved these changes Jul 4, 2025
ideoma
ideoma previously approved these changes Jul 7, 2025
@glasstiger
Copy link
Copy Markdown
Contributor

[PR Coverage check]

😍 pass : 310 / 332 (93.37%)

file detail

path covered line new line coverage
🔵 io/questdb/cairo/DefaultCairoConfiguration.java 0 2 00.00%
🔵 io/questdb/cairo/mv/NoOpMatViewStateStore.java 0 1 00.00%
🔵 io/questdb/cairo/mv/MatViewTimerJob.java 58 66 87.88%
🔵 io/questdb/cairo/mv/MatViewRefreshJob.java 131 142 92.25%
🔵 io/questdb/cairo/wal/WalPurgeJob.java 8 8 100.00%
🔵 io/questdb/cairo/mv/TimeZoneIntervalIterator.java 1 1 100.00%
🔵 io/questdb/cairo/wal/WalEventWriter.java 6 6 100.00%
🔵 io/questdb/PropServerConfiguration.java 6 6 100.00%
🔵 io/questdb/cairo/mv/MatViewState.java 32 32 100.00%
🔵 io/questdb/cairo/mv/SampleByIntervalIterator.java 6 6 100.00%
🔵 io/questdb/cairo/mv/MatViewStateStoreImpl.java 7 7 100.00%
🔵 io/questdb/cairo/mv/MatViewStateReader.java 22 22 100.00%
🔵 io/questdb/PropertyKey.java 2 2 100.00%
🔵 io/questdb/cairo/wal/ApplyWal2TableJob.java 4 4 100.00%
🔵 io/questdb/cairo/mv/FixedOffsetIntervalIterator.java 1 1 100.00%
🔵 io/questdb/cairo/CairoConfigurationWrapper.java 4 4 100.00%
🔵 io/questdb/cairo/mv/MatViewGraph.java 11 11 100.00%
🔵 io/questdb/cairo/wal/WalEventCursor.java 11 11 100.00%

@bluestreak01 bluestreak01 merged commit fb3406d into master Jul 7, 2025
34 checks passed
@bluestreak01 bluestreak01 deleted the puzpuzpuz_mat_view_wal_purge branch July 7, 2025 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Incorrect or unexpected behavior SQL Issues or changes relating to SQL execution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants