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

[NEW] theoretical / experimental take on mongo-backend sessions #13424

Closed
wants to merge 5 commits into from

Conversation

faust64
Copy link

@faust64 faust64 commented Feb 9, 2019

Eventually, would address #10714

Didn't look at the docs yet, although there would be stuff to update.

This PR is mostly sent as a theoretical take on moving rocket's in-memory sessions storage into mongodb.

I did not test this code!

Excluding package-lock, avoiding to bump dependencies I didn't mean to upgrade in the first place, ... pending further discussions, especially regarding configuration / environment variables we'ld want to use initializing mongodb sessions store

as discussed in RocketChat#10714

excluding package-lock, avoiding to bump dependencies I didn't mean to
upgrade in the first place, ... pending further discussions, especially
regarding configuration / environment variables we'ld want to use
initializing mongodb sessions store
@CLAassistant
Copy link

CLAassistant commented Feb 9, 2019

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@sampaiodiego sampaiodiego left a comment

Choose a reason for hiding this comment

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

Thanks @faust64 .. This is something we need for some time now but haven't time to look at.

Per CI tests seems your are not correct though:
Exception in callback of async function: TypeError: Cannot read property 'Store' of undefined

I'll need to give it a try to see what is going on.

I added some questions inplace, hope you don't mind answering.. thanks =)

@sampaiodiego sampaiodiego added this to the 0.75.0 milestone Feb 13, 2019
@faust64
Copy link
Author

faust64 commented Feb 16, 2019

Not sure what's next, @sampaiodiego , is everything OK? is it normal the build-and-test/hold jobs is still pending?

@sampaiodiego
Copy link
Member

thanks again @faust64 .. yes, the hold job stays pending, that's normal. I'll take a look again on this PR later this week.

Copy link
Member

@rodrigok rodrigok left a comment

Choose a reason for hiding this comment

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

Getting this error when trying to run it locally:

I20190304-11:36:15.406(-3)? Exception in callback of async function: TypeError: require(...) is not a function
I20190304-11:36:15.406(-3)?     at index.js (packages/rocketchat:grant/server/index.js:24:24)
I20190304-11:36:15.407(-3)?     at fileEvaluate (packages/modules-runtime.js:336:7)
I20190304-11:36:15.407(-3)?     at Module.require (packages/modules-runtime.js:238:14)
I20190304-11:36:15.407(-3)?     at require (packages/modules-runtime.js:258:21)
I20190304-11:36:15.407(-3)?     at /Users/rodrigonascimento/Projects/Rocket.Chat/.meteor/local/build/programs/server/packages/rocketchat_grant.js:806:15
I20190304-11:36:15.407(-3)?     at /Users/rodrigonascimento/Projects/Rocket.Chat/.meteor/local/build/programs/server/packages/rocketchat_grant.js:811:3
I20190304-11:36:15.407(-3)?     at /Users/rodrigonascimento/Projects/Rocket.Chat/.meteor/local/build/programs/server/boot.js:411:36
I20190304-11:36:15.407(-3)?     at Array.forEach (<anonymous>)
I20190304-11:36:15.407(-3)?     at /Users/rodrigonascimento/Projects/Rocket.Chat/.meteor/local/build/programs/server/boot.js:220:19
I20190304-11:36:15.407(-3)?     at /Users/rodrigonascimento/Projects/Rocket.Chat/.meteor/local/build/programs/server/boot.js:471:5
I20190304-11:36:15.407(-3)?     at Function.run (/Users/rodrigonascimento/Projects/Rocket.Chat/.meteor/local/build/programs/server/profile.js:510:12)
I20190304-11:36:15.407(-3)?     at /Users/rodrigonascimento/Projects/Rocket.Chat/.meteor/local/build/programs/server/boot.js:470:11

storeAddress += '&connectTimeoutMS=1200';
}
}
const SessionStorage = require('connect-mongodb-session')(session);
Copy link
Member

Choose a reason for hiding this comment

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

Please use import rather than require

const SessionStorage = require('connect-mongodb-session')(session);
const store = new SessionStorage({
collection: process.env.SESSION_COLLECTION || 'rocketchat_grant_sessions',
databaseName: process.env.SESSION_DATABASE || 'rocketchat',
Copy link
Member

Choose a reason for hiding this comment

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

Would this force the rocketchat database instead of getting from connection URI?

@infowolfe
Copy link

infowolfe commented Apr 22, 2019

@faust64 ping on this, please accept the CLA and update to latest master. This PR might have the added side effect of not requiring us to use session/server affinity in HA setups since session data would then be shared, rather than server-local.

I'm personally very much interested in seeing this make it into rocket.chat.

@engelgabriel engelgabriel modified the milestones: 1.0.0, 1.1.0 Apr 29, 2019
@rodrigok rodrigok modified the milestones: 1.1.0, 1.2.0 May 15, 2019
@filipef101
Copy link

@rodrigok @engelgabriel @faust64 @sampaiodiego
When is this expected to make it to master? Thanks

@filipef101
Copy link

@faust64 Can you sign the CLA? thanks

@infowolfe
Copy link

@filipef101 it seems that he already signed the CLA repeatedly, but the CLA site is broken as heck. If someone else wants to pick this up and apply the requested changes I'm pretty sure faust is good with that as he has no further interest in contributing to Rocket.Chat (as per an email from him yesterday) due to arduous contributing requirements and concerns relating to scalability.

@engelgabriel engelgabriel modified the milestones: 1.2.0, 1.3.0 Jul 10, 2019
@engelgabriel
Copy link
Member

The MemoryStore warning regarding memory leak only really applies if you enable our GraphQL experimental feature. Normal operations of the server are not affected, as we don't use ExpressJS for any other APIs. Having said that, we are planning to remove the GraphQL implementation from the main codebase and leave it to be added later as an auxiliary Apolo base project.

@infowolfe
Copy link

@engelgabriel That's weird, because Rocket.Chat 1) doesn't have a shared session store, making HA really annoying and 2) has had memory leaks even without GraphQL enabled in my usage.

@engelgabriel
Copy link
Member

See #14959

@engelgabriel
Copy link
Member

engelgabriel commented Jul 10, 2019

@infowolfe the GraphQL disable option was designed in a way that it does not really turn off GraphQL, it just makes the reply a 404.

@engelgabriel
Copy link
Member

engelgabriel commented Jul 10, 2019

And it is not correct that Rocket.Chat does not have a shared session store, Meteor uses MongoDB to store the session authentication token.

@infowolfe
Copy link

If that's the case, then why is it that I need to use session affinity in my load balancer in order for rocket.chat to not break completely?

@engelgabriel
Copy link
Member

@infowolfe this only happens if you are not using WebSockets for the real-time data.

Please see the link below for reference.
https://stackoverflow.com/questions/22594942/sockjs-and-meteor-what-if-load-balancer-do-not-support-sticky-sessions

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.

7 participants