summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-06-05 08:30:40 +0200
committerHarald Musum <musum@verizonmedia.com>2020-06-05 08:30:40 +0200
commit91dbcdd0921d015251f9a896e5321bfd2bda3b8c (patch)
treebb4477e3dc80729c4c05163b6357ef2482e82908 /configserver
parent7cbc790d3d4aefe89e43cf5a39ec2916d8432eb1 (diff)
Make sure to set previous active generation when one exists
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java4
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactory.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java17
3 files changed, 23 insertions, 4 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
index 9e8010cf8a7..595d35d557e 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java
@@ -664,7 +664,9 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye
public long createSession(ApplicationId applicationId, TimeoutBudget timeoutBudget, File applicationDirectory) {
Tenant tenant = tenantRepository.getTenant(applicationId.tenant());
tenant.getApplicationRepo().createApplication(applicationId);
- LocalSession session = tenant.getSessionFactory().createSession(applicationDirectory, applicationId, timeoutBudget);
+ Optional<Long> activeSessionId = tenant.getApplicationRepo().activeSessionOf(applicationId);
+ LocalSession session = tenant.getSessionFactory().createSession(applicationDirectory, applicationId,
+ timeoutBudget, activeSessionId);
tenant.getLocalSessionRepo().addSession(session);
return session.getSessionId();
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactory.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactory.java
index 16bb32a19f2..fc4071916ed 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactory.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactory.java
@@ -80,11 +80,11 @@ public class SessionFactory {
* @param timeoutBudget Timeout for creating session and waiting for other servers.
* @return a new session
*/
- public LocalSession createSession(File applicationDirectory, ApplicationId applicationId, TimeoutBudget timeoutBudget) {
- return create(applicationDirectory, applicationId, nonExistingActiveSession, false, timeoutBudget);
+ public LocalSession createSession(File applicationDirectory, ApplicationId applicationId,
+ TimeoutBudget timeoutBudget, Optional<Long> activeSessionId) {
+ return create(applicationDirectory, applicationId, activeSessionId.orElse(nonExistingActiveSession), false, timeoutBudget);
}
-
public RemoteSession createRemoteSession(long sessionId) {
Path sessionPath = sessionsPath.append(String.valueOf(sessionId));
SessionZooKeeperClient sessionZKClient = createSessionZooKeeperClient(sessionPath);
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
index d44be294713..fb91c7bfaae 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
@@ -142,6 +142,23 @@ public class ApplicationRepositoryTest {
}
@Test
+ public void redeploy() {
+ PrepareResult result = deployApp(testApp);
+
+ long firstSessionId = result.sessionId();
+
+ PrepareResult result2 = deployApp(testApp);
+ long secondSessionId = result2.sessionId();
+ assertNotEquals(firstSessionId, secondSessionId);
+
+ TenantName tenantName = applicationId().tenant();
+ Tenant tenant = tenantRepository.getTenant(tenantName);
+ LocalSession session = tenant.getLocalSessionRepo().getSession(
+ tenant.getApplicationRepo().requireActiveSessionOf(applicationId()));
+ assertEquals(firstSessionId, session.getMetaData().getPreviousActiveGeneration());
+ }
+
+ @Test
public void createFromActiveSession() {
PrepareResult result = deployApp(testApp);
long sessionId = applicationRepository.createSessionFromExisting(applicationId(),