Skip to content

Commit a0481d1

Browse files
authored
HBASE-27303 Unnecessary replication to secondary region replicas should avoid when WAL.sync throws Exception (#4707)
Signed-off-by: Duo Zhang <zhangduo@apache.org>
1 parent 950ad8d commit a0481d1

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8046,11 +8046,17 @@ private WriteEntry doWALAppend(WALEdit walEdit, BatchOperation<?> batchOp,
80468046
try {
80478047
long txid = this.wal.appendData(this.getRegionInfo(), walKey, walEdit);
80488048
WriteEntry writeEntry = walKey.getWriteEntry();
8049-
this.attachRegionReplicationInWALAppend(batchOp, miniBatchOp, walKey, walEdit, writeEntry);
80508049
// Call sync on our edit.
80518050
if (txid != 0) {
80528051
sync(txid, batchOp.durability);
80538052
}
8053+
/**
8054+
* If above {@link HRegion#sync} throws Exception, the RegionServer should be aborted and
8055+
* following {@link BatchOperation#writeMiniBatchOperationsToMemStore} will not be executed,
8056+
* so there is no need to replicate to secondary replica, for this reason here we attach the
8057+
* region replication action after the {@link HRegion#sync} is successful.
8058+
*/
8059+
this.attachRegionReplicationInWALAppend(batchOp, miniBatchOp, walKey, walEdit, writeEntry);
80548060
return writeEntry;
80558061
} catch (IOException ioe) {
80568062
if (walKey.getWriteEntry() != null) {

0 commit comments

Comments
 (0)