Skip to content

Conversation

@mergify
Copy link

@mergify mergify bot commented Jul 12, 2024

See #11667 (comment)

ets:whereis/1 adds some overhead - it's two ETS calls rather than one when ets:whereis/1 returns a table identifier. It's also not atomic: the table could disappear between ets:whereis/1 calls and the call to read data from a projection. We replace all ets:whereis/1 calls on projection tables with try/catch and return default values when we catch the badarg error which ETS emits when passed a non-existing table name.

One special case though is ets:info/2 which returns undefined when passed a non-existing table names. That block is refactored to use a case instead.


This is an automatic backport of pull request #11700 done by Mergify.

`ets:whereis/1` adds some overhead - it's two ETS calls rather than one
when `ets:whereis/1` returns a table identifier. It's also not atomic:
the table could disappear between `ets:whereis/1` calls and the call to
read data from a projection. We replace all `ets:whereis/1` calls on
projection tables with `try`/`catch` and return default values when we
catch the `badarg` `error` which ETS emits when passed a non-existing
table name.

One special case though is `ets:info/2` which returns `undefined` when
passed a non-existing table names. That block is refactored to use a
`case` instead.

(cherry picked from commit 9f255db)
@the-mikedavis the-mikedavis merged commit fc46884 into v4.0.x Jul 12, 2024
@the-mikedavis the-mikedavis deleted the mergify/bp/v4.0.x/pr-11700 branch July 12, 2024 22:36
the-mikedavis added a commit that referenced this pull request Jul 13, 2024
Use 'try'/'catch' rather than 'ets:whereis/1' for Khepri projections (backport #11700) (backport #11707)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants