Skip to content
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

SmrSession: allow active session for each game #368

Merged
merged 2 commits into from
Mar 6, 2018

Conversation

hemberger
Copy link
Member

Add a new method SmrSession::updateGame, which changes the
game_id, but also ensures that active sessions are unique for
each (account_id, game_id) pair.

This allows players to have multiple games open for the same
account (though in different browsers, due to the nature of the
browser cookies).

This is also an important step towards integrating multis into
the same account as the main.


Prerequisite commit
SmrSession: remove LIMIT 1 from deletion

One possible solution to (or mitigation of) the infrequent mysql error:

Duplicate entry '<hash>' for key 'PRIMARY'

is to remove the LIMIT 1 qualifier from the deletion that directly
precedes the INSERT that is causing this error.

The reason this may help is because certain incompletely understood
race conditions might result in an account having two active sessions.
Then when this deletion comes along, it removes one but not both of
these sessions. It is unclear why the primary keys would be identical.

The active_session table is small (due to pruning inactive sessions),
so having to process the entire table when creating a new session is
not going to impact performance at all.

One possible solution to (or mitigation of) the infrequent mysql error:

Duplicate entry '<hash>' for key 'PRIMARY'

is to remove the `LIMIT 1` qualifier from the deletion that directly
precedes the INSERT that is causing this error.

The reason this may help is because certain incompletely understood
race conditions might result in an account having two active sessions.
Then when this deletion comes along, it removes one but not both of
these sessions. It is unclear why the primary keys would be identical.

The `active_session` table is small (due to pruning inactive sessions),
so having to process the entire table when creating a new session is
not going to impact performance at all.
Add a new method `SmrSession::updateGame`, which changes the
`game_id`, but also ensures that active sessions are unique for
each (account_id, game_id) pair.

This allows players to have multiple games open for the same
account (though in different browsers, due to the nature of the
browser cookies).

This is also an important step towards integrating multis into
the same account as the main.
@hemberger hemberger merged commit 70bf5e2 into smrealms:master Mar 6, 2018
@hemberger hemberger deleted the multiple-sessions branch March 6, 2018 00:52
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