spring-projects / spring-projects/spring-session

Concurrency issue still possible with OracleJdbcIndexedSessionRepositoryCustomizer

Open
#1,790 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage type: bug
Dominant language
Java
Stars
1.9k
Forks
1.2k
Avg merge
4h 27m
Merged PRs (30d)
55

Description

In specific circumstances there is still a concrete chance to run into concurrency issues.

The reason lies in the use of the MERGE SQL statement which, albeit elegant, doesn't prevent a unique constraint violation in this case: 1) connection A adds attribute X, 2) connection B adds attribute X, 3) connection A commits, 4) connection B gets a unique constraint violation.

A way to reduce greatly the frequency of the problem is to replace the MERGE with an anonymous PL/SQL block of the form

BEGIN
INSERT ...
EXCEPTION
WHEN DUP_VAL_ON_INDEX THEN
UPDATE ...
END;

This statement is less compact and less elegant, but nearly eliminates the problem described above.

I will open a PR with a working implementation.

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.

Research direction

Start at OracleJdbcIndexedSessionRepositoryCustomizer and inspect the MERGE SQL used when attributes are added. Replace the concurrency-prone operation with the proposed anonymous PL/SQL insert/update flow, then verify that the concurrent duplicate-attribute scenario no longer produces a unique constraint violation.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring, sql
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.