8000 Infinispan Protostream Marshaller by pruivo · Pull Request #29474 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Infinispan Protostream Marshaller - #29474

Merged
mhajas merged 1 commit into
keycloak:mainfrom
pruivo:t_protostream_ispn15
Jun 13, 2024
Merged

mhajas merged 1 commit into
keycloak:mainfrom
pruivo:t_protostream_ispn15

Conversation

@pruivo
@pruivo pruivo commented May 13, 2024 •
Copy link
Copy Markdown
Member

Closes #29394

I'm gathering earlier feedback and sharing how it will end up.
Pending tasks are:

  • Compute the final Protostream IDs. With Protostream IDs, it generates smaller payloads since it sends the IDs (Goole Protobuf varInt) instead of the message name.
  • Refactor events and predicates. I'm taking the opportunity to remove unused fields and duplicated code.
  • Migration from JBoss Marshalling to Infinispan Protostream
  • Re-add JBoss Marshalling to allow migration of sessions
  • Add clearing of caches on migration to KC25 - all entries in the caches will be gone
  • Documentation for the release notes

Out of scope: Existing entries in the session cache will be migrated in PR #29377

Migration

The migration path is under discussion and has the following assumptions:

  • Only user and client sessions will be migrated. All other data stored in distributed/replicated caches will be lost.
  • Embedded cache needs to have persistence configured. If only in-memory storage is configured, we assume that losing sessions during Keycloak major version upgrade is acceptable and expected.

The most appealing solution is to start a separate, non-clustered Infinispan CacheManager with JBoss-Marshalling configured (the CacheManager is limited to a single marshalled). This CacheManager will be used to read the old session data. Then, we have the following 2 scenarios

  • Persistent User Sessions feature is enabled. Using the JBoss-Marshalling CacheManager to read the sessions and store them in the database. The cache is clear at the end.
  • Without Persistent User Session feature, it reads the sessions from the JBoss-Marshalling CacheManager and writes them in the Protostream enabled CacheManager.

@pruivo
pruivo force-pushed the t_protostream_ispn15 branch 2 times, most recently from 81b9388 to 81f1ba0 Compare May 14, 2024 13:17
@ryanemerson ryanemerson left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pruivo Do you plan to add the proto compatibility check capabilities as part of this PR or should we create an issue to add that in a subsequent PR? I would be happy with the latter given how large the current PR is.

@mhajas
mhajas self-requested a review May 14, 2024 14:27
@pruivo
pruivo force-pushed the t_protostream_ispn15 branch from 81f1ba0 to 70caa5f Compare May 14, 2024 15:41
@pruivo
pruivo force-pushed the t_protostream_ispn15 branch 2 times, most recently from 8e8b859 to 25c5cb1 Compare May 14, 2024 20:29
@stianst stianst added the status/hold PR should not be merged. On hold for later. label May 15, 2024
@stianst
stianst commented May 15, 2024
Copy link
Copy Markdown
Contributor

Please do not merge until we decide if this should be included in Keycloak 25, or shortly after the release

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.broker.KcOidcBrokerTest#testPostBrokerLoginFlowWithOTP_bruteForceEnabled

Keycloak CI - Java Distribution IT (windows-latest - temurin - 19)

java.lang.AssertionError: expected:<Invalid authenticator code.> but was:<null>
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.failNotEquals(Assert.java:835)
	at org.junit.Assert.assertEquals(Assert.java:120)
	at org.junit.Assert.assertEquals(Assert.java:146)
...

Report flaky test

@pruivo
pruivo force-pushed the t_protostream_ispn15 branch from b716502 to c91033c Compare June 3, 2024 17:26
@pruivo
pruivo commented Jun 3, 2024
Copy link
Copy Markdown
Member Author

Rebased and added documentation to

  • Release notes
  • Migration guide

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown
< 8000 /span>

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.oauth.TokenIntrospectionTest#testUnsupportedToken

Keycloak CI - Store IT

java.lang.NullPointerException: Cannot invoke "com.fasterxml.jackson.databind.JsonNode.asBoolean()" because the return value of "com.fasterxml.jackson.databind.JsonNode.get(String)" is null
	at org.keycloak.testsuite.oauth.TokenIntrospectionTest.testUnsupportedToken(TokenIntrospectionTest.java:313)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
...

Report flaky test

org.keycloak.testsuite.broker.KcOidcBrokerTest#testPostBrokerLoginFlowWithOTP_bruteForceEnabled

Keycloak CI - Java Distribution IT (ubuntu-latest - temurin - 17)

java.lang.AssertionError: expected:<Invalid authenticator code.> but was:<null>
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.failNotEquals(Assert.java:835)
	at org.junit.Assert.assertEquals(Assert.java:120)
	at org.junit.Assert.assertEquals(Assert.java:146)
...

Report flaky test

org.keycloak.testsuite.oauth.TokenIntrospectionTest#testUnsupportedToken

Keycloak CI - Base IT (6)

java.lang.NullPointerException: Cannot invoke "com.fasterxml.jackson.databind.JsonNode.asBoolean()" because the return value of "com.fasterxml.jackson.databind.JsonNode.get(String)" is null
	at org.keycloak.testsuite.oauth.TokenIntrospectionTest.testUnsupportedToken(TokenIntrospectionTest.java:313)
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
...

Report flaky test

@keycloak-github-bot keycloak-github-bot Bot left a comment
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.broker.KcOidcBrokerTest#testPostBrokerLoginFlowWithOTP_bruteForceEnabled

Keycloak CI - Java Distribution IT (windows-latest - temurin - 17)

java.lang.AssertionError: expected:<Invalid authenticator code.> but was:<null>
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.failNotEquals(Assert.java:835)
	at org.junit.Assert.assertEquals(Assert.java:120)
	at org.junit.Assert.assertEquals(Assert.java:146)
...

Report flaky test

ahus1
ahus1 previously approved these changes Jun 11, 2024
@ahus1 ahus1 left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR! Found a typo in the include for the release notes. Used the opportunity to remove some now unused code in the PersitentUserSessionProvider.

@ahus1
ahus1 enabled auto-merge (squash) June 11, 2024 14:46
ahus1
ahus1 previously approved these changes Jun 11, 2024
@pruivo
pruivo commented Jun 11, 2024
Copy link
Copy Markdown
Member Author

Thank you for the PR! Found a typo in the include for the release notes. Used the opportunity to remove some now unused code in the PersitentUserSessionProvider.

I didn't remove that method because of the javadoc: This method is public so people can use it to build their custom migrations or re-import sessions when necessary in a future version of Keycloak.

Isn't useful anymore?

@ahus1
ahus1 force-pushed the t_protostream_ispn15 branch from b5d3a88 to d2a1573 Compare June 11, 2024 15:05
@ahus1
ahus1 commented Jun 11, 2024
Copy link
Copy Markdown
Member

Isn't useful anymore?

With the change of the serialization format, it IMHO became less useful. But ok, let's keep it for now. I realize I only deleted half of it anyway :-(

ahus1
ahus1 previously approved these changes Jun 11, 2024
auto-merge was automatically disabled June 11, 2024 15:38

Head branch was pushed to by a user without write access

@ahus1
ahus1 force-pushed the t_protostream_ispn15 branch from b9788fc to 652cb51 Compare June 11, 2024 15:48
@ahus1
ahus1 enabled auto-merge (squash) June 11, 2024 15:48
ahus1
ahus1 previously approved these changes Jun 11, 2024
@ryanemerson ryanemerson left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @pruivo, just a few minor things I have noticed so far.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the IDs defined above are used anywhere in the code according to Intellij.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The modules where they are used do not depend on this one. The comments tell where they are used.

@pruivo
pruivo commented Jun 11, 2024
Copy link
Copy Markdown
Member Author

Added a new commit with @ryanemerson suggestions 👍

Closes keycloak#29394

Signed-off-by: Pedro Ruivo <pruivo@redhat.com>
Co-authored-by: Alexander Schwartz <aschwart@redhat.com>
@pruivo
pruivo force-pushed the t_protostream_ispn15 branch from 3218aff to 25e3dfd Compare June 13, 2024 08:20
@pruivo
pruivo commented Jun 13, 2024
Copy link
Copy Markdown
Member Author

Rebased and squashed the commits.

I suspect that CacheInitializer#loadSessions() is running concurrently with UserSessionProvider#migrate(). The migrate method will clear the cache and remove the InitializerState preventing nodes to start. I couldn't get any logs from GitHub Actions to confirm this.

I changed how the migration works and moved the code to DefaultInfinispanConnectionProvider to avoid code duplication. It no longers clears the in-memory data (assumes there isn't a mix of KC25 and KC26 servers in the same cluster) but only from persistence (which is the only place where the data is stored in binary).

cc @ahus1 @mhajas @ryanemerson

@mhajas mhajas left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much @pruivo! This was quite a journey. Let's see what the rest of it will look like! It looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Infinispan Protostream

5 participants

0