spring-projects / spring-projects/spring-session

Improve data consistency documentation

Open
#1,975 1 comment 0 reactions 1 assignee View on GitHub

@eleftherias is already working on this.

Since Dec 14, 2021.

in: docs type: enhancement
Dominant language
Java
Stars
1.9k
Forks
1.2k
Avg merge
4h 27m
Merged PRs (30d)
55

Description

I have some questions about what data consistency guarantees spring boot session jdbc provides.

Suppose we have this scenario:

  • A stateful session in a spring boot application with spring session jdbc. Every request updates the session.
  • 2 containers running with the same application
  • 1 database with jdbc driver
  • A reverse proxy with round robin (No sticky session) A client making parallel requests to the server

Questions:

  • When the first request hits Container A in order to reads a session from DB, is there a lock on the object?
  • If there is no lock on read, but only on write operation, what happens if a second request hits container B before request on container A has saved the session?
  • Do we have to assume a last-write-wins semantics? Probably yes based on this answer
  • Can we have stale data read?
  • If we look at this example (https://docs.spring.io/spring-session/reference/api.html) can I state that in order to reduce data inconsistency I have to reduce as much as possible the time between session read (session.getAttribute(...)) and session save (4)?

I suggest to improve the documentation to better explain what data consistency guarantee spring boot session has for the different back-ends. For example wildfly use infinispan to manage distributed cache and has a good documentation on this.

A possible workaround is to use sticky sessions (optional, can be enabled only when required) to have stronger data consistency. With sticky session some optimization are possible: reads come from jvm memory objects, writes to persistent storage can be async. See issue 6

Thank you for your help and feedback.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.