Skip to content

Commit 0cf9128

Browse files
committed
HDFS-16513. [SBN read] Observer Namenode does not trigger the edits rolling of active Namenode
1 parent 62d59e5 commit 0cf9128

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1938,6 +1938,14 @@ public boolean isInStandbyState() {
19381938
HAServiceState.OBSERVER == haContext.getState().getServiceState();
19391939
}
19401940

1941+
public boolean isInObserverState() {
1942+
if (haContext == null || haContext.getState() == null) {
1943+
return haEnabled;
1944+
}
1945+
1946+
return HAServiceState.OBSERVER == haContext.getState().getServiceState();
1947+
}
1948+
19411949
/**
19421950
* return a list of blocks & their locations on {@code datanode} whose
19431951
* total size is {@code size}

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/ha/EditLogTailer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ private void doWork() {
505505
// read any more transactions since the last time a roll was
506506
// triggered.
507507
boolean triggeredLogRoll = false;
508-
if (tooLongSinceLastLoad() &&
508+
if (!namesystem.isInObserverState() && tooLongSinceLastLoad() &&
509509
lastRollTriggerTxId < lastLoadedTxnId) {
510510
triggerActiveLogRoll();
511511
triggeredLogRoll = true;

0 commit comments

Comments
 (0)