Skip to content

Commit

Permalink
Updating DB IDs after swap
Browse files Browse the repository at this point in the history
  • Loading branch information
TalZaccai committed Mar 8, 2025
1 parent 6e9d4c8 commit 62159e6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions libs/server/Databases/MultiDatabaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,9 @@ public override bool TrySwapDatabases(int dbId1, int dbId2)
databaseMapSnapshot[dbId1] = db2;
databaseMapSnapshot[dbId2] = tmp;

databaseMapSnapshot[dbId1].Id = dbId1;
databaseMapSnapshot[dbId2].Id = dbId2;

var sessions = StoreWrapper.TcpServer?.ActiveConsumers().ToArray();
if (sessions == null) return true;
if (sessions.Length > 1) return false;
Expand Down
3 changes: 3 additions & 0 deletions libs/server/Resp/RespServerSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,9 @@ internal bool TrySwapDatabaseSessions(int dbId1, int dbId2)
databaseSessions.Map[dbId1] = dbSession2;
databaseSessions.Map[dbId2] = tmp;

databaseSessions.Map[dbId1].Id = dbId1;
databaseSessions.Map[dbId2].Id = dbId2;

if (activeDbId == dbId1)
SwitchActiveDatabaseSession(dbId1, ref databaseSessions.Map[dbId1]);
else if (activeDbId == dbId2)
Expand Down

0 comments on commit 62159e6

Please sign in to comment.