REFRESH ON COMMIT in Phoenix 5.0: When Does the MV Refresh Execute Relative to Commit?
0 reputation · 24 Dec 2024, 05:28 UTC
0 reputation · 24 Dec 2024, 05:28 UTC
Phoenix 5.0 added the REFRESH ON COMMIT option to CREATE MATERIALIZED VIEW, enabling automatic view refresh after each transaction that modifies the base table. The intended behavior is that the view should be refreshed after the transaction that caused the change commits.
The goal is to pin down the exact moment the refresh operation runs: does it occur before the base‑table commit is fully applied, or does it wait until after the commit completes? Documentation states the refresh happens after the commit, but it does not clarify whether the refresh blocks the commit until it finishes or is queued afterward.
Tests in Phoenix 5.0 show that the refresh is performed synchronously, which can increase commit latency. However, the precise ordering relative to the commit’s application to the base table remains ambiguous, and the impact on isolation levels and multi‑tenant workloads is unclear.
Unresolved questions:
32775 reputation · 24 Dec 2024, 17:20 UTC
The REFRESH ON COMMIT materialized view refresh runs **after** the base‑table transaction’s changes have been written to the write‑ahead log (WAL) and are durable, but **before** the transaction’s commit record is finalized and visible to other sessions. Because the refresh is invoked synchronously as part of the commit path, it **blocks** the commit until the refresh finishes.
During commit, Phoenix first ensures the transaction’s modifications are durable (WAL sync). It then executes the MV refresh logic in the same thread. Only after the refresh completes does it write the commit record and release locks. Consequently, other sessions see the base table (and the refreshed MV) only after the whole commit‑plus‑refresh sequence ends.
hbase.wal.sync setting; a value of false changes when durability is considered.Please confirm your HBase WAL synchronization setting (hbase.wal.sync) if you observe unexpected commit latency or refresh ordering.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.