Resolve ETS table names only once per function call#10536
Resolve ETS table names only once per function call#10536sverker merged 5 commits intoerlang:maintfrom
Conversation
CT Test Results 2 files 97 suites 1h 9m 34s ⏱️ Results for commit bb71d64. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts
// Erlang/OTP Github Action Bot |
There was a problem hiding this comment.
Pull request overview
This PR modifies several ETS and DETS functions to resolve table names to table identifiers (TIDs) only once at the beginning of each function call. This prevents issues that could occur if a named table is deleted and recreated by a concurrent process during function execution.
Changes:
- Updated
ets:init_table/2,ets:tab2file/3,ets:table/2, andets:i/3to resolve table names once at function entry - Updated
dets:from_ets/2anddets:to_ets/2to resolve ETS table names once at function entry - Enhanced
ets:whereis/1documentation to explain the consistency benefit - Updated test expectations for
tab2fileto handle new error return format
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/stdlib/src/ets.erl | Resolves table names to TIDs at function entry for init_table, tab2file, table, and i; updates whereis documentation; adds error handling for private tables in tab2file |
| lib/stdlib/src/dets.erl | Adds ensure_ets_tid helper; updates from_ets and to_ets to resolve ETS table names once |
| lib/stdlib/test/ets_SUITE.erl | Updates test to expect error tuple return instead of exception for tab2file with bad tables |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d9f918b to
28e2219
Compare
Yes, ets:tab2file for some reason returns error tuple for bad table instead of badarg exception like all others. So we make tab2file more consistent with itself.
into maint as 'sverker/stdlib/ets-one-name-lookup/OTP-19911'
f013624 to
bb71d64
Compare
Prevent strange effects if the named table is deleted and recreated by a concurrent process during the function call.
Fixed functions are
ets:init_tableets:tab2fileets:tableets:idets:from_etsdets:to_ets