Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Fixed
-
0.94.0
-
None
-
Reviewed
Description
It is a big problem we found in 0.94, and you could reproduce the problem in Trunk using the test case I uploaded.
When we do compaction, we will use region.getSmallestReadPoint() to keep MVCC for opened scanners;
However,It will make data mistake after majorCompaction because we will skip delete type KV but keep the put type kv in the compacted storefile.
The following is the reason from code:
In StoreFileScanner, enforceMVCC is false when compaction, so we could read the delete type KV,
However, we will skip this delete type KV in ScanQueryMatcher because following code
if (kv.isDelete()) { ... if (includeDeleteMarker && kv.getMemstoreTS() <= maxReadPointToTrackVersions) { System.out.println("add deletes,maxReadPointToTrackVersions=" + maxReadPointToTrackVersions); this.deletes.add(bytes, offset, qualLength, timestamp, type); } ... }
Here maxReadPointToTrackVersions = region.getSmallestReadPoint();
and kv.getMemstoreTS() > maxReadPointToTrackVersions
So we won't add this to DeleteTracker.
Why test case passed if remove the line MultiVersionConsistencyControl.setThreadReadPoint(smallestReadPoint);
Because in the StoreFileScanner#skipKVsNewerThanReadpoint
if (cur.getMemstoreTS() <= readPoint) {
cur.setMemstoreTS(0);
}
So if we remove the line MultiVersionConsistencyControl.setThreadReadPoint(smallestReadPoint);
Here readPoint is LONG.MAX_VALUE, we will set memStore ts as 0, so we will add it to DeleteTracker in ScanQueryMatcher
Solution:
We use smallestReadPoint of region when compaction to keep MVCC for OPENED scanner, So we should retain delete type kv in output in the case(Already deleted KV is retained in output to make old opened scanner could read this KV) even if it is a majorcompaction.