-
-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure sessions are correctly deleted from ETS by passing the pid along #558
Conversation
Codecov Report
@@ Coverage Diff @@
## master #558 +/- ##
=======================================
Coverage 92.73% 92.73%
=======================================
Files 26 26
Lines 853 853
=======================================
Hits 791 791
Misses 62 62
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
pid
along
Thanks for the PR! Do you mind adding some tests? |
There are currently no tests for |
It think it's fine to create a new unit test module for the session store, and test that it can store and delete multiple sessions for the same test pid, and remove them both when that test pid goes down. |
lib/wallaby/session_store.ex
Outdated
|
||
case result do | ||
[{ref, _}] -> | ||
[{ref, pid, _session}] -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be [{ref, _session, pid}]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, but I can switch the return value order to match the way the data is stored in ETS. This match is based on the way the result is returned from, not stored in ETS (you can see the :ets.delete
call matches the storage order.
EDIT: The ordering is a result of this call:
result =
:ets.select(:session_store, [
{{{:"$1", :"$2", :"$3"}, :"$4"}, [{:==, :"$2", session.id}], [{{:"$1", :"$3", :"$4"}}]}
])
I can swap the [{{:"$1", :"$3", :"$4"}}]}
and make it [{{:"$1", :"$4", :"$3"}}]}
to keep the order matched.
However, do we really even need to return the session
itself? We could probably get away with just returning the session.id
value (or not at all). We already have the session
passed in, and only need the session.id
to successfully delete.
EDIT 2: I think it'd be worth making that return value just the ref, pid
pair, because we can use that + the passed in session.id
to cleanly and correctly delete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see now that I misread it.
…om the ETS table on monitor/demonitor calls, as expected
@mhanberg added a couple straightforward tests to verify the ETS table adds & correctly removes sessions. I also streamlined the queries just a tad for unused params |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks!
Happy to help! |
@mhanberg sorry to comment again on a closed PR, but wanted to check in on what the release cycle is like for wallaby being updated in Hex? Would love to have this fix available, and curious if I should install from github, or if a new release will be made with this fix? |
I'm currently adding some more tests. I'll release a patch release once I'm done with that. You can install from github master until then if you'd like. |
ETS records weren't being correctly removed from
SessionStore
, leaving stale sessions around inSessionStore.list_sessions_for
. By returning thepid
from the:ets.select
, we can ensure a correct match & delete of the session.Could be useful to add a
defdelegate active_sessions
in the mainWallaby
interface that callsSessionStore.list_sessions_for
, but didn't want to make that assumption in this PR.Fixes the issue pointed out in #550