bug(core): potential race condition in discovery sources array update #527

Closed
opened 2026-03-28 04:25:22 +00:00 by mfreeman451 · 1 comment
Owner

Imported from GitHub.

Original GitHub issue: #1553
Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/issues/1553
Original created: 2025-08-21T04:42:20Z


The materialized view unified_device_pipeline_mv (lines 100-103 of the schema) has a race condition issue:

  if(index_of(if_null(u.discovery_sources, []), s.discovery_source) > 0,
     u.discovery_sources,
     array_push_back(if_null(u.discovery_sources, []), s.discovery_source)) AS discovery_sources,

Problem: When multiple updates arrive close together (e.g., armis and sweep), they both read the current state from unified_devices, but whichever one processes second might not see the first one's update yet. This is because:

  • Update 1 (armis): Reads current state (empty), adds 'armis', writes ['armis']
  • Update 2 (sweep): Reads current state (might still be empty if Update 1 hasn't committed), adds 'sweep', writes ['sweep'] - overwriting armis!
Imported from GitHub. Original GitHub issue: #1553 Original author: @mfreeman451 Original URL: https://github.com/carverauto/serviceradar/issues/1553 Original created: 2025-08-21T04:42:20Z --- The materialized view unified_device_pipeline_mv (lines 100-103 of the schema) has a race condition issue: ```golang if(index_of(if_null(u.discovery_sources, []), s.discovery_source) > 0, u.discovery_sources, array_push_back(if_null(u.discovery_sources, []), s.discovery_source)) AS discovery_sources, ``` Problem: When multiple updates arrive close together (e.g., armis and sweep), they both read the current state from unified_devices, but whichever one processes second might not see the first one's update yet. This is because: - Update 1 (armis): Reads current state (empty), adds 'armis', writes ['armis'] - Update 2 (sweep): Reads current state (might still be empty if Update 1 hasn't committed), adds 'sweep', writes ['sweep'] - overwriting armis!
Author
Owner

Imported GitHub comment.

Original author: @mfreeman451
Original URL: https://github.com/carverauto/serviceradar/issues/1553#issuecomment-3813458067
Original created: 2026-01-28T19:35:01Z


closing, stale

Imported GitHub comment. Original author: @mfreeman451 Original URL: https://github.com/carverauto/serviceradar/issues/1553#issuecomment-3813458067 Original created: 2026-01-28T19:35:01Z --- closing, stale
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
carverauto/serviceradar#527
No description provided.