Skip to content

PIAdapters: Eliminate InputMeasurementKeyTypes race conditions in PIOutputAdapter - #568

Merged
ritchiecarroll merged 1 commit into
masterfrom
pi-signal-type-race
Jul 23, 2026
Merged

PIAdapters: Eliminate InputMeasurementKeyTypes race conditions in PIOutputAdapter#568
ritchiecarroll merged 1 commit into
masterfrom
pi-signal-type-race

Conversation

@StephenCWills

@StephenCWills StephenCWills commented Jul 22, 2026

Copy link
Copy Markdown
Member

As the comment previously indicated, there is a possible race condition where the backing field for InputMeasurementKeys is updated but InputMeasurementKeyTypes is not. Comparing the length of each array is a decent way to guard against this race condition, but it makes two assumptions.

  1. InputMeasurementKeys is strictly ordered.
  2. You will never encounter a case where the number of inputs added is equal to the number of inputs removed.

Neither of these assumptions are guaranteed, but in practice the race condition and the violations of these assumptions are quite rare. One notable exception, however, occurs in an openPDC system with a large number of measurements. At least in one user's case, the first assumption is violated frequently after a ReloadConfig -Database is issued to the service unless an ORDER BY clause is added to the filter expression.

This PR avoids the race condition entirely by replacing the parallel arrays with a single array of tuples.

@ritchiecarroll
ritchiecarroll merged commit 0809ee1 into master Jul 23, 2026
3 checks passed
@ritchiecarroll
ritchiecarroll deleted the pi-signal-type-race branch July 23, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants