apurtell commented on code in PR #2658:
URL: https://github.com/apache/phoenix/pull/2658#discussion_r4507808467
##########
phoenix-core-server/src/main/java/org/apache/phoenix/hbase/index/IndexCDCConsumer.java:
##########
@@ -319,8 +326,42 @@ private PTable getDataTable(PhoenixConnection conn) throws
SQLException {
return dataTable;
}
+ /**
+ * Reads the data table definition from SYSTEM.CATALOG. The metadata cache
of the region server
+ * can keep an old definition after an ALTER, for example when the region
moves to this server.
+ */
private void refreshDataTableCache(PhoenixConnection conn) throws
SQLException {
- cachedDataTable = conn.getTable(dataTableName);
+ cachedDataTable = conn.getTableNoCache(conn.getTenantId(), dataTableName);
+ }
Review Comment:
I checked this, and I don't think UCF refreshes the PTable that the consumer
uses.
getDataTable() calls PhoenixConnection.getTable(String), which only reads
the cache. It makes an RPC only on a cache miss, and its javadoc says it
ignores UCF (PHOENIX-4475). Nothing else in the consumer resolves the data
table through updateCache with UCF. The CDC query resolves the CDC object and
the CDC index under UCF. But the optimizer then gets the data table with
connection.getTable(dataTableName). Refreshing the CDC index only swaps that
one index into the cached parent (PMetaDataImpl.addTable). An ALTER of another
index does not change the CDC index, so the parent's other indexes keep their
old consistency.
Nothing invalidates the region server cache. The ALTER writes SYSTEM.CATALOG
with UPSERTs and clears only the endpoint cache. So a region server can keep
the old definition indefinitely.
A UCF-bounded refresh would still not be safe for STRONG→EVENTUAL. Writers
and the consumer refresh at different times. A writer that sees EVENTUAL first
stops maintaining the index synchronously. A consumer that still sees STRONG
skips those events and moves its tracker past them, so the index misses those
updates permanently. The other direction (EVENTUAL→STRONG with an old view)
only adds duplicate writes, which do no harm.
I have kept the read in the batch update, but scoped it down to happen much
less often. Now the consumer reads the definition only when a batch has events
newer than its last read, and at most once per new
`phoenix.index.cdc.consumer.metadata.refresh.interval.ms` (default 5 s). Events
newer than the last read stay in the CDC queue until the next read. An old
definition can delay an event but never skip it. Idle regions make no
SYSTEM.CATALOG reads. Busy regions make at most one read per interval, down
from one per batch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]