Repository navigation
HubSpot Edit (not yet upstreamed): Preserve WAL edit order - #215
Conversation
| } | ||
|
|
||
| private MapReduceExtendedCell wrapCell(ExtendedCell cell, int order) { | ||
| if (this.diskBasedSortingEnabled) { |
There was a problem hiding this comment.
This check here (and in other places in the code) ensures this order preservation is only on for incremental backup. That being said -- I wonder if we also want to think about implementing for our WAL replay logic in the restore process
| TreeSet<OrderPreservedMapReduceExtendedCell> cells = | ||
| new TreeSet<>(Comparator.comparingInt(OrderPreservedMapReduceExtendedCell::getOrder)); |
There was a problem hiding this comment.
I was looking through the code with claude, and it reckons multiple cells with the same timestamp could get erroneously deduplicated here. I'm not sure — something to investigate before we ship. It recommended something like this instead:
TreeSet<OrderPreservedMapReduceExtendedCell> cells = new TreeSet<>(
Comparator.<OrderPreservedMapReduceExtendedCell>comparingInt(
OrderPreservedMapReduceExtendedCell::getOrder)
.thenComparingLong(OrderPreservedMapReduceExtendedCell::getSequenceId)
.thenComparing(CellComparator.getInstance())
);There was a problem hiding this comment.
This is a good point - I can switch off of using a Set
|
|
||
| for (OrderPreservedMapReduceExtendedCell cell : values) { | ||
| OrderPreservedMapReduceExtendedCell copy = | ||
| new OrderPreservedMapReduceExtendedCell(cell.deepClone(), cell.getOrder()); |
There was a problem hiding this comment.
We need to deep clone now b/c the Iterator can re-use these values
)" This reverts commit 3ac3d23.
We've discovered that inter-put edits lose their ordering when we convert WAL files to HFiles using a MR job. The reducer doesn't provide any ordering guarantees of the values being sorted lexigraphically. That means if the client does
Even though their "latest" edit for CF + CQ is "zzz", a snapshot scan over an incremental backup (and if we restore the table prior to the next full backup) will return "aaa". When you query HBase, though, it returns "aaa".
This PR aims to address this problem by encoding the ordering into the cell value. This has been branch-deployed and has resolved data inconsistencies when comparing snapshot scans from a full backup vs a modern backup