Files
gerrit/java/com/google/gerrit/server
Edwin Kempin fc417a149b Extract detection of LOCK_FAILURE errors into an ExceptionHook
ExceptionHook allows implementors to detect and handle exceptions that
are caused by temporary errors, and hence should cause a retry of the
failed operation. We should make use of it to detect and handle
LOCK_FAILURE errors. This way the code to detect LOCK_FAILURE is in a
single place instead of in RetryHelper for change actions and in
RestApiServlet for REST requests. As it turns out the detection of
LOCK_FAILURE errors in these places was inconsistent, RetryHelper did
unwrapping for UpdateException and StorageException, while
RestApiServlet did unwrapping only for UpdateException. Due to this some
LOCK_FAILURE errors such as [1] didn't trigger request retries.

[1]
com.google.gerrit.exceptions.StorageException: Star change 133855 for account 6003 failed
        at com.google.gerrit.server.StarredChangesUtil.star(StarredChangesUtil.java:234)
        at com.google.gerrit.server.restapi.account.StarredChanges$Create.apply(StarredChanges.java:133)
        at com.google.gerrit.server.restapi.account.StarredChanges$Create.apply(StarredChanges.java:97)
        at com.google.gerrit.httpd.restapi.RestApiServlet.lambda$invokeRestCollectionCreateViewWithRetry$5(RestApiServlet.java:758)
        at com.github.rholder.retry.AttemptTimeLimiters$NoAttemptTimeLimit.call(AttemptTimeLimiters.java:78)
        at com.github.rholder.retry.Retryer.call(Retryer.java:160)
        at com.google.gerrit.server.update.RetryHelper.executeWithTimeoutCount(RetryHelper.java:417)
        at com.google.gerrit.server.update.RetryHelper.executeWithAttemptAndTimeoutCount(RetryHelper.java:368)
        at com.google.gerrit.server.update.RetryHelper.execute(RetryHelper.java:271)
        at com.google.gerrit.httpd.restapi.RestApiServlet.invokeRestEndpointWithRetry(RestApiServlet.java:820)
        at com.google.gerrit.httpd.restapi.RestApiServlet.invokeRestCollectionCreateViewWithRetry(RestApiServlet.java:753)
        at com.google.gerrit.httpd.restapi.RestApiServlet.service(RestApiServlet.java:527)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
        ...
Caused by: com.google.gerrit.git.LockFailureException: Update star labels on ref refs/starred-changes/55/133855/6003 failed
        at com.google.gerrit.server.StarredChangesUtil.updateLabels(StarredChangesUtil.java:484)
        at com.google.gerrit.server.StarredChangesUtil.star(StarredChangesUtil.java:227)
        ... 208 more

Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: Ia7162ee5441d72b9ed32ff5b145b93d8626713c6
2019-11-21 11:25:39 +01:00
..
2019-11-15 00:27:29 -08:00
2019-11-19 14:24:04 -08:00
2019-11-18 15:03:35 -08:00