[erlang-questions] Is ets:insert/2 (with multiple objects) isolated with respect to concurrent readers?

Ulf Wiger ulf.wiger@REDACTED
Tue Jun 30 22:49:40 CEST 2009

Chris Newcombe wrote:
> Please could the isolation behavior be officially documented for
> ets:insert, ets:insert_new, and ets:delete_all_objects?

Granted, you're asking for official documentation, and I
agree that this is important.

Meanwhile, the implementation (R13B01) of ets:insert/2
takes a table lock if the second argument is a non-empty
list in order to ensure atomicity. Same with insert_new().

  /* Write lock table if more than one object to keep atomicy */
  kind = ((is_list(BIF_ARG_2) && CDR(list_val(BIF_ARG_2)) != NIL)
          ? LCK_WRITE : LCK_WRITE_REC);

Since write locks are exclusive (no reads allowed while a
resource is write-locked), isolation will also hold.

Ulf W
Ulf Wiger
CTO, Erlang Training & Consulting Ltd

More information about the erlang-questions mailing list