- private synchronized void blankTransaction() {
- // create transaction
- ObjectName tx = configRegistry.beginConfig();
- CommitStatus commitStatus = configRegistry.commitConfig(tx);
- logger.debug("Committed blank transaction with status {}", commitStatus);
+ private void blankTransactionAsync() {
+ txExecutor.execute(this::blankTransactionSync);
+ }
+
+ void blankTransactionSync() {
+ // race condition check: config-persister might push new configuration while
+ // server is starting up.
+ ConflictingVersionException lastException = null;
+ for (int i = 0; i < maxAttempts; i++) {
+ try {
+ // create transaction
+ CommitStatus commitStatus = blankTransaction.hit();
+ LOG.debug("Committed blank transaction with status {}", commitStatus);
+ return;
+ } catch (final ConflictingVersionException e) {
+ lastException = e;
+ try {
+ Thread.sleep(1000);
+ } catch (final InterruptedException interruptedException) {
+ Thread.currentThread().interrupt();
+ LOG.debug("blankTransactionSync was interrupted");
+ return;
+ }
+ } catch (final ValidationException e) {
+ LOG.error("Validation exception while running blank transaction indicates programming error", e);
+ }
+ }
+
+ LOG.error("Maximal number of attempts reached and still cannot get optimistic lock from config manager",
+ lastException);