Skip to content

Commit

Permalink
RavenDB-22849 - backwards compatibilty changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lastav5 committed Jan 23, 2025
1 parent f7ecb9f commit 0a0a695
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ private Dictionary<string, DatabaseStatusReport> CollectDatabaseInformation(Tran
var report = new DatabaseStatusReport
{
Name = dbName,
NodeName = _server.NodeTag
NodeName = _server.NodeTag,
BackupStatuses = new ()
};

prevReport.TryGetValue(dbName, out var prevDatabaseReport);
Expand Down
26 changes: 20 additions & 6 deletions src/Raven.Server/ServerWide/Maintenance/ClusterNodeStatusReport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class DatabaseStatusReport : IDynamicJson

public Dictionary<string, ObservedIndexStatus> LastIndexStats = new Dictionary<string, ObservedIndexStatus>();
public Dictionary<string, long> LastSentEtag = new Dictionary<string, long>();
public Dictionary<long, PeriodicBackupStatusReport> BackupStatuses = new ();
public Dictionary<long, PeriodicBackupStatusReport> BackupStatuses;

public long LastCompareExchangeIndex { get; set; }
public long LastClusterWideTransactionRaftIndex { get; set; }
Expand Down Expand Up @@ -149,8 +149,16 @@ public override string ToString()
public long GetBackupStatusReportHash()
{
long hash = 0;
foreach (var (_, status) in BackupStatuses)

if (BackupStatuses == null)
{
Debug.Fail($"{nameof(BackupStatuses)} should not be null");
return hash;
}

foreach (var (taskId, status) in BackupStatuses)
{
hash = Hashing.Combine(hash, taskId);
hash = Hashing.Combine(hash, status?.LastRaftIndex?.LastEtag ?? 0);
}

Expand Down Expand Up @@ -205,12 +213,18 @@ public DynamicJsonValue ToJson()
}
dynamicJsonValue[nameof(LastIndexStats)] = indexStats;

var backupStatuses = new DynamicJsonValue();
foreach (var status in BackupStatuses)
if (BackupStatuses == null)
dynamicJsonValue[nameof(BackupStatuses)] = null;
else
{
backupStatuses[status.Key.ToString()] = status.Value?.ToJson();
var backupStatuses = new DynamicJsonValue();
foreach (var status in BackupStatuses)
{
backupStatuses[status.Key.ToString()] = status.Value?.ToJson();
}

dynamicJsonValue[nameof(BackupStatuses)] = backupStatuses;
}
dynamicJsonValue[nameof(BackupStatuses)] = backupStatuses;

return dynamicJsonValue;
}
Expand Down
5 changes: 2 additions & 3 deletions src/Raven.Server/ServerWide/Maintenance/ClusterObserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,9 @@ private CompareExchangeTombstonesCleanupState GetMaxCompareExchangeTombstonesEta
if (hasReport == false)
return CompareExchangeTombstonesCleanupState.InvalidDatabaseObservationState;

if (state.RawDatabase.PeriodicBackupsTaskIds != null && state.RawDatabase.PeriodicBackupsTaskIds.Count != 0 &&
report.BackupStatuses.Count == 0)
if (report.BackupStatuses == null)
{
// we got a report from an old version that doesn't populate BackupStatuses (we add BackupStatuses taskIds keys even if its values are null)
// the node wasn't updated to a version that supports it
return CompareExchangeTombstonesCleanupState.InvalidPeriodicBackupStatus;
}

Expand Down

0 comments on commit 0a0a695

Please sign in to comment.