kadirozde commented on code in PR #1531:
URL: https://github.com/apache/phoenix/pull/1531#discussion_r1072733289


##########
phoenix-core/src/main/java/org/apache/phoenix/coprocessor/UncoveredIndexRegionScanner.java:
##########
@@ -244,20 +256,62 @@ protected boolean scanIndexTableRows(List<Cell> result,
         return scanIndexTableRows(result, startTime, null, 0);
     }
 
-    private boolean getNextCoveredIndexRow(List<Cell> result) {
+    private boolean verifyIndexRowAndRepairIfNecessary(Result dataRow, byte[] 
indexRowKey, long ts) throws IOException {
+        Put put = new Put(dataRow.getRow());
+        for (Cell cell : dataRow.rawCells()) {
+            put.add(cell);
+        }
+        if (indexMaintainer.checkIndexRow(indexRowKey, put)) {
+            if (IndexUtil.getMaxTimestamp(put) != ts) {
+                Mutation[] mutations;
+                Put indexPut = new Put(indexRowKey);
+                indexPut.addColumn(emptyCF, emptyCQ, ts, 
QueryConstants.VERIFIED_BYTES);
+                if ((EnvironmentEdgeManager.currentTimeMillis() - ts) > 
ageThreshold) {
+                    Delete indexDelete = 
indexMaintainer.buildRowDeleteMutation(indexRowKey,

Review Comment:
   We need make sure that index and data table rows have the same timestamp for 
time range queries. That is way we need to delete the index row version with 
incorrect timestamps. Please note as part of the repair operation, we also 
insert the correct version. During the write path, we update the index row 
before the data row. If the data row update fails, the index row timestamp will 
be higher than the data row timestamp. If compaction happens before the index 
row is read, then the correct version would be removed by compaction. That is 
the reason we add the correct version during repair. 



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