fix: serialize database activity during playout
This commit is contained in:
@@ -170,9 +170,14 @@ public sealed partial class MainWindow
|
||||
return;
|
||||
}
|
||||
|
||||
var databaseActivityEntered = false;
|
||||
try
|
||||
{
|
||||
Interlocked.Exchange(ref _playoutCommandInFlight, 1);
|
||||
CancelActiveMarketDataRequest();
|
||||
CancelActiveDatabaseHealthCheck();
|
||||
await _databaseActivityGate.WaitAsync(_lifetimeCancellation.Token);
|
||||
databaseActivityEntered = true;
|
||||
if (IsBrowserCorrelationQuarantined())
|
||||
{
|
||||
PostPlayoutCommandError(
|
||||
@@ -308,6 +313,10 @@ public sealed partial class MainWindow
|
||||
finally
|
||||
{
|
||||
Interlocked.Exchange(ref _playoutCommandInFlight, 0);
|
||||
if (databaseActivityEntered)
|
||||
{
|
||||
_databaseActivityGate.Release();
|
||||
}
|
||||
_playoutCommandGate.Release();
|
||||
// A browser-side timeout may have discarded the correlated result while the
|
||||
// native operation was still completing. Always publish the authoritative
|
||||
@@ -760,6 +769,7 @@ public sealed partial class MainWindow
|
||||
{
|
||||
await Task.Delay(nextDelay, token);
|
||||
await _playoutCommandGate.WaitAsync(token);
|
||||
var databaseActivityEntered = false;
|
||||
try
|
||||
{
|
||||
if (!ReferenceEquals(_legacyRefreshCancellation, cancellation) ||
|
||||
@@ -769,6 +779,10 @@ public sealed partial class MainWindow
|
||||
}
|
||||
|
||||
Interlocked.Exchange(ref _playoutCommandInFlight, 1);
|
||||
CancelActiveMarketDataRequest();
|
||||
CancelActiveDatabaseHealthCheck();
|
||||
await _databaseActivityGate.WaitAsync(token);
|
||||
databaseActivityEntered = true;
|
||||
var result = await workflow.RefreshOnAirAsync(token);
|
||||
// A failed, timed-out, or unknown update never repeats. The operator
|
||||
// must reconcile native/PGM state before starting another command.
|
||||
@@ -819,6 +833,10 @@ public sealed partial class MainWindow
|
||||
finally
|
||||
{
|
||||
Interlocked.Exchange(ref _playoutCommandInFlight, 0);
|
||||
if (databaseActivityEntered)
|
||||
{
|
||||
_databaseActivityGate.Release();
|
||||
}
|
||||
_playoutCommandGate.Release();
|
||||
QueuePlayoutStatus();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user