Writing to sessions unfortunately takes forever in mysql.

I think it would be awesome if this was ported back to D6.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

te-brian’s picture

FileSize
13.33 KB
19.91 KB

Here is my first stab at a 'backport'.

This is for testing and debugging only. I left in some debugging logic I was using in case someone needs to do some debugging on their own.

Some Notes:

- This was developed and tested in a pressflow install. As such it implements and uses some functions that only pressflow has. However, these functions only live in mongodb_session.inc, so in theory this should work with core drupal as well (please test).

- If you want to test this in a pressflow install you will have to apply the included patch which moves all the drupal_session_* functions from bootstrap.inc to session.inc. This allows mongodb_session.inc to override them, since they contain db_query writes. We will need to petition the guys at four kitchens to apply this patch once we are happy with this module.

Enjoy

crea’s picture

Status: Active » Needs work

The patch is too old

crea’s picture

Attaching my version of the patch. Depends on #1179402: Define REQUEST_TIME for backports for REQUEST_TIME support. Other than REQUEST_TIME, it follows D6 in every aspect: no lazy sessions, https stuff, etc.
I think for Pressflow its better to create separate .inc file

crea’s picture

Category: feature » task
Status: Needs work » Needs review
FileSize
15.26 KB

Better patch

crea’s picture

Status: Needs review » Needs work
crea’s picture

Status: Needs work » Needs review
FileSize
9.66 KB

Updated patch: no REQUEST_TIME dependency, no tests, variable collection name.
Btw, previous version worked for me without issues.

fgm’s picture

I wonder whether :

- it makes sense to create this version for core instead of Pressflow: can you really imagine a MongoDB deployment on a non-Pressflow instance ?
- we can have a test suite before committing

crea’s picture

I'm using D6 core myself :P

dob_’s picture

Got errors when i had no session.

My workaround:

$user = mongodb_collection(variable_get('mongodb_session', 'session'))->findOne(array('sid' => $sid));

if($user)
$user = (object)$user;

If this is not changed it tries to get the not set variable $user->uid and throws an exception.

crea’s picture

@dob_
You said you are using Pressflow. I wonder how you make this work, because Pressflow has different session functions and stuff (same as D7) and this patch is only for D6

I've encountered "non utf8 string" exceptions with my last patch. So I switched to using MongoBinData

crea’s picture

There's a bug in the previous patch: I forgot to unpack binary data for anonymous sessions.

crea’s picture

Status: Needs review » Needs work
crea’s picture

Status: Needs work » Needs review
FileSize
9.77 KB

Status: Needs review » Needs work

The last submitted patch, mongodb_session_1007974_13.patch, failed testing.

phayes’s picture

Status: Needs work » Reviewed & tested by the community

The d.o testbot doesn't have mongodb installed so obviously the test fails. I re-ran the test in my local environment with mongodb installed and all tests passed. Furthurmore, this patch seems to work great. Please commit!

phayes’s picture

Status: Reviewed & tested by the community » Needs work

I take it all back. This implementation is broken.

It puts the *entire* user object into mongo, then, when the session is instantiated, it does this:

global $user;
$user = $user_from_mongo;

This is bad because it's impossible to update a user without instantiating a session for that user. Expect many things to mysteriously break.

do not use this patch.

crea’s picture

AFAIR, the patch doesn't do anything different from the core D6, but I'll double check when I have time.

crea’s picture

Yeah, #16 makes sense. Original code gets user object from the user table.

fgm’s picture

Issue summary: View changes

Three years later and no working version, can we agree to close this and say there will never be a stable 6.x version for sessions ?

slashrsm’s picture

Status: Needs work » Closed (won't fix)

Agreed. If there is still anyone out there that needs this feel free to reopen and bring patch to RTBC state. Maintainers will be happy to commit it in that case.