diff --git a/MP.RIOC/MP.RIOC.csproj b/MP.RIOC/MP.RIOC.csproj
index 7b168969..49b7811e 100644
--- a/MP.RIOC/MP.RIOC.csproj
+++ b/MP.RIOC/MP.RIOC.csproj
@@ -5,7 +5,7 @@
enable
enable
MP.RIOC
- 8.16.2606.1118
+ 8.16.2606.1119
diff --git a/MP.RIOC/Resources/ChangeLog.html b/MP.RIOC/Resources/ChangeLog.html
index 6cde41a6..7e230697 100644
--- a/MP.RIOC/Resources/ChangeLog.html
+++ b/MP.RIOC/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MP-RIOC
- Versione: 8.16.2606.1118
+ Versione: 8.16.2606.1119
Note di rilascio:
-
diff --git a/MP.RIOC/Resources/VersNum.txt b/MP.RIOC/Resources/VersNum.txt
index edaf8e76..7907c963 100644
--- a/MP.RIOC/Resources/VersNum.txt
+++ b/MP.RIOC/Resources/VersNum.txt
@@ -1 +1 @@
-8.16.2606.1118
+8.16.2606.1119
diff --git a/MP.RIOC/Resources/manifest.xml b/MP.RIOC/Resources/manifest.xml
index 26b82416..d39cf2ef 100644
--- a/MP.RIOC/Resources/manifest.xml
+++ b/MP.RIOC/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 8.16.2606.1118
+ 8.16.2606.1119
https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/MP.RIOC.zip
https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/ChangeLog.html
false
diff --git a/MP.RIOC/Services/MetricsDbFlushService.cs b/MP.RIOC/Services/MetricsDbFlushService.cs
index 3d89e907..53f4d415 100644
--- a/MP.RIOC/Services/MetricsDbFlushService.cs
+++ b/MP.RIOC/Services/MetricsDbFlushService.cs
@@ -69,20 +69,27 @@ namespace MP.RIOC.Services
///
/// Cancellazione ricorsiva chiavi ausiliarie (:status, :errors) e rimozione dall'indice
///
- private async Task DeleteAuxKeysAndIndexAsync(RedisKey sKey, RedisKey indexKey, IBatch batch)
+ private async Task DeleteAuxKeysAndIndexAsync(RedisKey sKey, RedisKey indexKey, IBatch batch, List pendingOps)
{
string sKeyStr = sKey.ToString();
string keyDir = sKeyStr.Substring(0, sKeyStr.LastIndexOf(':'));
// Cancella :status dal sorted set e dalla hash
string statusKey = keyDir + ":status";
- await batch.SortedSetRemoveAsync(indexKey, statusKey);
- await batch.KeyDeleteAsync(statusKey);
-
+ try
+ {
+ pendingOps.Add(batch.SortedSetRemoveAsync(indexKey, statusKey));
+ pendingOps.Add(batch.KeyDeleteAsync(statusKey));
+ }
+ catch { }
// Cancella :errors dal sorted set e dalla hash
string errorKey = keyDir + ":errors";
- await batch.SortedSetRemoveAsync(indexKey, errorKey);
- await batch.KeyDeleteAsync(errorKey);
+ try
+ {
+ pendingOps.Add(batch.SortedSetRemoveAsync(indexKey, errorKey));
+ pendingOps.Add(batch.KeyDeleteAsync(errorKey));
+ }
+ catch { }
// Cancella chiave ausiliaria :status anche da un eventuale indice days se presente
if (statusKey.Contains(":stats:hours:"))
@@ -90,7 +97,7 @@ namespace MP.RIOC.Services
string daysIndex = statusKey.Replace(":stats:hours:", ":stats:days:");
try
{
- await batch.SortedSetRemoveAsync(daysIndex, statusKey);
+ pendingOps.Add(batch.SortedSetRemoveAsync(daysIndex, statusKey));
}
catch { }
}
@@ -101,7 +108,7 @@ namespace MP.RIOC.Services
string daysIndex = errorKey.Replace(":stats:hours:", ":stats:days:");
try
{
- await batch.SortedSetRemoveAsync(daysIndex, errorKey);
+ pendingOps.Add(batch.SortedSetRemoveAsync(daysIndex, errorKey));
}
catch { }
}
@@ -150,6 +157,7 @@ namespace MP.RIOC.Services
};
var batch = _db.CreateBatch();
+ var pendingOps = new List();
foreach (var pattern in patternsToScan)
{
// Nota: KeyScanAsync/KeysAsync e' disponibile su IServer
@@ -179,17 +187,19 @@ namespace MP.RIOC.Services
isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalHours > 30.25 * 24;
}
- // Se era scaduta o orfana e abbiamo il permesso, segnamola per la cancellazione
- if ((meta.Timestamp < currentDayStart || isOrphanKey) && deleteConfirmed)
+ // Se è orfana e abbiamo il permesso, segnamola per la cancellazione
+ // NOTA: non usiamo il confronto con currentDayStart perché taglierebbe fuori
+ // i dati delle ore/giorni precedenti che devono essere ancora processati dal DB
+ if (isOrphanKey && deleteConfirmed)
{
// 1. Segna la chiave Hash (Dati) per l'eliminazione
keysToDelete.Add(sKey);
// 2. Rimuovi il riferimento dal Sorted Set (Indice)
- await batch.SortedSetRemoveAsync(indexKey, statKey);
+ pendingOps.Add(batch.SortedSetRemoveAsync(indexKey, statKey));
// 3. Cancellazione ricorsiva delle chiavi ausiliarie (:status, :errors, :days)
- await DeleteAuxKeysAndIndexAsync(sKey, indexKey, batch);
+ await DeleteAuxKeysAndIndexAsync(sKey, indexKey, batch, pendingOps);
}
// Recupero dati dalla Hash
@@ -236,6 +246,8 @@ namespace MP.RIOC.Services
}
}
batch.Execute();
+ // attendo conclusione
+ await Task.WhenAll(pendingOps);
}
// --- FASE UPSERT DB ---
@@ -251,13 +263,16 @@ namespace MP.RIOC.Services
if (deleteConfirmed && keysToDelete.Any())
{
var batch = _db.CreateBatch();
+ var pendingOps = new List();
int deletedCount = 0;
foreach (var key in keysToDelete)
{
- await batch.KeyDeleteAsync(key);
+ pendingOps.Add(batch.KeyDeleteAsync(key));
deletedCount++;
}
batch.Execute();
+ // attendo conclusione
+ await Task.WhenAll(pendingOps);
Log.Info($"[CLEANUP DAY] Deleted {deletedCount} expired metric keys from Redis");
}
}
@@ -294,6 +309,7 @@ namespace MP.RIOC.Services
};
var batch = _db.CreateBatch();
+ var pendingOps = new List();
foreach (var pattern in patternsToScan)
{
// Nota: KeyScanAsync/KeysAsync e' disponibile su IServer
@@ -323,17 +339,19 @@ namespace MP.RIOC.Services
isOrphanKey = keyTtl.Value.TotalSeconds < 0 || keyTtl.Value.TotalHours > 15.25 * 24;
}
- // Se era scaduta o orfana e abbiamo il permesso, segnamola per la cancellazione
- if ((meta.Timestamp < currentHourStart || isOrphanKey) && deleteConfirmed)
+ // Se è orfana e abbiamo il permesso, segnamola per la cancellazione
+ // NOTA: non usiamo il confronto con currentHourStart perché taglierebbe fuori
+ // i dati delle ore precedenti che devono essere ancora processati dal DB
+ if (isOrphanKey && deleteConfirmed)
{
// 1. Segna la chiave Hash (Dati) per l'eliminazione
keysToDelete.Add(sKey);
// 2. Rimuovi il riferimento dal Sorted Set (Indice)
- await batch.SortedSetRemoveAsync(indexKey, statKey);
+ pendingOps.Add(batch.SortedSetRemoveAsync(indexKey, statKey));
// 3. Cancellazione ricorsiva chiavi ausiliarie
- await DeleteAuxKeysAndIndexAsync(sKey, indexKey, batch);
+ await DeleteAuxKeysAndIndexAsync(sKey, indexKey, batch, pendingOps);
}
// Recupero dati dalla Hash
@@ -379,6 +397,8 @@ namespace MP.RIOC.Services
}
}
batch.Execute();
+ // attendo conclusione
+ await Task.WhenAll(pendingOps);
}
// --- FASE UPSERT DB ---
@@ -394,13 +414,16 @@ namespace MP.RIOC.Services
if (deleteConfirmed && keysToDelete.Count > 0)
{
var batch = _db.CreateBatch();
+ var pendingOps = new List();
int deletedCount = 0;
foreach (var key in keysToDelete)
{
- await batch.KeyDeleteAsync(key);
+ pendingOps.Add(batch.KeyDeleteAsync(key));
deletedCount++;
}
batch.Execute();
+ // attendo conclusione
+ await Task.WhenAll(pendingOps);
Log.Info($"[CLEANUP HOUR] Deleted {deletedCount} expired metric keys from Redis");
}
}