Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-functioning session persistence when using JDBC over Infinispan #24766

Closed
1 task done
miroRucka opened this issue Nov 15, 2023 · 2 comments · Fixed by #24774
Closed
1 task done

non-functioning session persistence when using JDBC over Infinispan #24766

miroRucka opened this issue Nov 15, 2023 · 2 comments · Fixed by #24774
Labels
area/infinispan kind/bug Categorizes a PR related to a bug
Milestone

Comments

@miroRucka
Copy link

miroRucka commented Nov 15, 2023

Before reporting an issue

  • I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.

Area

infinispan

Describe the bug

Hello, I recently created a pull request regarding the issue of storing user sessions into the JDBC data layer through Infinispan. The PR also describes a use case.

PR link:

#24248

PR description:

The problem arises when the persistent jdbc layer is used to save the session. After logging in, the user session is only stored in memory and is not stored in the relational database as I would expect. However, in rare cases the saving works, but it was very accidental. After studying the integration code on infinispan, I discovered that the cache instance always returns with the SKIP_CACHE_STORE flag, which actually results in the avoidance of persistence. It complicates the use of keycloak for us, because after a restart, users are always logged out both on mobile devices and on websites. I have tested this fix and user sessions persist immediately after logging in. If you know another way to fix it, let me know, if there is no other way, it would be good to reconsider the purpose of the SKIP_CACHE_STORE flag. Well thank you.

I found the same problem on a forum as well. Also, there is a recorded response that describes the modification of CacheDecorators and a problematic flag.

Here is link:
https://stackoverflow.com/questions/76661708/infinispan-doesnt-write-any-sessions-in-jdbc-persisted-cache-in-keycloak-21-0-2

Please try to look into it to see if it is correct behavior, thank you.

Version

21.1.2

Expected behavior

I expect that with each login, sessions will be saved to the database and will not be lost upon restarting KC.

Actual behavior

Currently, the saving is random and in most cases, the session is not saved, resulting in users being logged out after a restart.

How to Reproduce?

o simulate the problem, it is necessary to run KC with ISPN and JDBC configuration, for example on a Postgres DB, then perform a login and check the table where sessions are stored. I would perform the login multiple times with different users, as sometimes the session is recorded.

Anything else?

No response

@miroRucka
Copy link
Author

It is probably a duplicate of this issue: #10803

@ahus1
Copy link
Contributor

ahus1 commented Nov 15, 2023

@miroRucka - thank you for sharing this context. To reproduce this locally, I need a Infinispan XML configuration to test this. I know that the Stackoverflow issue you linked contains one, but to really reproduce the case I'd like to see more about your setup. It would also help to see the PostgreSQL configuration you're using.

A full CLI example and a configuration on how to prepare the PostgreSQL for your example would help as well.

@ahus1 ahus1 added this to the 23.0.0 milestone Nov 20, 2023
ahus1 added a commit to ahus1/keycloak that referenced this issue Nov 20, 2023
Closes keycloak#10803
Closes keycloak#24766

Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
Co-authored-by: daviddelannoy <16318239+daviddelannoy@users.noreply.github.com>
ahus1 added a commit that referenced this issue Nov 20, 2023
Closes #10803
Closes #24766

Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
Co-authored-by: daviddelannoy <16318239+daviddelannoy@users.noreply.github.com>
@ghost ghost removed the status/triage label Nov 20, 2023
ShefeeqPM pushed a commit to ShefeeqPM/keycloak that referenced this issue Jan 27, 2024
Closes keycloak#10803
Closes keycloak#24766

Signed-off-by: Alexander Schwartz <aschwart@redhat.com>
Co-authored-by: daviddelannoy <16318239+daviddelannoy@users.noreply.github.com>
Signed-off-by: ShefeeqPM <86718986+ShefeeqPM@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/infinispan kind/bug Categorizes a PR related to a bug
Projects
None yet
2 participants