aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2021-07-14 15:08:15 +0200
committerGitHub <noreply@github.com>2021-07-14 15:08:15 +0200
commit3f7beca44cbd15e7839077c54356084509728b21 (patch)
tree625afe3dae402153a1465b02b825d6af0ebe38db
parent1287b943081406083b1913ac90c4850c796ac79a (diff)
parente7bff5537329fd28a598af0ba101a5bedb57ffb9 (diff)
Merge pull request #18604 from vespa-engine/hmusum/use-session-from-disk-when-deleting
Use local sessions from file system when deleting expired sessions
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java1
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java18
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java5
3 files changed, 20 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 56fd6a64305..1eb27a3224a 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
@@ -107,7 +107,6 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
-import static com.yahoo.config.model.api.container.ContainerServiceType.CLUSTERCONTROLLER_CONTAINER;
import static com.yahoo.config.model.api.container.ContainerServiceType.CONTAINER;
import static com.yahoo.config.model.api.container.ContainerServiceType.LOGSERVER_CONTAINER;
import static com.yahoo.vespa.config.server.filedistribution.FileDistributionUtil.fileReferenceExistsOnDisk;
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 27ee040fe4f..1e025bd8e35 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
@@ -208,6 +208,22 @@ public class SessionRepository {
return List.copyOf(localSessionCache.values());
}
+ public Set<LocalSession> getLocalSessionsFromFileSystem() {
+ File[] sessions = tenantFileSystemDirs.sessionsPath().listFiles(sessionApplicationsFilter);
+ if (sessions == null) return Set.of();
+
+ Set<LocalSession> sessionIds = new HashSet<>();
+ for (File session : sessions) {
+ long sessionId = Long.parseLong(session.getName());
+ SessionZooKeeperClient sessionZKClient = createSessionZooKeeperClient(sessionId);
+ File sessionDir = getAndValidateExistingSessionAppDir(sessionId);
+ ApplicationPackage applicationPackage = FilesApplicationPackage.fromFile(sessionDir);
+ LocalSession localSession = new LocalSession(tenantName, sessionId, applicationPackage, sessionZKClient);
+ sessionIds.add(localSession);
+ }
+ return sessionIds;
+ }
+
private void loadLocalSessions(ExecutorService executor) {
File[] sessions = tenantFileSystemDirs.sessionsPath().listFiles(sessionApplicationsFilter);
if (sessions == null) return;
@@ -553,7 +569,7 @@ public class SessionRepository {
log.log(Level.FINE, () -> "Purging old sessions for tenant '" + tenantName + "'");
Set<LocalSession> toDelete = new HashSet<>();
try {
- for (LocalSession candidate : getLocalSessions()) {
+ for (LocalSession candidate : getLocalSessionsFromFileSystem()) {
Instant createTime = candidate.getCreateTime();
log.log(Level.FINE, () -> "Candidate session for deletion: " + candidate.getSessionId() + ", created: " + createTime);
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 1b31d02d222..8f8005894e5 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
@@ -465,12 +465,13 @@ public class ApplicationRepositoryTest {
// Create a local session without any data in zookeeper (corner case seen in production occasionally)
// and check that expiring local sessions still work
int sessionId = 6;
- Files.createDirectory(new TenantFileSystemDirs(serverdb, tenant1).getUserApplicationDir(sessionId).toPath());
+ TenantName tenantName = tester.tenant().getName();
+ Files.createDirectory(new TenantFileSystemDirs(serverdb, tenantName).getUserApplicationDir(sessionId).toPath());
LocalSession localSession2 = new LocalSession(tenant1,
sessionId,
FilesApplicationPackage.fromFile(testApp),
new SessionZooKeeperClient(curator,
- tenant1,
+ tenantName,
sessionId,
ConfigUtils.getCanonicalHostName()));
sessionRepository.addLocalSession(localSession2);