You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Race Condition Causes Specimen Container Locations to Be Overwritten by Newly Created Specimens #275
A race condition is occurring during the assignment of specimens to containers. When multiple specimens are being assigned to the same container concurrently—such as during batch creation—the location data for previously assigned specimens is being overwritten. This results in:
• Previously assigned specimens appearing as if they were never assigned to the container.
• The newly created specimens occupying container locations that were already taken.
This behaviour suggests that there is no mechanism in place to lock or validate container slots during concurrent assignments, allowing the latest write to override previous data silently.
Steps to Reproduce
1. Assign specimen A to container X at location Y.
2. In a separate session, assign specimen B to the same container X at the same or overlapping location.
3. Observe that specimen A’s location assignment is lost or overwritten by specimen B.
Expected Behavior
Each container slot should be exclusively assigned to one specimen. Assignments should be rejected or deferred if the intended slot is already occupied at the time of the operation.
Suggested Fix
Introduce transactional locking or server-side validation during specimen-container assignment to prevent overwriting existing assignments due to concurrent operations.
changed the title [-]race condition results in container locations being overwritten by new containers[/-][+]Race Condition Causes Specimen Container Locations to Be Overwritten by Newly Created Specimens[/+]on May 5, 2025
As far as we know when 2 users have sessions loaded they can request the same location in a container and when they both submit one will override the other.
SELECT * FROM biobank_container bc
LEFT JOIN biobank_container_parent bcp on bcp.ContainerID =bc.ContainerID
JOIN biobank_specimen bs ON bs.ContainerID =bc.ContainerID
JOIN history h ON (bc.ContainerID=primaryVals)
WHERE bc.ContainerStatusID = 1 AND bcp.ParentContainerID IS NULL AND bc.CenterID =86 AND tbl="biobank_container_parent"
;
Activity
[-]race condition results in container locations being overwritten by new containers[/-][+]Race Condition Causes Specimen Container Locations to Be Overwritten by Newly Created Specimens[/+]ridz1208 commentedon May 5, 2025
As far as we know when 2 users have sessions loaded they can request the same location in a container and when they both submit one will override the other.
example usecase
ridz1208 commentedon May 5, 2025
query used
SELECT * FROM biobank_container bc
LEFT JOIN biobank_container_parent bcp on bcp.ContainerID =bc.ContainerID
JOIN biobank_specimen bs ON bs.ContainerID =bc.ContainerID
JOIN history h ON (bc.ContainerID=primaryVals)
WHERE bc.ContainerStatusID = 1 AND bcp.ParentContainerID IS NULL AND bc.CenterID =86 AND tbl="biobank_container_parent"
;