summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2020-10-23 16:24:43 +0200
committerGitHub <noreply@github.com>2020-10-23 16:24:43 +0200
commit62592a05a61bf3fa855fa67dc6dda0f06bfba205 (patch)
treec5349780eb813d2db39c615e105fac08007dabbc
parent17baf9ce98dd6aebcd186f53b98b20b83393ce3b (diff)
parente0b43fe70ec272d269da74514500b3588ffec51b (diff)
Merge pull request #15021 from vespa-engine/jonmv/remove-logging-in-doc-v1-on-errors
Destroy async session during shutdown
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java
index 5408d64f0af..4fdac7b584a 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/DocumentV1ApiHandler.java
@@ -244,13 +244,19 @@ public class DocumentV1ApiHandler extends AbstractRequestHandler {
@Override
public void destroy() {
executor.shutdown();
+ Instant doom = clock.instant().plus(Duration.ofSeconds(20));
+ while ( ! operations.isEmpty() && clock.instant().isBefore(doom))
+ dispatchEnqueued();
+
+ if ( ! operations.isEmpty())
+ log.log(WARNING, "Failed to empty request queue before shutdown timeout — " + operations.size() + " requests left");
+
+ asyncSession.destroy();
visits.values().forEach(VisitorSession::destroy);
+
try {
- if ( ! executor.awaitTermination(10, TimeUnit.SECONDS)) {
+ if ( ! executor.awaitTermination(Duration.between(clock.instant(), doom).toMillis(), TimeUnit.MILLISECONDS))
executor.shutdownNow();
- if ( ! executor.awaitTermination(10, TimeUnit.SECONDS))
- log.log(WARNING, "Failed shutting down /document/v1 executor within 20 seconds");
- }
}
catch (InterruptedException e) {
log.log(WARNING, "Interrupted waiting for /document/v1 executor to shut down");