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

Change default value for KeyspaceEventMessageListener on keyspace event notifications #2670

Open
jxblum opened this issue Aug 10, 2023 · 0 comments · May be fixed by #2671
Open

Change default value for KeyspaceEventMessageListener on keyspace event notifications #2670

jxblum opened this issue Aug 10, 2023 · 0 comments · May be fixed by #2671
Assignees
Labels
in:messaging Redis messaging components type: bug A general bug

Comments

@jxblum
Copy link
Contributor

jxblum commented Aug 10, 2023

The default value in Spring Data Redis for notify-keyspace-events is set to EA. Therefore, when a user declares and registers a bean of type KeyExpirationEventMessageListener (which extends KeyspaceEventMessageListener) in the Spring ApplicationContext, Spring Data Redis will send a config set notify-keyspace-events EA command to the Redis server on initialization (and then init()).

While this may be "convenient" during development, it is NOT (ever) appropriate for production deployments, and can lead to confusing behavior exactly like this.

With a combination of Lettuce attempting to reconnect (Jedis will not automatically reconnect) and the fact that Redis does not retain configuration changes between restarts (i.e. non-persistent config when changed at runtime; even when applied using the redis-cli), then this situation, such as in Issue #2654, can occur.

NOTE: It is not uncommon for data stores to retain (persist) dynamic configuration changes between sessions.

Therefore, it is recommend the default value in Spring Data Redis be changed to empty, precisely how the Redis server (in redis.conf from a clean install) defines this setting, itself.

If users change the default (e.g. to EA, or otherwise), then they have chosen to "opt-in" and are therefore responsible for the change, such as when the Redis server needs to be restarted.

As explained in Issue #2654, the appropriate location to declare "infrastructure-related" configuration settings to the Redis server is in the redis.conf file, where it belongs! Additionally, users must ensure any custom (modified) configuration file is then passed to and recognized by the Redis server on start.

TIP: On a positive note, the customized/modified redis.conf used to change the default behavior of the Redis server can be checked into version control the same as the application source code that requires the Redis server to behave in a custom way.

In conclusion, the framework, or any library for that matter, should never be making "infrastructure" decisions for users.

@jxblum jxblum self-assigned this Aug 10, 2023
@jxblum jxblum added type: bug A general bug in:messaging Redis messaging components labels Aug 10, 2023
@jxblum jxblum changed the title Change default value for KeyExpirationEventMessageListener to disable notifications Change default value for KeyExpirationEventMessageListener to disable notifications Aug 10, 2023
@jxblum jxblum changed the title Change default value for KeyExpirationEventMessageListener to disable notifications Change default value for KeyExpirationEventMessageListener keyspace event notifications Aug 10, 2023
@jxblum jxblum changed the title Change default value for KeyExpirationEventMessageListener keyspace event notifications Change default value for KeyspaceEventMessageListener keyspace event notifications Aug 10, 2023
jxblum added a commit to jxblum/spring-data-redis that referenced this issue Aug 10, 2023
…notifications.

Users must now explicitly call setKeyspaceNotificationsConfigParameter(:String) to a valid redis.config, notify-keyspace-events value to enable Redis keyspace notifications. This aligns with the Redis servers default setting for notify-keyspace-events in redis.conf, which is disabled by default.

Additionally, the default value for KeyExpirationEventMessageListener has been changed to 'Ex', for development-time convenience only.

However, users should be aware that any notify-keyspace-events configuration only applies once on Spring container initialization and any Redis server reboot will not remember dynamic configuration modifications applied at runtime. Therefore, it is recommended that users applly infrastructure-related configuration changes directly to redis.conf.

Closes spring-projects#2670
jxblum added a commit to jxblum/spring-data-redis that referenced this issue Aug 11, 2023
…notifications.

Users must now explicitly call setKeyspaceNotificationsConfigParameter(:String) to a valid redis.config, notify-keyspace-events value to enable Redis keyspace notifications. This aligns with the Redis servers default setting for notify-keyspace-events in redis.conf, which is disabled by default.

Additionally, the default value for KeyExpirationEventMessageListener has been changed to 'Ex', for development-time convenience only.

However, users should be aware that any notify-keyspace-events configuration only applies once on Spring container initialization and any Redis server reboot will not remember dynamic configuration modifications applied at runtime. Therefore, it is recommended that users applly infrastructure-related configuration changes directly to redis.conf.

Closes spring-projects#2670
@jxblum jxblum changed the title Change default value for KeyspaceEventMessageListener keyspace event notifications Change default value for KeyspaceEventMessageListener on keyspace event notifications Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in:messaging Redis messaging components type: bug A general bug
Projects
None yet
1 participant