HDFS-7923 ,to rate-limit DN block report, DN will ask for a full block lease id from active NN before sending full block to NN. Then DN will send full block report together with lease id. If the lease id is invalid, NN will reject the full block report and log "not in the pending set".
In a case when DN is doing full block reporting while NN is restarted. It happens that DN will later send a full block report with lease id ,acquired from previous NN instance, which is invalid to the new NN instance. Though DN recognized the new NN instance by heartbeat and reregister itself, it did not reset the lease id from previous instance.
The issuse may cause DNs to temporarily go dead, making it unsafe to restart NN especially in hadoop cluster which has large amount of DNs.
HDFS-12914 reported the issue without any clues why it occurred and remain unsolved.
To make it clear, look at code below. We take it from method offerService of class BPServiceActor. We eliminate some code to focus on current issue. fullBlockReportLeaseId is a local variable to hold lease id from NN. Exceptions will occur at blockReport call when NN restarting, which will be caught by catch block in while loop. Thus fullBlockReportLeaseId will not be set to 0. After NN restarted, DN will send full block report which will be rejected by the new NN instance. DN will never send full block report until the next full block report schedule, about an hour later.
Solution is simple, just reset fullBlockReportLeaseId to 0 after any exception or after registering to NN. Thus it will ask for a valid fullBlockReportLeaseId from new NN instance.