From b804a0c4a68a7f493e7941848b2e8858e8d870fa Mon Sep 17 00:00:00 2001 From: Daniel Mitterdorfer Date: Fri, 20 Nov 2015 11:21:56 +0100 Subject: [PATCH] Improve stability of UpdateIT With this commit, we reduce the amount of work that UpdateIT does and add progress logging. Closes #14877 --- .../action/update/TransportUpdateAction.java | 2 ++ .../java/org/elasticsearch/update/UpdateIT.java | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java b/core/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java index 2a639c83ad1..b2d24fef714 100644 --- a/core/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java +++ b/core/src/main/java/org/elasticsearch/action/update/TransportUpdateAction.java @@ -190,6 +190,8 @@ public class TransportUpdateAction extends TransportInstanceSingleOperationActio e = ExceptionsHelper.unwrapCause(e); if (e instanceof VersionConflictEngineException) { if (retryCount < request.retryOnConflict()) { + logger.trace("Retry attempt [{}] of [{}] on version conflict on [{}][{}][{}]", + retryCount + 1, request.retryOnConflict(), request.index(), request.shardId(), request.id()); threadPool.executor(executor()).execute(new ActionRunnable(listener) { @Override protected void doRun() { diff --git a/core/src/test/java/org/elasticsearch/update/UpdateIT.java b/core/src/test/java/org/elasticsearch/update/UpdateIT.java index a197e918c21..a789bb48774 100644 --- a/core/src/test/java/org/elasticsearch/update/UpdateIT.java +++ b/core/src/test/java/org/elasticsearch/update/UpdateIT.java @@ -936,16 +936,19 @@ public class UpdateIT extends ESIntegTestCase { int numberOfThreads = scaledRandomIntBetween(2,5); final CountDownLatch latch = new CountDownLatch(numberOfThreads); final CountDownLatch startLatch = new CountDownLatch(1); - final int numberOfUpdatesPerThread = scaledRandomIntBetween(100, 10000); + final int numberOfUpdatesPerThread = scaledRandomIntBetween(100, 500); final List failures = new CopyOnWriteArrayList<>(); + for (int i = 0; i < numberOfThreads; i++) { Runnable r = new Runnable() { - @Override public void run() { try { startLatch.await(); for (int i = 0; i < numberOfUpdatesPerThread; i++) { + if (i % 100 == 0) { + logger.debug("Client [{}] issued [{}] of [{}] requests", Thread.currentThread().getName(), i, numberOfUpdatesPerThread); + } if (useBulkApi) { UpdateRequestBuilder updateRequestBuilder = client().prepareUpdate(indexOrAlias(), "type1", Integer.toString(i)) .setScript(new Script("field", ScriptService.ScriptType.INLINE, "field_inc", null)) @@ -960,6 +963,12 @@ public class UpdateIT extends ESIntegTestCase { .execute().actionGet(); } } + logger.info("Client [{}] issued all [{}] requests.", Thread.currentThread().getName(), numberOfUpdatesPerThread); + } catch (InterruptedException e) { + // test infrastructure kills long-running tests by interrupting them, thus we handle this case separately + logger.warn("Test was forcefully stopped. Client [{}] may still have outstanding requests.", Thread.currentThread().getName()); + failures.add(e); + Thread.currentThread().interrupt(); } catch (Throwable e) { failures.add(e); } finally { @@ -968,7 +977,9 @@ public class UpdateIT extends ESIntegTestCase { } }; - new Thread(r).start(); + Thread updater = new Thread(r); + updater.setName("UpdateIT-Client-" + i); + updater.start(); } startLatch.countDown(); latch.await();