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 we refresh the PTable that the CDC
consumer uses according to UCF. An ALTER writes SYSTEM.CATALOG with UPSERTs and
clears only the endpoint cache. So a regionserver can have the old definition
cached and we need to look at it proactively.
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]