episphere / connect

Connect API for DCEG's Cohort Study
10 stars 5 forks source link

KPGA manifest discrepancy after printing (Biospecimen) (September Release) #928

Open erincschwartz opened 6 months ago

erincschwartz commented 6 months ago

A KPGA team member prepared specimens for shipment yesterday, 3/12/2024 at 2:26pm. Specimens for collection IDs CXA022312 and CXA022313 were put into Box 613, both were present on the shipping manifest, which was printed. After printing, the KPGA team member noted that only one of the collections was showing on the manifest within the Dashboard, collection CXA022313 was no longer present. This collection did not appear on the In transit or Receipt csv files for BPTL.

The team member attempted to re-add these specimens to the box in the Dashboard and received the error shown below. Please investigate using Data Dog.

Image

erincschwartz commented 6 months ago

Took a look at the prod files today for this collection, BioCol_CollBoxedStatus_v1r0 in the Connect_prod_Biospec_Formats file shows "Boxed" but this collection is not included in the flatboxes file. Added @Davinkjohnson to this issue.

JoeArmani commented 5 months ago

Thanks @erincschwartz, agreed - this looks like the same issue based on the back-end data behavior. Thanks for pointing me this direction.

Additional notes: CXA022312 receipt scan (CID 926457119) on 2024-03-13T00:00:00.000Z CXA022313 does not have receipt scan.

Both collections are marked boxedStatus: boxed. Possibility: Something could be triggering removal from the box but not updating the 'boxed status' property. TODO: Check reloading sequence, inspect data object in state before & after printing manifest. Compare that to Firestore data.

Note: this is the first found instance. Prior to March release.

Note 4/4: I've reviewed the playback session. The order of events may be slightly different than reported. That discrepancy could be DataDog or something else, but CXA022313 seems to disappear from Available Collections (its status gets updated to 'boxed') when the user goes into the 'Assign Tracking' flow. This collection should not have been associated with those operations and should've remained in Available Collections.

JoeArmani commented 5 months ago

@erincschwartz Here's what I think is happening in both cases: https://github.com/episphere/connect/issues/928 and https://github.com/episphere/connect/issues/950

Users appear to work on separate computers in the shipping dashboard from the same location. DataDog shows concurrent sessions processing the same 'add to box' operations, probably with different collections, seemingly on the same box.

This type of concurrency isn't handled/supported on the back end, so box data is likely being overwritten during the 'addToBox' operation.


What's Happening step-by-step: (1) User 1 adds a collection 'A' to a box. That collection goes into bag 1 in the box, and the collection's status gets updated to 'boxed'

(2) User 2 adds collection 'B' to that box. That operation is naive to the fact that another item is in the box (the computer's local data hasn't been refreshed since User 1's add-to-box operation. It overwrites Collection A as bag1 in that box.

(3) Collection 'A' has been overwritten and that is not a 'handled' operation, so its status is still 'boxed' and it is not available in Available Collections.


Until this is resolved, users should be notified that these concurrent operations aren't supported yet. This specifically applies to the 'add to box' operation.

Possible resolutions: (1) When a user tries an addToBox or removeFromBox operation, we should check whether the local 'lastUpdatedTimestamp' matches the 'lastUpdatedTimestamp' in the database. If yes, allow the operation. If no, present a modal that says something like 'This box was recently updated. Please refresh your screen to fetch recent updates and try again.'

(2) I did a quick code review. The 'add to box' operation could handle this more flexibly. The 'remove from box' algorithm already appears to handle concurrency well.

Technical Note: connectFaas function names updateBox and removeBag

sonyekere commented 5 months ago

As mentioned above, this issue is tied to #950 . Issue is currently not critical, however important update in the long run so sites can put multiple staff on packing samples if volume is high.

sonyekere commented 4 months ago

Decided that sites to follow standards until the June release