What should I do if the client crashes during HDFS writing? (lease reinstatement)

  When the client crashes, the lease cannot be renewed periodically, and the namenode can perceive it.

  When the client exits abnormally during the data writing process, different copies of the same data block may exist in an inconsistent state. Select a copy as the primary data node, coordinate other data nodes, and restore the data block to their minimum length. An important mechanism for failure recovery in HDFS when data block recovery cooperates with lease recovery.

  Lease recovery algorithm:

  1.NameNode finds lease information.
  2. For each file f in the client lease, let b be the last block of f, and do the following:
  a. Get the list of datanodes where b is located.
  b. Let one of the datanodes be the primarydatanode p.
  c. p gets the latest timestamp from the namenode.
  d. p obtains block information from each datanode.
  e. p calculates the minimum block length.
  f. p updates the datanode with a valid timestamp with the smallest block length and the latest timestamp.
  g. p notifies the namenode to update the result.
  h.namenode updates BlockInfo.
  i.namenode deletes f from the lease. If all files in the lease have been deleted at this time, the lease will be deleted.
  j.namenode submits the modified EditLog.
  k. When the client recovers, it communicates with the namenode again. At this time, the lease of the namenode has been deleted, and the client will continue to write in the append mode. 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325301648&siteId=291194637