Merge branch 'stable-3.11' * stable-3.11: Do not throw an exception when refs/multi-site/version lock fails Reformat with GJF 1.24.0 Change-Id: I7220719b6bbebd93d3e57f7a10967f3d97ee6879
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/Configuration.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/Configuration.java index e3f53ab..0ae4738 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/multisite/Configuration.java +++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/Configuration.java
@@ -213,7 +213,8 @@ if (replicationConfig.getBoolean("gerrit", "replicateOnStartup", false)) { return Arrays.asList( new Message( - "Invalid replication.config: gerrit.replicateOnStartup has to be set to 'false' for multi-site setups")); + "Invalid replication.config: gerrit.replicateOnStartup has to be set to 'false' for" + + " multi-site setups")); } return Collections.emptyList(); }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexingHandlerWithRetries.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexingHandlerWithRetries.java index d135e39..8cf0553 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexingHandlerWithRetries.java +++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexingHandlerWithRetries.java
@@ -79,7 +79,8 @@ indexName()); if (!indexingRetryTaskMap.remove(id, retry)) { log.debug( - "{} {} not removed from retry map because of racy addition of a new retry indexing retry"); + "{} {} not removed from retry map because of racy addition of a new retry indexing" + + " retry"); } return false; } @@ -111,7 +112,8 @@ if (indexingRetryTaskMap.put(id, retry) != null) { indexOnce.accept(id); log.debug( - "Skipping indexing because there is already a running task for the specified id. Index name: {}, task id: {}", + "Skipping indexing because there is already a running task for the specified id. Index" + + " name: {}, task id: {}", indexName(), id); return; @@ -144,7 +146,8 @@ } if (!indexingRetryTaskMap.remove(id, retry)) { log.debug( - "{} {} not removed from retry map because of racy addition of a new retry indexing retry"); + "{} {} not removed from retry map because of racy addition of a new retry indexing" + + " retry"); } }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java index 57c7cd1..f3f7534 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java +++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java
@@ -182,7 +182,8 @@ } catch (IOException e) { log.warn( String.format( - "Cannot check consistency for change %s, current patchset commit %s. Assuming change is consistent", + "Cannot check consistency for change %s, current patchset commit %s. Assuming change" + + " is consistent", changeId, currentPatchSetCommitId.getName()), e); }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImpl.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImpl.java index e9e40f3..67104ba 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImpl.java +++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImpl.java
@@ -54,7 +54,8 @@ if (event.sha1 == null) { logger.atWarning().log( - "Event for group '%s' does not contain sha1, consider group up-to-date for compatibility.", + "Event for group '%s' does not contain sha1, consider group up-to-date for" + + " compatibility.", groupUUID); return true; }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java index 03e0a6e..d67492d 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java +++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationFetchFilter.java
@@ -72,8 +72,8 @@ localRefOid.ifPresent( oid -> repLog.info( - "{}:{}={} is already up-to-date with the shared-refdb and thus will NOT BE" - + " fetched", + "{}:{}={} is already up-to-date with the shared-refdb and thus will NOT" + + " BE fetched", projectName, ref, oid.getName()));
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectVersionRefUpdateImpl.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectVersionRefUpdateImpl.java index adbef1b..e4f133b 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectVersionRefUpdateImpl.java +++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectVersionRefUpdateImpl.java
@@ -86,12 +86,15 @@ Project.NameKey projectNameKey = Project.nameKey(refUpdatedEvent.getProjectName()); long newVersion = getCurrentGlobalVersionNumber(); - RefUpdate newProjectVersionRefUpdate = updateLocalProjectVersion(projectNameKey, newVersion); + Optional<RefUpdate> newProjectVersionRefUpdate = + updateLocalProjectVersion(projectNameKey, newVersion); - verLogger.log(projectNameKey, newVersion, 0L); + if (newProjectVersionRefUpdate.isPresent()) { + verLogger.log(projectNameKey, newVersion, 0L); - if (updateSharedProjectVersion(projectNameKey, newVersion)) { - gitReferenceUpdated.fire(projectNameKey, newProjectVersionRefUpdate, null); + if (updateSharedProjectVersion(projectNameKey, newVersion)) { + gitReferenceUpdated.fire(projectNameKey, newProjectVersionRefUpdate.get(), null); + } } } catch (LocalProjectVersionUpdateException | SharedProjectVersionUpdateException e) { logger.atSevere().withCause(e).log( @@ -127,7 +130,8 @@ try { if (sharedVersion.isPresent() && sharedVersion.get() >= newVersion) { logger.atWarning().log( - "NOT Updating project %s value=%d in shared ref-db because is more recent than the local value=%d", + "NOT Updating project %s value=%d in shared ref-db because is more recent than the" + + " local value=%d", projectNameKey.get(), newVersion, sharedVersion.get()); return false; } @@ -140,7 +144,8 @@ } catch (GlobalRefDbSystemError refDbSystemError) { String message = String.format( - "Error while updating shared project value for %s. Current value %s, new value: %s. Error: %s", + "Error while updating shared project value for %s. Current value %s, new value: %s." + + " Error: %s", projectNameKey.get(), sharedVersion.map(Object::toString).orElse(null), newVersion, @@ -159,8 +164,8 @@ } } catch (NoSuchMethodError e) { logger.atSevere().log( - "Global-refdb library is outdated and is not supporting " - + "'put' method, update global-refdb to the newest version. Falling back to 'compareAndPut'"); + "Global-refdb library is outdated and is not supporting 'put' method, update global-refdb" + + " to the newest version. Falling back to 'compareAndPut'"); } sharedRefDb.compareAndPut( @@ -229,7 +234,8 @@ } @SuppressWarnings("FloggerLogString") - private RefUpdate updateLocalProjectVersion(Project.NameKey projectNameKey, long newVersionNumber) + private Optional<RefUpdate> updateLocalProjectVersion( + Project.NameKey projectNameKey, long newVersionNumber) throws LocalProjectVersionUpdateException { logger.atFine().log( "Updating local version for project %s with version %d", @@ -238,6 +244,13 @@ Repository repository = gitRepositoryManager.openRepository(projectNameKey)) { RefUpdate refUpdate = getProjectVersionRefUpdate(repository, newVersionNumber); RefUpdate.Result result = refUpdate.update(); + if (RefUpdate.Result.LOCK_FAILURE.equals(result)) { + logger.atFine().log( + "RefUpdate LOCK_FAILURE for refs/multi-site/version on project=%s, version=%d", + projectNameKey.get(), newVersionNumber); + return Optional.empty(); + } + if (!isSuccessful(result)) { String message = String.format( @@ -247,7 +260,7 @@ throw new LocalProjectVersionUpdateException(message); } - return refUpdate; + return Optional.of(refUpdate); } catch (IOException e) { String message = "Cannot create versioning command for " + projectNameKey.get(); logger.atSevere().withCause(e).log(message);