Skip to content

Commit dbf156b

Browse files
authored
fix(runtime): preserve ETS tables for configured heirs
Live heirs recover table contents and ownership before exit notifications. Heirs receive transfer messages with gift data that survives garbage collection. Missing, dead and self heirs retain table-deletion behavior.
1 parent da0f5b4 commit dbf156b

7 files changed

Lines changed: 589 additions & 57 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,26 @@ All notable milestones for the nera project are documented in this file.
5959
- Direct compile-error regressions cover `/bitstring-unit:8`, a zero `/bits`
6060
unit and an out-of-range `/bitstring` pattern unit.
6161

62+
## ETS tables survive owner exit through their configured heir
63+
64+
- `ets:new/2` honours `{heir, Pid, GiftData}`: a live heir inherits the
65+
table and its contents before the old owner's `EXIT` or `DOWN` signals,
66+
and receives `{'ETS-TRANSFER', Table, OldOwner, GiftData}`.
67+
- Gift data owns its storage across the creator's garbage collection and
68+
exit. `ets:info/1,2` includes the configured heir, or `none`.
69+
- Tables without an heir, with a dead heir, or with the exiting owner itself
70+
as heir are deleted. Explicit table deletion does not notify the heir.
71+
- The legacy `{heir, Pid}` option transfers without a notification;
72+
`{heir, none}` disables inheritance. Later heir options take precedence.
73+
- `ets_heir` checks named and unnamed tables of all four types, four exit
74+
paths, gift lifetime, manual ownership transfer and concurrent heir exit,
75+
unchanged natively and on BEAM. Changing heirs with `ets:setopts/2`
76+
remains unsupported.
77+
6278
## Process exits release ETS tables before exit signals
6379

64-
- A dead process's ETS tables are deleted before linked processes receive
65-
`EXIT` or monitoring processes receive `DOWN`, as on BEAM. This also covers
80+
- A dead process's ETS tables without a live heir are deleted before linked
81+
processes receive `EXIT` or monitoring processes receive `DOWN`, as on BEAM. This also covers
6682
processes killed by a linked process's exit.
6783
- A child restarted by its supervisor can immediately create the same named
6884
table without racing the previous owner's cleanup.

‎FEATURES.md‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ process dictionary under `rand_seed`.
518518

519519
| Function | Status | Notes |
520520
|----------------------|--------|-------------------------------------|
521-
| new/2 | ✅ | `set`, `ordered_set`, `bag`, `duplicate_bag`, `named_table`, `{keypos, N}`; returns the name for a `named_table`, otherwise an integer table identifier (BEAM returns a reference) |
521+
| new/2 | ✅ | `set`, `ordered_set`, `bag`, `duplicate_bag`, `named_table`, `{keypos, N}`, `{heir, Pid, GiftData}`, `{heir, none}`; returns the name for a `named_table`, otherwise an integer table identifier (BEAM returns a reference) |
522522
| insert/2 | ✅ | Single or list of tuples |
523523
| lookup/2 | ✅ | Returns list of matching tuples |
524524
| delete/1 | ✅ | Delete table |
@@ -527,7 +527,7 @@ process dictionary under `rand_seed`.
527527
| match_object/2 | ✅ | Simple pattern matching |
528528
| select_delete/2 | ✅ | Match spec for conditional delete |
529529
| tab2list/1 | ✅ | |
530-
| info/1,2 | ✅ | `size`, `name`, `type`, `keypos` |
530+
| info/1,2 | ✅ | `size`, `name`, `type`, `keypos`, `owner`, `heir`; `memory` in info/2 |
531531
| update_counter/3 | ✅ | Atomic counter increment (set/ordered_set only) |
532532
| update_element/3 | ✅ | Update tuple element by position (set/ordered_set only) |
533533
| give_away/3 | ✅ | Transfer table ownership |
@@ -542,6 +542,12 @@ process dictionary under `rand_seed`.
542542
| bag | ✅ | Multiple values per key, no exact duplicates |
543543
| duplicate_bag | ✅ | Multiple values per key, duplicates allowed |
544544

545+
A live configured ETS heir inherits ownership and contents before the old
546+
owner's exit signals, receiving `{'ETS-TRANSFER', Table, OldOwner, GiftData}`.
547+
The legacy `{heir, Pid}` option transfers without a notification. Dead or
548+
self heirs do not preserve a table on owner exit. `ets:setopts/2` is not
549+
implemented.
550+
545551
### timer module
546552

547553
| Function | Status | Notes |

0 commit comments

Comments
 (0)