Implement exclude keys for ActionController::Live execution sharing #56393
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.
When using
ActionController::Livethe execution context is shared across threads. In some cases, like database context switching from a writer to a replica connection, you may not want that context to be shared.This PR implements a config option for excluding specific keys from the shared execution. By default no keys are shared to support backwards compatibility in order to maintain current behavior while implementing a way for applications experiencing an issue with database connections to opt-out. See #52906.
To exclude a specific key application-wide, set the following config option:
If you want finer-grained control over which controllers exclude these keys you can set
live_streaming_excluded_keysin the controller itself.In the future we may want to default to excluding this key since I'm not sure anyone wants to share database context. However I chose not to do that in this PR because we need to backport this to use as a bug fix, and if it changes behavior that could break applications.
Fixes #52906