8000 Race Condition Causes Specimen Container Locations to Be Overwritten by Newly Created Specimens · Issue #275 · aces/biobank · GitHub
[go: up one dir, main page]

Skip to content

Race Condition Causes Specimen Container Locations to Be Overwritten by Newly Created Specimens #275

Open

Description

@HenriRabalais

Description

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.

Activity

  1. 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
  2. ridz1208 commented on May 5, 2025

    @ridz1208
    Collaborator

    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

    USER 1 SUBMISSION
    14592482	biobank_container_parent	ContainerID		188765	ContainerID	188765	2025-05-02 13:25:07.000
    14592483	biobank_container_parent	ParentContainerID		21087	ContainerID	188765	2025-05-02 13:25:07.000
    14592484	biobank_container_parent	Coordinate		15	ContainerID	188765	2025-05-02 13:25:07.000
    14592494	biobank_container_parent	ContainerID		188766	ContainerID	188766	2025-05-02 13:25:07.000
    14592495	biobank_container_parent	ParentContainerID		21087	ContainerID	188766	2025-05-02 13:25:07.000
    14592496	biobank_container_parent	Coordinate		40	ContainerID	188766	2025-05-02 13:25:07.000
    14592506	biobank_container_parent	ContainerID		188767	ContainerID	188767	2025-05-02 13:25:07.000
    14592507	biobank_container_parent	ParentContainerID		21087	ContainerID	188767	2025-05-02 13:25:07.000
    14592508	biobank_container_parent	Coordinate		41	ContainerID	188767	2025-05-02 13:25:07.000
    14592518	biobank_container_parent	ContainerID		188768	ContainerID	188768	2025-05-02 13:25:07.000
    14592519	biobank_container_parent	ParentContainerID		21087	ContainerID	188768	2025-05-02 13:25:07.000
    14592520	biobank_container_parent	Coordinate		42	ContainerID	188768	2025-05-02 13:25:07.000
    14592530	biobank_container_parent	ContainerID		188769	ContainerID	188769	2025-05-02 13:25:07.000
    14592531	biobank_container_parent	ParentContainerID		21087	ContainerID	188769	2025-05-02 13:25:07.000
    14592532	biobank_container_parent	Coordinate		45	ContainerID	188769	2025-05-02 13:25:07.000
    14592542	biobank_container_parent	ContainerID		188770	ContainerID	188770	2025-05-02 13:25:07.000
    14592543	biobank_container_parent	ParentContainerID		21087	ContainerID	188770	2025-05-02 13:25:07.000
    14592544	biobank_container_parent	Coordinate		46	ContainerID	188770	2025-05-02 13:25:07.000
    
    
    
    USER 2 SUBMISSION
    14594868	biobank_container_parent	ContainerID		188818	ContainerID	188818	2025-05-02 14:07:27.000
    14594869	biobank_container_parent	ParentContainerID		21087	ContainerID	188818	2025-05-02 14:07:27.000
    14594870	biobank_container_parent	Coordinate		15	ContainerID	188818	2025-05-02 14:07:27.000
    14594880	biobank_container_parent	ContainerID		188819	ContainerID	188819	2025-05-02 14:07:27.000
    14594881	biobank_container_parent	ParentContainerID		21087	ContainerID	188819	2025-05-02 14:07:27.000
    14594882	biobank_container_parent	Coordinate		40	ContainerID	188819	2025-05-02 14:07:27.000
    14594892	biobank_container_parent	ContainerID		188820	ContainerID	188820	2025-05-02 14:07:27.000
    14594893	biobank_container_parent	ParentContainerID		21087	ContainerID	188820	2025-05-02 14:07:27.000
    14594894	biobank_container_parent	Coordinate		41	ContainerID	188820	2025-05-02 14:07:27.000
    14594904	biobank_container_parent	ContainerID		188821	ContainerID	188821	2025-05-02 14:07:27.000
    14594905	biobank_container_parent	ParentContainerID		21087	ContainerID	188821	2025-05-02 14:07:27.000
    14594906	biobank_container_parent	Coordinate		42	ContainerID	188821	2025-05-02 14:07:27.000
    14594916	biobank_container_parent	ContainerID		188822	ContainerID	188822	2025-05-02 14:07:27.000
    14594917	biobank_container_parent	ParentContainerID		21087	ContainerID	188822	2025-05-02 14:07:27.000
    14594918	biobank_container_parent	Coordinate		45	ContainerID	188822	2025-05-02 14:07:27.000
    14594928	biobank_container_parent	ContainerID		188823	ContainerID	188823	2025-05-02 14:07:27.000
    14594929	biobank_container_parent	ParentContainerID		21087	ContainerID	188823	2025-05-02 14:07:27.000
    14594930	biobank_container_parent	Coordinate		46	ContainerID	188823	2025-05-02 14:07:27.000
    14594940	biobank_container_parent	ContainerID		188824	ContainerID	188824	2025-05-02 14:07:27.000
    14594941	biobank_container_parent	ParentContainerID		21087	ContainerID	188824	2025-05-02 14:07:27.000
    14594942	biobank_container_parent	Coordinate		60	ContainerID	188824	2025-05-02 14:07:27.000
    
  3. ridz1208 commented on May 5, 2025

    @ridz1208
    Collaborator

    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"
    ;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0