Improve retry handling when saving FileStoreAttributes fails
- fix handling of interrupts in FileStoreAttributes#saveToConfig - increase retry wait time to 100ms - don't wait after last retry - dont retry if failure is caused by another exception than LockFailedException Change-Id: I108c012717d2bcce71f2c6cb9cf0879de704ebc2 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
cb53db4bff
commit
2d84bb4341
|
@ -430,6 +430,7 @@ localRefIsMissingObjects=Local ref {0} is missing object(s).
|
||||||
localRepository=local repository
|
localRepository=local repository
|
||||||
lockCountMustBeGreaterOrEqual1=lockCount must be >= 1
|
lockCountMustBeGreaterOrEqual1=lockCount must be >= 1
|
||||||
lockError=lock error: {0}
|
lockError=lock error: {0}
|
||||||
|
lockFailedRetry=locking {0} failed after {1} retries
|
||||||
lockOnNotClosed=Lock on {0} not closed.
|
lockOnNotClosed=Lock on {0} not closed.
|
||||||
lockOnNotHeld=Lock on {0} not held.
|
lockOnNotHeld=Lock on {0} not held.
|
||||||
malformedpersonIdentString=Malformed PersonIdent string (no < was found): {0}
|
malformedpersonIdentString=Malformed PersonIdent string (no < was found): {0}
|
||||||
|
|
|
@ -491,6 +491,7 @@ public static JGitText get() {
|
||||||
/***/ public String localRepository;
|
/***/ public String localRepository;
|
||||||
/***/ public String lockCountMustBeGreaterOrEqual1;
|
/***/ public String lockCountMustBeGreaterOrEqual1;
|
||||||
/***/ public String lockError;
|
/***/ public String lockError;
|
||||||
|
/***/ public String lockFailedRetry;
|
||||||
/***/ public String lockOnNotClosed;
|
/***/ public String lockOnNotClosed;
|
||||||
/***/ public String lockOnNotHeld;
|
/***/ public String lockOnNotHeld;
|
||||||
/***/ public String malformedpersonIdentString;
|
/***/ public String malformedpersonIdentString;
|
||||||
|
|
|
@ -580,20 +580,30 @@ private static void saveToConfig(FileStore s,
|
||||||
} catch (LockFailedException e) {
|
} catch (LockFailedException e) {
|
||||||
// race with another thread, wait a bit and try again
|
// race with another thread, wait a bit and try again
|
||||||
try {
|
try {
|
||||||
LOG.warn(MessageFormat.format(JGitText.get().cannotLock,
|
|
||||||
userConfig));
|
|
||||||
retries++;
|
retries++;
|
||||||
Thread.sleep(20);
|
if (retries < max_retries) {
|
||||||
|
Thread.sleep(100);
|
||||||
|
LOG.debug("locking {} failed, retries {}/{}", //$NON-NLS-1$
|
||||||
|
userConfig, Integer.valueOf(retries),
|
||||||
|
Integer.valueOf(max_retries));
|
||||||
|
} else {
|
||||||
|
LOG.warn(MessageFormat.format(
|
||||||
|
JGitText.get().lockFailedRetry, userConfig,
|
||||||
|
Integer.valueOf(retries)));
|
||||||
|
}
|
||||||
} catch (InterruptedException e1) {
|
} catch (InterruptedException e1) {
|
||||||
Thread.interrupted();
|
Thread.currentThread().interrupt();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOG.error(MessageFormat.format(
|
LOG.error(MessageFormat.format(
|
||||||
JGitText.get().cannotSaveConfig, userConfig), e);
|
JGitText.get().cannotSaveConfig, userConfig), e);
|
||||||
|
break;
|
||||||
} catch (ConfigInvalidException e) {
|
} catch (ConfigInvalidException e) {
|
||||||
LOG.error(MessageFormat.format(
|
LOG.error(MessageFormat.format(
|
||||||
JGitText.get().repositoryConfigFileInvalid,
|
JGitText.get().repositoryConfigFileInvalid,
|
||||||
userConfig, e.getMessage()));
|
userConfig, e.getMessage()));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue