YR created HBASE-29216:
--------------------------

             Summary: Recovered replication stuck ,  when enabled 
“hbase.separate.oldlogdir.by.regionserver” 
                 Key: HBASE-29216
                 URL: https://issues.apache.org/jira/browse/HBASE-29216
             Project: HBase
          Issue Type: Bug
          Components: regionserver
            Reporter: YR


Recovered replication stuck ,  when enabled 
“hbase.separate.oldlogdir.by.regionserver” 


The WAL location cannot be found after the configuration is enabled. 


The execution logic looks like this
1.  Set “hbase.separate.oldlogdir.by.regionserver”  to enabled 
2. Restart the RegionServer, the  "write a head log"  will from 
*/hbase/WALs/servername/{wal-filename} * moves to 
*/hbase/oldWALs/servername/{wal-filename}  
*
3. WALEntryStream will find archive logs using 
AbstractFSWALProvider.findArchivedLog 

To solve this problem, we can try to improve the findArchiveLog method

Some codes

{code:java}
// HRegionServer.java   
private void shutdownWAL(final boolean close) {
    if (this.walFactory != null) {
      try {
        if (close) {  
          walFactory.close();  // here will move wals to oldwals
        } else {
          walFactory.shutdown();
        }
      } catch (Throwable e) {
        e = e instanceof RemoteException ? ((RemoteException) 
e).unwrapRemoteException() : e;
        LOG.error("Shutdown / close of WAL failed: " + e);
        LOG.debug("Shutdown / close exception details:", e);
      }
    }
  }
{code}



{code:java}
// AbstractFSWALProvider.java:450
 public static Path findArchivedLog(Path path, Configuration conf) throws 
IOException {
    // Here will be return , stuck the replication
    if (path.toString().contains(HConstants.HREGION_OLDLOGDIR_NAME)) {
      return null;
    }
    Path walRootDir = CommonFSUtils.getWALRootDir(conf);
    FileSystem fs = path.getFileSystem(conf);
    // Try finding the log in old dir
    Path oldLogDir = new Path(walRootDir, HConstants.HREGION_OLDLOGDIR_NAME);
    Path archivedLogLocation = new Path(oldLogDir, path.getName());
    if (fs.exists(archivedLogLocation)) {
      LOG.info("Log " + path + " was moved to " + archivedLogLocation);
      return archivedLogLocation;
    }

    ServerName serverName = getServerNameFromWALDirectoryName(path);
    if (serverName == null) {
      LOG.warn("Can not extract server name from path {}, "
        + "give up searching the separated old log dir", path);
      return null;
    }
    // Try finding the log in separate old log dir
    oldLogDir = new Path(walRootDir, new 
StringBuilder(HConstants.HREGION_OLDLOGDIR_NAME)
      .append(Path.SEPARATOR).append(serverName.getServerName()).toString());
    archivedLogLocation = new Path(oldLogDir, path.getName());
    if (fs.exists(archivedLogLocation)) {
      LOG.info("Log " + path + " was moved to " + archivedLogLocation);
      return archivedLogLocation;
    }
    LOG.error("Couldn't locate log: " + path);
    return null;
  }
{code}





--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to