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

FISH-766 Improper session synchronization of session map #4479

Merged

Conversation

sgflt
Copy link
Contributor

@sgflt sgflt commented Feb 9, 2020

Description

This is a bug fix of #4280

Important Info

Dependant PRs

Blockers

Testing

New tests

none

Testing Performed

none

Test suites executed

none

Testing Environment

Documentation

Notes for Reviewers

Reviewer should check the synchronization was incorrect (asymetric) and now each write attempt is locked to prevent readers to receive ConcurrentModificationException.

sgflt added 2 commits February 9, 2020 13:05
- cache could be read by another thread and put caused ConcurrentModificationException
- synchronization object should be final, that is what Sonar said
@rdebusscher rdebusscher added the PR: Awaiting CLA Contributor does not have a CLA or has submitted an unconfirmed CLA. label Feb 11, 2020
@rdebusscher
Copy link

@sgflt We are awaiting the signed CLA (https://github.com/payara/Payara/blob/master/PayaraCLA.pdf) otherwise we need to close this PR.

@rdebusscher rdebusscher added the Status: Abandoned User has not supplied reproducers for bug report, soon to be closed if user doesn’t come back label Apr 3, 2020
@smillidge smillidge added PR: CLA CLA submitted on PR by the contributor and removed PR: Awaiting CLA Contributor does not have a CLA or has submitted an unconfirmed CLA. labels Apr 6, 2020
@smillidge
Copy link
Contributor

We've got the CLA

@rdebusscher rdebusscher added community-contribution and removed Status: Abandoned User has not supplied reproducers for bug report, soon to be closed if user doesn’t come back labels Apr 6, 2020
Copy link
Contributor

@lprimak lprimak left a comment

Choose a reason for hiding this comment

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

Instead of synchronized keyword around HashMap,
why don't you replace it with ConcurrentHashMap instead?

@sgflt
Copy link
Contributor Author

sgflt commented Jun 24, 2020

Just for minimal change. But why not. I can try to use ConcurrentHashMap.

@sgflt
Copy link
Contributor Author

sgflt commented Jul 19, 2020

WIP: Replacing synchronized by ConcurrentHashMap is not so trivial. Some parts of code have different semantics that may break session management. Anyways I am keeping to dig deeper.

@sgflt
Copy link
Contributor Author

sgflt commented Jul 19, 2020

What does S1AS8 6155481 START kind of comments mean? Are they useful or just garbage?

@lprimak
Copy link
Contributor

lprimak commented Jul 19, 2020

I think that's remanents of Sun / Oracle issue tracking before JIRA -type or source control integration

@lprimak
Copy link
Contributor

lprimak commented Jul 19, 2020

WIP: Replacing synchronized by ConcurrentHashMap is not so trivial. Some parts of code have different semantics that may break session management. Anyways I am keeping to dig deeper.

why not? I don't see any difference with that and synchronize, except synchronize has to be used in all parts of the code (even future parts) but not ConcurrentHashMap

}
this.cache.forEach((ssoId, sso) -> {
if (sso.isEmpty() && sso.getLastAccessTime() < tooOld) {
removals.add(ssoId);
}
Copy link
Contributor Author

@sgflt sgflt Jul 19, 2020

Choose a reason for hiding this comment

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

There is a little change in behavior.

Old implementation locked SSOs and created a list of expired SSOs. No one could create a new SSO.

New implementation uses what is available and does not block creation of a new SSO (which is not taken for expiration in given round). However probability of a new SSO being expired is so small so I think this change should be OK for a real world usage.

@sgflt sgflt marked this pull request as draft July 19, 2020 17:47
@@ -985,16 +982,14 @@ public void processExpires() {

long timeNow = System.currentTimeMillis();

Session[] sessions = findSessions();
if (sessions != null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nullcheck for broken contract removed

@@ -882,21 +881,19 @@ public void stop(boolean isShutdown) throws LifecycleException {
}

// Expire all active sessions and notify their listeners
Session sessions[] = findSessions();
if (sessions != null) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nullcheck for broken contract removed

@@ -111,8 +111,8 @@ public void clearSessions() {
}

@Override
public Session[] findSessions() {
return null;
Copy link
Contributor Author

@sgflt sgflt Jul 19, 2020

Choose a reason for hiding this comment

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

broken contract fixed

@dmatej
Copy link
Contributor

dmatej commented Jul 20, 2020

What does S1AS8 6155481 START kind of comments mean? Are they useful or just garbage?

S1AS8 means SunOne Application Server 8 which used same system as the Sun JDK, now dead.

@sgflt sgflt marked this pull request as ready for review July 21, 2020 05:38
@MeroRai
Copy link
Member

MeroRai commented Nov 17, 2020

jenkins test please

@MeroRai MeroRai changed the title Fixes #4280 improper session synchronization FISH-766 Improper session synchronization of session map Nov 18, 2020
@MeroRai MeroRai merged commit 0892dff into payara:master Nov 18, 2020
cubastanley added a commit to cubastanley/Payara that referenced this pull request Dec 4, 2020
…-session-synchronization"

This reverts commit 0892dff, reversing
changes made to 39d14da.
Cousjava pushed a commit to Cousjava/Payara that referenced this pull request Jan 27, 2021
…-synchronization

 FISH-766 Improper session synchronization of session map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: CLA CLA submitted on PR by the contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants