Touch expires key in SortedSetRedisSessionExpirationStore - #3870
Open
lsh1215 wants to merge 1 commit into
Open
Conversation
cleanupExpiredSessions touched the session key (<namespace>:sessions:<id>) instead of the expires shadow key (<namespace>:sessions:expires:<id>). RedisIndexedSessionRepository#onMessage only reacts to key events whose key starts with the "sessions:expires:" prefix, so touching the session key never triggered a SessionDeletedEvent/SessionExpiredEvent for sessions tracked by this store. Touch the expires key instead, consistent with MinuteBasedRedisSessionExpirationStore and the reactive SortedSetReactiveRedisSessionExpirationStore. Closes spring-projectsgh-3468 Signed-off-by: sanghun <vitash1215@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SortedSetRedisSessionExpirationStore#cleanupExpiredSessionstouches the session key (<namespace>:sessions:<id>) instead of the expires shadow key (<namespace>:sessions:expires:<id>).RedisIndexedSessionRepository#onMessageonly handles keyspace events whose key starts with thesessions:expires:prefix. Because the store touches the session key, expiration does not produce an event that matches that prefix, soSessionDeletedEventandSessionExpiredEventare not published for sessions tracked by this store. The principal index cleanup and the removal from the expiration sorted set run from that sameonMessagehandler, so they do not happen either.This affects
RedisIndexedSessionRepositorywhen it is configured withSortedSetRedisSessionExpirationStore.MinuteBasedRedisSessionExpirationStoreand the reactiveSortedSetReactiveRedisSessionExpirationStoreboth touch the expires key and are not affected.Change
cleanupExpiredSessionsnow touches<namespace>:sessions:expires:<id>, which matches the prefix thatonMessagelistens on and is consistent with the other two stores. The existing private helper was renamed fromgetSessionKeytogetExpiredKeyto reflect the key it builds and to match the naming used inRedisIndexedSessionRepositoryandReactiveRedisIndexedSessionRepository.Testing
SortedSetRedisSessionExpirationStoreTests#cleanupExpiredSessionsThenTouchExpiredSessionsto assert that the expires key is touched. It fails before the change and passes after../gradlew :spring-session-data-redis:testpasses../gradlew :spring-session-data-redis:integrationTest --tests "*SortedSetRedisSessionExpirationStoreITests"passes.Closes gh-3468
cc @rwinch