virajjasani commented on code in PR #2658:
URL: https://github.com/apache/phoenix/pull/2658#discussion_r4507567624
##########
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);
+ }
+
+ /**
+ * Returns the timestamp of the last CDC event that the consumer applies to
the index. An EVENTUAL
+ * index gets all events. After a switch from EVENTUAL to STRONG, a client
with an old cache can
+ * send EVENTUAL maintainers for up to UPDATE_CACHE_FREQUENCY. Thus the
consumer applies events up
+ * to the index LAST_DDL_TIMESTAMP, plus that time, plus a grace period.
Writers also maintain the
+ * index synchronously in this period, and the replay writes the same cells
again.
+ * @return the cutoff timestamp, or {@link Long#MIN_VALUE} when the consumer
does not maintain the
+ * index.
+ */
+ static long getApplyCutoff(PTable dataTable, PTable index) {
+ IndexConsistency consistency = index.getIndexConsistency();
+ if (consistency != null && consistency.isAsynchronous()) {
+ return Long.MAX_VALUE;
+ }
+ Long lastDDLTimestamp = index.getLastDDLTimestamp();
+ if (
+ lastDDLTimestamp == null || index.getIndexType() ==
PTable.IndexType.LOCAL
+ || CDCUtil.isCDCIndex(index)
+ ) {
+ return Long.MIN_VALUE;
+ }
+ long cacheLag = Math.max(dataTable.getUpdateCacheFrequency(),
index.getUpdateCacheFrequency());
Review Comment:
All indexes are always expected to use data table's updateCacheFrequency, so
we don't need max() here. This will work fine:
```
long cacheLag = dataTable.getUpdateCacheFrequency();
```
--
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]