apurtell commented on code in PR #2658:
URL: https://github.com/apache/phoenix/pull/2658#discussion_r4508387551


##########
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:
   Did a clamp between UCF, 60s min, and 15m max. We go with UCF unless it is < 
60s, in which case it is 60s, or if it is > 15m we use 15m.  This works for us 
for ALWAYS (we will get 60s) and allows for people to go out longer if they 
don't mind or even want longer windows. 



-- 
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]

Reply via email to