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

6035 memory leaks #6143

Merged
merged 10 commits into from
Sep 10, 2019
Merged

6035 memory leaks #6143

merged 10 commits into from
Sep 10, 2019

Conversation

landreev
Copy link
Contributor

@landreev landreev commented Sep 5, 2019

New Contributors

Welcome! New contributors should at least glance at CONTRIBUTING.md, especially the section on pull requests where we encourage you to reach out to other developers before you start coding. Also, please note that we measure code coverage and prefer you write unit tests. Pull requests can still be reviewed without tests or completion of the checklist outlined below. Thanks!

Related Issues

closes #6035

Pull Request Checklist

…logged in users,

while keeping the anonymous sessions limited to the shorter default value
(as specified in web.xml). #6035
@dataversebot
Copy link

Can one of the admins verify this patch?

@coveralls
Copy link

coveralls commented Sep 5, 2019

Coverage Status

Coverage decreased (-0.004%) to 19.484% when pulling 5e47e25 on 6035-memory-leaks into 09fe94b on develop.

@landreev
Copy link
Contributor Author

landreev commented Sep 5, 2019

One specific area I want somebody who understands how different types of authentication work to review:
Our strategy is to keep the anonymous sessions short - by keeping the default session timeout (the value configurable in web.xml) short; and then increase the timeout for logged-in users, to something configurable as a setting.
It looks like this needs to happen in several places, not just the login page. I'm doing it in the following places:

src/main/java/edu/harvard/iq/dataverse/LoginPage.java
src/main/java/edu/harvard/iq/dataverse/authorization/providers/builtin/DataverseUserPage.java
src/main/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/OAuth2FirstLoginPage.java
src/main/java/edu/harvard/iq/dataverse/authorization/providers/oauth2/OAuth2LoginBackingBean.java
src/main/java/edu/harvard/iq/dataverse/confirmemail/ConfirmEmailPage.java
src/main/java/edu/harvard/iq/dataverse/passwordreset/PasswordResetPage.java
src/main/java/edu/harvard/iq/dataverse/privateurl/PrivateUrlPage.java
src/main/java/edu/harvard/iq/dataverse/Shib.java

It's possible that it's not strictly necessary in some of the places above (in some cases the user may be redirected back to the login page, for example, and the session timeout will be increased there - ?) - but it shouldn't hurt either. I'm more concerned about missing something.

Copy link
Member

@pdurbin pdurbin left a comment

Choose a reason for hiding this comment

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

"Request changes" seems too strong because this is a really good pull request but @landreev if you would document the new :LoginSessionTimeout option both in the Installation Guide (config page) and maybe at doc/release-notes/4.17-release-notes.md (new process) it would be much appreciated.

Also, what about log out? Should we consider destroying the session on logout? Here's a TODO comment in diff:

diff --git a/src/main/java/edu/harvard/iq/dataverse/DataverseHeaderFragment.java b/src/main/java/edu/harvard/iq/dataverse/DataverseHeaderFragment.java
index 0085c395f..0fedc38c6 100644
--- a/src/main/java/edu/harvard/iq/dataverse/DataverseHeaderFragment.java
+++ b/src/main/java/edu/harvard/iq/dataverse/DataverseHeaderFragment.java
@@ -220,6 +220,7 @@ public class DataverseHeaderFragment implements java.io.Serializable {
     public String logout() {
         dataverseSession.setUser(null);
         dataverseSession.setStatusDismissed(false);
+        // TODO: destroy session here somehow?
 
         String redirectPage = navigationWrapper.getPageFromContext();
         try {

HttpSession httpSession = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);

if (httpSession != null) {
logger.info("jsession: "+httpSession.getId()+" setting the lifespan of the session to " + systemConfig.getLoginSessionTimeout() + " minutes");
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be reduced to logger.fine.

src/main/java/edu/harvard/iq/dataverse/Shib.java Outdated Show resolved Hide resolved
@@ -55,6 +55,7 @@ public String init() {
if (confirmEmailData != null) {
user = confirmEmailData.getAuthenticatedUser();
session.setUser(user);
session.configureSessionTimeout(); // TODO: is this needed here? (it can't hurt, but still)
Copy link
Member

Choose a reason for hiding this comment

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

Yes, this is needed here. This is a builtin user who just reset their password.

<session-timeout>
1440
10
Copy link
Member

Choose a reason for hiding this comment

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

Nice and short. 10 minutes. Perfect. Let's try it. 😄


.. code-block:: bash

#!/bin/sh
Copy link
Member

Choose a reason for hiding this comment

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

We could refactor this into a downloadable script and also continue to inline it. Here's an example of where we do that (the "clear timer" script): http://guides.dataverse.org/en/4.16/admin/troubleshooting.html#deployment-fails-ejb-timer-service-not-available

@kcondon
Copy link
Contributor

kcondon commented Sep 9, 2019

Tested, this is ready to go, pending a release notes update.

@landreev landreev removed their assignment Sep 10, 2019
@kcondon kcondon self-assigned this Sep 10, 2019
@kcondon kcondon merged commit 729101f into develop Sep 10, 2019
@kcondon kcondon deleted the 6035-memory-leaks branch September 10, 2019 18:52
@djbrooke djbrooke added this to the 4.17 milestone Sep 18, 2019
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.

Memory leak when dataverse is stressed with GET requests
6 participants