spring-projects / spring-session-data-mongodb

Spring Session for MongoDB
https://spring.io/projects/spring-session-data-mongodb
Apache License 2.0
50 stars 35 forks source link

Consider adding support for writing delta of changes #106

Open vpavic opened 5 years ago

vpavic commented 5 years ago

Generally, session repository implementations should track changes to session and write only delta in order to reduce the probability of lost updates due to race conditions.

Additionally, if this is implemented also consider supporting SaveMode to allow flexibility.

All session repositories in Spring Session core modules support this and could be used for inspiration.

stefanbethke commented 4 years ago

Please add information to the documentation about this serious limitation! We did some simple load testing between Redis and MongoDB, and found them to be roughly equivalent in our environment, so we went with MongoDB because the application already uses MongoDB, and we have a team maintaining a MongoDB cluster for us, so wie didn't need to figure out how to run Redis in production.

However, we have relatively complex login logic, where a request starts on the server, then some backend systems are queried, and finally the user is logged in, all via Spring Security and custom providers. It took us about 5 person-days to figure out that the race conditions we were seeing had nothing to do with our specific setup, but are a limitation of the spring-session-data-mongodb.

I personally believe that a session repository that allows race conditions like these is pretty much useless for all but the most simple cases.