summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-06-05 19:02:42 +0200
committerGitHub <noreply@github.com>2020-06-05 19:02:42 +0200
commit42b7c64af11a108e1d055196ff3ab0f3fc0d5c5d (patch)
treeba0ee189571e7ae023e811d4199bb8faace28ae4 /configserver
parent86c998932c894e47fe3a710d79b2f37894994947 (diff)
parent91dbcdd0921d015251f9a896e5321bfd2bda3b8c (diff)
Merge pull request #13492 from vespa-engine/hmusum/use-correct-previous-active-generation
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 819049c6517..9404bc9c279 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
@@ -660,7 +660,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 3e5b539a5bf..a3d072be38b 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
@@ -167,6 +167,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(),