fix(ets): route ETS-specific functions through sandbox adapter#37
Open
BobbieBarker wants to merge 1 commit intoMikaAK:mainfrom
Open
fix(ets): route ETS-specific functions through sandbox adapter#37BobbieBarker wants to merge 1 commit intoMikaAK:mainfrom
BobbieBarker wants to merge 1 commit intoMikaAK:mainfrom
Conversation
ETS-specific functions (update_counter, insert_raw, match_object) were bypassing sandbox isolation by calling :ets directly. This caused concurrent async tests to collide when using sandbox?: true with Cache.ETS adapter. Add defoverridable wrappers in the __using__ macro that prefix keys via maybe_sandbox_key and route through @cache_adapter when sandbox mode is enabled.
f201b7c to
5688897
Compare
Owner
|
I think this is a fundamental problem with the ets adapter, it probably should be calling something the module attribute to allow the sandbox switchover 🤔 |
Collaborator
I am open to feedback. If you want this to work differently let me know. I was optimistically trying to use the new ETS functionality you added, and found out that these functions don't play nice with the sandbox, so i whipped something up to cover the gap. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
update_counter/2,update_counter/3,insert_raw/1,match_object/1,match_object/2) were bypassing sandbox isolation by calling:etsdirectly instead of routing through@cache_adapterdefoverridablewrappers in the__using__macro (lib/cache.ex) that prefix keys viamaybe_sandbox_keyand dispatch through@cache_adapterwhensandbox?: trueandadapter: Cache.ETSCache.Sandbox) already had implementations for these functions — they just were never called from the generated moduleTest plan
test/cache/ets_sandbox_test.exswith 11 tests verifying sandbox isolation for all affected functionsredis_json_test.exsis pre-existing and unrelated)