-
Notifications
You must be signed in to change notification settings - Fork 38
4.x: Add advanced shard awareness #517
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
base: scylla-4.x
Are you sure you want to change the base?
4.x: Add advanced shard awareness #517
Conversation
b2aa823
to
f3dc5ef
Compare
I'll probably introduce some small checks to port allocator (for example the range should not be too small) and some unit tests but the gist of the PR will probably look as it is now. |
560a1f2
to
33a9063
Compare
@Bouncheck , I realy don't like idea of |
16f0fda
to
90d63df
Compare
There always is that possibility. PortIterator suffers from the same thing. The only solution is to try again. From what I see PortIterator does not check if returned port was free at all. |
It does that when socket is actually allocated, and no, it doesn't suffer from it, it will retry on next port if port is busy |
@Bouncheck , also another reason to stick to PortIterator is that it keeps behavior inline with OS and driver socket configurations:
|
90d63df
to
67348e7
Compare
Both solutions are just black boxes that return an int when asked. In the time between they return an int and The additional bind exception handling you've added is separate from portIterator and can be done with any other port number picking black box as well, but it does not solve this problem (does not prevent stealing the port). |
I don't understand this part |
When you create a socket or bind it, the OS is generally expected to return an error if the specified port and/or address is already in use. Socket options:
At least one of these is also configurable through the driver using OS-level settings: For example, on Linux, the sysctl setting The outcome depends on the combination of Since you're calling listen first, the behavior will follow the rules specific to listen. |
4708b33
to
33a9063
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, one more test needed and and couple of doc issues.
integration-tests/src/test/java/com/datastax/oss/driver/core/pool/AdvancedShardAwarenessIT.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/datastax/oss/driver/api/core/config/DefaultDriverOption.java
Show resolved
Hide resolved
# Whether to use advanced shard awareness when trying to open new connections. | ||
# | ||
# Having this enabled makes sense only for ScyllaDB clusters. | ||
# Results in smaller connection storms in multi-client settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it ? I don't see any difference in this regard between regular shard awarness and advanced, if anything it will reduce number of reconnections needed to fullfill connection pool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it decreases the number of reconnections needed then it lessens the load, no? Of course all driver applications will need to use it for best results.
Maybe I'm using a wrong term here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please refrase it so that it does not confuse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but which part? I don't know which part is the problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Results in smaller connection storms in multi-client settings.
-> # Enabling it reduces amount of reconnections driver does to get connection pool filled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to Reduces number of reconnections driver needs to fully initialize connection pool.
956cbd9
to
799de7e
Compare
Addresed docs comments and added 1 change to port allocator. It will follow reuse address setting from the config. |
Adds config options for toggling the feature on and defining port ranges to use. By default the feature will be enabled.
With advanced shard awareness target shard is a necessary parameter for connecting. Extends non public methods with new parameters and provides one additional public method. Passing `null` as shard id or ShardingInfo will lead to previous non-shard aware behavior.
Makes `addMissingChannels` use advanced shard awareness. It will now specify target shard when adding missing channels for specific shards. In case returned channels do not match requested shards warnings are logged. Initial connection to the node works on previous rules, meaning it uses arbitrary local port for connection to arbitrary shard. Adds AdvancedShardAwarenessIT that has several methods displaying the difference between establishing connections with option enabled and disabled. Adds ChannelPoolShardAwareInitTest
1680633
to
1d92051
Compare
Squashed fixes into appropriate commits and added missing |
Adds advanced shard awareness to the 4.x version of the driver.
Added integration test that checks if reconnections are sufficiently rare with advanced shard awareness.
should_struggle_to_fill_pools
andshould_not_struggle_to_fill_pools
can be run locally to see the difference between the driver with and without this feature.Fixes #515