Skip to content

Commit

Permalink
HBASE-27303 Unnecessary replication to secondary region replicas shou…
Browse files Browse the repository at this point in the history
…ld avoid when WAL.sync throws Exception (#4707)

Signed-off-by: Duo Zhang <[email protected]>
  • Loading branch information
comnetwork authored Aug 24, 2022
1 parent 950ad8d commit a0481d1
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8046,11 +8046,17 @@ private WriteEntry doWALAppend(WALEdit walEdit, BatchOperation<?> batchOp,
try {
long txid = this.wal.appendData(this.getRegionInfo(), walKey, walEdit);
WriteEntry writeEntry = walKey.getWriteEntry();
this.attachRegionReplicationInWALAppend(batchOp, miniBatchOp, walKey, walEdit, writeEntry);
// Call sync on our edit.
if (txid != 0) {
sync(txid, batchOp.durability);
}
/**
* If above {@link HRegion#sync} throws Exception, the RegionServer should be aborted and
* following {@link BatchOperation#writeMiniBatchOperationsToMemStore} will not be executed,
* so there is no need to replicate to secondary replica, for this reason here we attach the
* region replication action after the {@link HRegion#sync} is successful.
*/
this.attachRegionReplicationInWALAppend(batchOp, miniBatchOp, walKey, walEdit, writeEntry);
return writeEntry;
} catch (IOException ioe) {
if (walKey.getWriteEntry() != null) {
Expand Down

0 comments on commit a0481d1

Please sign in to comment.