Frank Muller
2021-04-22 11:32:12 UTC
Hi guys
Iâve a little issue Iâm unable to solve with the current ETS API.
My table is of type set. Keys are integers and values are list of names:
123 -> [ jane, john, bob ]
456 -> [ joe, alice ]
âŠ
Process A with Key=123 wants to delete âJaneâ while process B with Key=123
wants to add âAdamâ.
First, they both needs to read the value associated with Key=123, update
that list accordingly and set back the new value.
But this lead to race condition (ex. process B could put back âjaneâ - last
write wins).
Could this problem be solved atomically without involving explicit locking
per Key?
Is there any other better way to represent this data set which will not
suffer from the race condition?
Thanks
/Frank
Iâve a little issue Iâm unable to solve with the current ETS API.
My table is of type set. Keys are integers and values are list of names:
123 -> [ jane, john, bob ]
456 -> [ joe, alice ]
âŠ
Process A with Key=123 wants to delete âJaneâ while process B with Key=123
wants to add âAdamâ.
First, they both needs to read the value associated with Key=123, update
that list accordingly and set back the new value.
But this lead to race condition (ex. process B could put back âjaneâ - last
write wins).
Could this problem be solved atomically without involving explicit locking
per Key?
Is there any other better way to represent this data set which will not
suffer from the race condition?
Thanks
/Frank