Sessions should be shared based on parameters
Reported by Paul Jones | March 9th, 2011 @ 08:49 AM | in 0.9.3
The initial design of the SessionManager always included the intent to share sessions when their creation parameters were the same. We don't currently do this, causing a full system sync (see #195) every time a browser session is opened. #195 addresses making this behaviour more lightweight, but we should also consider sharing sessions where possible.
Comments and changes to this ticket
-

Ben Hood March 9th, 2011 @ 11:50 PM
I thought that the session parameters were used as a key for locating
the session cache - does this not give you implicit session sharing
without a resync? -

Paul Jones March 10th, 2011 @ 08:13 AM
So after some further tracing, blaming the DefaultSessionManager was wrong. It hashes the start, end and scope to generate a key, which should result in stable sessions. However, even though the date bounds are currently ignored, the DifferencesResource calls the start/1 method, which applies a start and end time of now +/- 1 year, which changes with each subsequent request.
Given we're currently ignoring the date bounds in the session manager, I think we should change the defaultDateBounds to be null/null, making the call more accurate, and allowing us to share sessions.
-

Ben Hood March 10th, 2011 @ 09:33 AM
(from [19667c70eec21d542be9c580b7f44465ac864ebe]) [#196] Use more stable time bounds to make sessions share. Add REST method for forcing session sync https://github.com/lshift/diffa/commit/19667c70eec21d542be9c580b7f4...
-

Paul Jones March 10th, 2011 @ 09:38 AM
- State changed from new to open
The change in the SessionManager is trivial to fix this. However, making the tests all work again turns out to be quite a Rabbit-hole (and partially infringes on the changes necessary to make #195 a reality).
Once sessions are shared, the test cases (which have an implicit assumption that sessions will always sync on creation) start to fail. So I've added a REST method for forcing a synchronisation. Synchronisation on top of an active session was never previously an expected behaviour, so mismatches that were corrected were never detailed to the session. I've changed this so that a sync operation generates match events as it goes, so at the completion of a sync, both matches and mismatches will have been generated.
Given I've come this far, I think the one final piece of implementation to put in place under this ticket will be the ability to query the sync state of a session. This should hopefully eliminate a number of race conditions that have appeared in the tests with the previous change to async session filling, and also provide almost all of the pieces necessary to do #195 cleanly.
-

Ben Hood March 10th, 2011 @ 12:37 PM
I didn't quite follow the last paragraph - what does it mean exactly
to query the sync state of a session? In what situations is this going
to be useful? -

Paul Jones March 10th, 2011 @ 12:45 PM
In the integration tests, there are currently lots of race conditions where we poll the session waiting for events to arrive. We assume that the sync is complete when some events are added into the session - if more events are later added, then we won't see this. Also, if the session has previous data in it (such as now, when the session is re-used), if we poll it before the sync has finished and cleared out the stale events then the test will fail because the wrong events are in the session. We currently prevent this by sleeping and hoping we've slept long enough for the actions to occur.
A more stable behaviour is for the tests to be able to poll for whether the difference/sync operation has completed yet, and only start inspecting the state once it has.
This behaviour is probably also going to be necessary once syncs are able to be triggered manually, since the Web UI is going to need some way of showing what is going on in the background.
-

Ben Hood March 10th, 2011 @ 12:57 PM
Ok, so it's just a simple query to let the observer know whether there
is currently a sync occurring in the session or not. -

Paul Jones March 10th, 2011 @ 01:03 PM
From an outside perspective, yes. Internally, we'll need to keep a state map in order to make that information available.
-

Ben Hood March 10th, 2011 @ 02:33 PM
(from [a882b48b54178e4ba865b393af7513101316aa91]) [#196] Make the SessionManager track the synchronisation state of pairs, and report them for sessions. https://github.com/lshift/diffa/commit/a882b48b54178e4ba865b393af75...
-

Ben Hood March 10th, 2011 @ 03:14 PM
(from [6ca9946c6ef185cd82fa4b6f176235af76d5ffc7]) [#196] Make sync state available via Differences REST api. Make the tests consume it too. https://github.com/lshift/diffa/commit/6ca9946c6ef185cd82fa4b6f1762...
-

Paul Jones March 10th, 2011 @ 03:16 PM
- State changed from open to resolved
- Assigned user set to Ben Hood
I've added the ability to track these changes now, and updated the tests to use them. If its any consolation, I actually think it shaved quite a few seconds off the build.
-

-

Ben Hood March 11th, 2011 @ 02:47 AM
- State changed from resolved to closed
Added to merge-commit:
- Spelling of synchronization
- Added MandatoryParams annotation to DifferencesResource
but other than that, QA+
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
A Real Time Differencing Tool.
People watching this ticket
Referenced by
-
196
Sessions should be shared based on parameters
(from [19667c70eec21d542be9c580b7f44465ac864ebe])
[#196] ...
-
196
Sessions should be shared based on parameters
(from [a882b48b54178e4ba865b393af7513101316aa91])
[#196] ...
-
196
Sessions should be shared based on parameters
(from [6ca9946c6ef185cd82fa4b6f176235af76d5ffc7])
[#196] ...
-
196
Sessions should be shared based on parameters
(from [1ac0455f25758b3e1d2037f47a82b362470b614e])
Merged ...