Compare commits

...
Author SHA1 Message Date
adminandClaude Opus 4.5 9df86a3d8d Prevent result count regression to fix sync mismatches
The server sends unfilteredCountAfter=0 for intermediate chunks when
splitting large result sets (>1024 results). The client was blindly
updating its count to 0, causing false sync mismatches when heartbeats
reported the incorrect count.

Changes:
- Only update Eagle result count if new count > old count
- Only update Shardok result count if new count > old count
- Log warnings when unexpected count decreases are ignored

This ensures counts are monotonically increasing, preventing false
sync mismatch detection during initial sync or reconnection.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-28 13:18:47 -08:00
@@ -424,10 +424,17 @@ namespace eagle {
var newCount = update.ActionResultResponse.UnfilteredResultCountAfter;
lock (_resultCountLock) {
var oldCount = _lastUnfilteredResultCount;
_lastUnfilteredResultCount = newCount;
if (newCount != oldCount) {
// Only update if new count is higher. The server sends 0 for
// intermediate chunks when splitting large result sets, which we
// should ignore to prevent false sync mismatches.
if (newCount > oldCount) {
_lastUnfilteredResultCount = newCount;
_connectionLogger.LogLine(
$"[RESULT_COUNT] Updated count {oldCount} -> {newCount}");
} else if (newCount < oldCount && newCount != 0) {
// Unexpected: count decreased (but not to 0, which is chunking)
_connectionLogger.LogLine(
$"[RESULT_COUNT] WARNING: Ignoring count decrease {oldCount} -> {newCount}");
}
}
break;
@@ -435,7 +442,16 @@ namespace eagle {
case GameUpdate.GameUpdateDetailsOneofCase.ShardokActionResultResponse:
foreach (var response in update.ShardokActionResultResponse
.ShardokGameResponses) {
_shardokResultCounts[response.ShardokGameId] = response.NewResultViewCount;
var shardokId = response.ShardokGameId;
var newShardokCount = response.NewResultViewCount;
var oldShardokCount = _shardokResultCounts.GetValueOrDefault(shardokId, 0);
// Only update if new count is higher (count should only increase)
if (newShardokCount > oldShardokCount) {
_shardokResultCounts[shardokId] = newShardokCount;
} else if (newShardokCount < oldShardokCount) {
_connectionLogger.LogLine(
$"[SHARDOK_COUNT] WARNING: Ignoring count decrease for {shardokId}: {oldShardokCount} -> {newShardokCount}");
}
}
break;
}