diff options
6 files changed, 28 insertions, 10 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 bcdb2618bda..490ab988048 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 @@ -684,8 +684,11 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye sessionsPerTenant.values().forEach(sessionList -> sessionList.forEach(s -> applicationIds.add(s.getApplicationId()))); Map<ApplicationId, Long> activeSessions = new HashMap<>(); - applicationIds.forEach(applicationId -> activeSessions.put(applicationId, getActiveSession(applicationId).getSessionId())); - + applicationIds.forEach(applicationId -> { + RemoteSession activeSession = getActiveSession(applicationId); + if (activeSession != null) + activeSessions.put(applicationId, activeSession.getSessionId()); + }); sessionsPerTenant.keySet().forEach(tenant -> tenant.getLocalSessionRepo().deleteExpiredSessions(activeSessions)); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSessionRepo.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSessionRepo.java index f9b851fe197..d276a59327d 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSessionRepo.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSessionRepo.java @@ -120,7 +120,7 @@ public class LocalSessionRepo extends SessionRepo<LocalSession> { return candidate.getStatus() == Session.Status.ACTIVATE; } - void deleteSession(LocalSession session) { + public void deleteSession(LocalSession session) { long sessionId = session.getSessionId(); log.log(Level.FINE, "Deleting local session " + sessionId); LocalSessionStateWatcher watcher = sessionStateWatchers.remove(sessionId); 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 4d0253cd3f8..e977284e06c 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 @@ -21,12 +21,14 @@ import com.yahoo.io.IOUtils; import com.yahoo.jdisc.Metric; import com.yahoo.test.ManualClock; import com.yahoo.text.Utf8; +import com.yahoo.transaction.NestedTransaction; import com.yahoo.vespa.config.server.application.OrchestratorMock; import com.yahoo.vespa.config.server.deploy.DeployTester; import com.yahoo.vespa.config.server.http.InternalServerException; import com.yahoo.vespa.config.server.http.SessionHandlerTest; import com.yahoo.vespa.config.server.http.v2.PrepareResult; import com.yahoo.vespa.config.server.session.LocalSession; +import com.yahoo.vespa.config.server.session.LocalSessionRepo; import com.yahoo.vespa.config.server.session.PrepareParams; import com.yahoo.vespa.config.server.session.RemoteSession; import com.yahoo.vespa.config.server.session.SilentDeployLogger; @@ -331,18 +333,33 @@ public class ApplicationRepositoryTest { assertNotEquals(activeSessionId, deployment3session); // No change to active session id assertEquals(activeSessionId, tester.tenant().getApplicationRepo().requireActiveSessionOf(tester.applicationId())); - assertEquals(3, tester.tenant().getLocalSessionRepo().listSessions().size()); + LocalSessionRepo localSessionRepo = tester.tenant().getLocalSessionRepo(); + assertEquals(3, localSessionRepo.listSessions().size()); clock.advance(Duration.ofHours(1)); // longer than session lifetime // All sessions except 3 should be removed after the call to deleteExpiredLocalSessions tester.applicationRepository().deleteExpiredLocalSessions(); - Collection<LocalSession> sessions = tester.tenant().getLocalSessionRepo().listSessions(); + Collection<LocalSession> sessions = localSessionRepo.listSessions(); assertEquals(1, sessions.size()); - assertEquals(3, new ArrayList<>(sessions).get(0).getSessionId()); + ArrayList<LocalSession> localSessions = new ArrayList<>(sessions); + LocalSession localSession = localSessions.get(0); + assertEquals(3, localSession.getSessionId()); // There should be no expired remote sessions in the common case assertEquals(0, tester.applicationRepository().deleteExpiredRemoteSessions(clock, Duration.ofSeconds(0))); + + // Deploy, but do not activate + Optional<com.yahoo.config.provision.Deployment> deployment4 = tester.redeployFromLocalActive(); + assertTrue(deployment4.isPresent()); + deployment4.get().prepare(); // session 5 (not activated) + + assertEquals(2, localSessionRepo.listSessions().size()); + localSessionRepo.deleteSession(localSession); + assertEquals(1, localSessionRepo.listSessions().size()); + + // Check that trying to expire when there are no active sessions works + tester.applicationRepository().deleteExpiredLocalSessions(); } @Test diff --git a/searchlib/src/vespa/searchlib/features/fieldmatch/computer_shared_state.cpp b/searchlib/src/vespa/searchlib/features/fieldmatch/computer_shared_state.cpp index 135902116c0..033124e86bb 100644 --- a/searchlib/src/vespa/searchlib/features/fieldmatch/computer_shared_state.cpp +++ b/searchlib/src/vespa/searchlib/features/fieldmatch/computer_shared_state.cpp @@ -14,8 +14,7 @@ namespace search::features::fieldmatch { ComputerSharedState::ComputerSharedState(const vespalib::string& propertyNamespace, const PhraseSplitterQueryEnv& splitter_query_env, const FieldInfo& fieldInfo, const Params& params) - : _splitter_query_env(splitter_query_env), - _field_id(fieldInfo.id()), + : _field_id(fieldInfo.id()), _params(params), _use_cached_hits(true), _query_terms(), diff --git a/searchlib/src/vespa/searchlib/features/fieldmatch/computer_shared_state.h b/searchlib/src/vespa/searchlib/features/fieldmatch/computer_shared_state.h index 8de5914422d..e6b46f0add9 100644 --- a/searchlib/src/vespa/searchlib/features/fieldmatch/computer_shared_state.h +++ b/searchlib/src/vespa/searchlib/features/fieldmatch/computer_shared_state.h @@ -37,7 +37,6 @@ public: private: // per query - const search::fef::PhraseSplitterQueryEnv& _splitter_query_env; uint32_t _field_id; Params _params; bool _use_cached_hits; diff --git a/vespalib/src/vespa/vespalib/stllike/allocator.h b/vespalib/src/vespa/vespalib/stllike/allocator.h index 3d8c2f03154..efe885f5c96 100644 --- a/vespalib/src/vespa/vespalib/stllike/allocator.h +++ b/vespalib/src/vespa/vespalib/stllike/allocator.h @@ -23,7 +23,7 @@ public: void deallocate(T * p, std::size_t n) { _allocator->free(p, n*sizeof(T)); } - alloc::MemoryAllocator * allocator() const { return _allocator; } + const alloc::MemoryAllocator * allocator() const { return _allocator; } private: const alloc::MemoryAllocator * _allocator; }; |