Feat: The "inception pool" aka Ratomic::LocalPool - #26
Merged
Conversation
…dlock in the underlying DashMap bucket
Add Ratomic::LocalPool, a shareable facade over per-Ractor local resource pools. Designed for live resources such as Redis clients and database connections where ownership preservation is preferable to ownership transfer. Includes Redis smoke tests and documentation updates.
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.
Summary
This PR introduces
Ratomic::LocalPool, a new pooling primitive for resources that should remain local to the Ractor that created them.Examples include:
Background
While experimenting with Redis clients under Ruby Ractors, the ownership-transfer semantics were exposed that they are not always appropriate for live resources.
Ratomic::Poolcorrectly implements ownership transfer:However, Redis clients contain internal state that cannot safely participate in ownership transfer after initialization. This resulted in failures such as:
Several approaches were explored, including pool reset behavior, but the underlying issue was resource ownership rather than resource cleanup.
Solution
Introduce
Ratomic::LocalPool.Instead of moving live resources between Ractors, the facade remains shareable while each Ractor lazily creates and owns its own local resource pool.
Architecture:
Calling this the "Inception Pool" design:
A Pool within a Pool :)
Validation
Added Redis smoke tests covering:
basic_redis.rb
queue_redis.rb
Observed results:
Ractor::MovedErrorRactor::IsolationError