virajjasani commented on code in PR #5603:
URL: https://github.com/apache/hbase/pull/5603#discussion_r1443273449


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/TakeSnapshotHandler.java:
##########
@@ -129,6 +132,8 @@ public TakeSnapshotHandler(SnapshotDescription snapshot, 
final MasterServices ma
       "Taking " + snapshot.getType() + " snapshot on table: " + snapshotTable, 
false, true);
     this.snapshotManifest =
       SnapshotManifest.create(conf, rootFs, workingDir, snapshot, monitor, 
status);
+    this.lockAcquireTimeoutMs =
+      conf.getLong(HBASE_SNAPSHOT_MASTER_LOCK_ACQUIRE_TIMEOUT, 5 * 60 * 1000L);

Review Comment:
   Sounds good, will make this change.



##########
hbase-server/src/main/java/org/apache/hadoop/hbase/master/snapshot/TakeSnapshotHandler.java:
##########
@@ -147,12 +152,16 @@ private TableDescriptor loadTableDescriptor() throws 
IOException {
   public TakeSnapshotHandler prepare() throws Exception {
     super.prepare();
     // after this, you should ensure to release this lock in case of exceptions
-    this.tableLock.acquire();
-    try {
-      this.htd = loadTableDescriptor(); // check that .tableinfo is present
-    } catch (Exception e) {
-      this.tableLock.release();
-      throw e;
+    if (this.tableLock.tryAcquire(this.lockAcquireTimeoutMs)) {
+      try {
+        this.htd = loadTableDescriptor(); // check that .tableinfo is present
+      } catch (Exception e) {
+        this.tableLock.release();
+        throw e;
+      }
+    } else {
+      LOG.error("Master lock could not be acquired in {} ms", 
lockAcquireTimeoutMs);
+      throw new IOException("Master lock could not be acquired");

Review Comment:
   Actually, regardless of the Exception type here, it does eventually throw 
`SnapshotCreationException`:
   
   ```
       try {
         handler.prepare();
         this.executorService.submit(handler);
         this.snapshotHandlers.put(TableName.valueOf(snapshot.getTable()), 
handler);
       } catch (Exception e) {
         // cleanup the working directory by trying to delete it from the fs.
         Path workingDir = 
SnapshotDescriptionUtils.getWorkingSnapshotDir(snapshot, rootDir,
           master.getConfiguration());
         FileSystem workingDirFs = 
workingDir.getFileSystem(master.getConfiguration());
         try {
           if (!workingDirFs.delete(workingDir, true)) {
             LOG.error("Couldn't delete working directory (" + workingDir + " 
for snapshot:"
               + ClientSnapshotDescriptionUtils.toString(snapshot));
           }
         } catch (IOException e1) {
           LOG.error("Couldn't delete working directory (" + workingDir + " for 
snapshot:"
             + ClientSnapshotDescriptionUtils.toString(snapshot));
         }
         // fail the snapshot
         throw new SnapshotCreationException("Could not build snapshot 
handler", e,
           ProtobufUtil.createSnapshotDesc(snapshot));
       }
   ```
   
   but sure i can still make it throw DoNotRetryIOException.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to