Skip to content

Resolve ETS table names only once per function call#10536

Merged
sverker merged 5 commits intoerlang:maintfrom
sverker:sverker/stdlib/ets-one-name-lookup/OTP-19911
Jan 21, 2026
Merged

Resolve ETS table names only once per function call#10536
sverker merged 5 commits intoerlang:maintfrom
sverker:sverker/stdlib/ets-one-name-lookup/OTP-19911

Conversation

@sverker
Copy link
Contributor

@sverker sverker commented Jan 12, 2026

Prevent strange effects if the named table is deleted and recreated by a concurrent process during the function call.

Fixed functions are

  • ets:init_table
  • ets:tab2file
  • ets:table
  • ets:i
  • dets:from_ets
  • dets:to_ets

@sverker sverker added this to the 28.4 milestone Jan 12, 2026
@sverker sverker self-assigned this Jan 12, 2026
@sverker sverker added team:VM Assigned to OTP team VM fix labels Jan 12, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2026

CT Test Results

    2 files     97 suites   1h 9m 34s ⏱️
2 215 tests 2 164 ✅ 51 💤 0 ❌
2 603 runs  2 547 ✅ 56 💤 0 ❌

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

@sverker sverker requested a review from Copilot January 12, 2026 17:42
@sverker sverker added the testing currently being tested, tag is used by OTP internal CI label Jan 12, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and ets:i/3 to resolve table names once at function entry
  • Updated dets:from_ets/2 and dets:to_ets/2 to resolve ETS table names once at function entry
  • Enhanced ets:whereis/1 documentation to explain the consistency benefit
  • Updated test expectations for tab2file to 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.

@sverker sverker force-pushed the sverker/stdlib/ets-one-name-lookup/OTP-19911 branch from d9f918b to 28e2219 Compare January 14, 2026 12:14
@sverker sverker requested a review from dgud January 14, 2026 14:04
dgud
dgud previously approved these changes Jan 14, 2026
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'
@sverker sverker force-pushed the sverker/stdlib/ets-one-name-lookup/OTP-19911 branch from f013624 to bb71d64 Compare January 19, 2026 14:15
@sverker sverker requested a review from dgud January 20, 2026 19:49
@sverker sverker merged commit 87154b5 into erlang:maint Jan 21, 2026
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants