summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-12-20 23:02:14 +0100
committerHarald Musum <musum@verizonmedia.com>2020-12-20 23:02:14 +0100
commit25ee555d9a2290e9fa59d9fe40aae812a6dd3fa6 (patch)
tree3fc427eea10246c092e2a244c25b76e956340f36 /configserver
parentc26ef3801d0db74209931fb713a1e3ff72381273 (diff)
ConstrĂșct SessionCounter once
Creating SessionCounter every time we need the next session is wrong, we might end up getting the same session id for two different deployments, e.g. if they are happening in two different threads or on two different config servers at the same time.
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java4
1 files changed, 3 insertions, 1 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java
index fc0a887cf0e..64b757037d0 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java
@@ -88,6 +88,7 @@ public class SessionRepository {
private final Path sessionsPath;
private final TenantName tenantName;
private final GlobalComponentRegistry componentRegistry;
+ private final SessionCounter sessionCounter;
public SessionRepository(TenantName tenantName,
GlobalComponentRegistry componentRegistry,
@@ -95,6 +96,7 @@ public class SessionRepository {
SessionPreparer sessionPreparer) {
this.tenantName = tenantName;
this.componentRegistry = componentRegistry;
+ sessionCounter = new SessionCounter(componentRegistry.getConfigCurator(), tenantName);
this.sessionsPath = TenantRepository.getSessionsPath(tenantName);
this.clock = componentRegistry.getClock();
this.curator = componentRegistry.getCurator();
@@ -655,7 +657,7 @@ public class SessionRepository {
}
private long getNextSessionId() {
- return new SessionCounter(componentRegistry.getConfigCurator(), tenantName).nextSessionId();
+ return sessionCounter.nextSessionId();
}
public Path getSessionPath(long sessionId) {