In my program I had 2 ets tables both public with below definition. One being set
and other being bag
data type.
:ets.new(table, [
data_type,
:public,
:named_table,
read_concurrency: true,
write_concurrency: true
])
I store the ets
to disk at regular interval using the tab2file/2
and then read back using file2tab/2
anytime I restart the application and no issues reading and writing to the ets
and saving and restoring.
Issue
Initially the ets
were being initialized by a process managing connection to slack. The issue happened on the bag
type ets
where I couldn’t insert
and delete_object
and get argument error
when I switched the ets
to its own GenServer
for managing as everytime the slack websocket connection would break the slack process restarts causing the ets to get cleared and reload from file. In the new setup after reading the ets from file2 tab
saved by old setup using tab2file
I can do incr
on the set
type ets
. I didn’t find any documentation indicating that an ets
table written by a process or type of process can not be read/moved to another process for bag
or any other ets
type. I couldn’t reproduce the same issue on my local with the same design as I could insert
and delete_object
locally. Had to remove the tab on file to create fresh ets
to resolve the issue.
Would like to understand what could have caused this as they were public tables it should be able to insert
and delete_object
from any process(es) ?