-
Notifications
You must be signed in to change notification settings - Fork 645
CASSGO-5 Fix DisableInitialHostLookup flag ignored when querying system.peers #1790
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: trunk
Are you sure you want to change the base?
CASSGO-5 Fix DisableInitialHostLookup flag ignored when querying system.peers #1790
Conversation
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.
Added some comments.
In summary I think this PR should be limited to making the refreshRing
function do nothing when the flag is set. That would ensure that the driver will keep using the contact points as the hosts forever and ignore any kind of topology changes or any host information from system tables.
It's fine if the driver queries the system tables to check if there is schema agreement, I don't think it goes against the intention of the flag.
|
||
if err = iter.Close(); err != nil { | ||
goto cont | ||
} |
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.
I think it's fine if we query system.peers for the purpose of retrieving the schema version of each host as long as we don't update gocql's ring/hosts. If a user wants to use a static set of contact points and avoid using hosts from system tables there's no reason why they would have to give up the functionality of awaiting for schema agreement.
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.
Agree, fixed.
host_source.go
Outdated
// Check if host lookup is disabled | ||
if r.session.cfg.DisableHostLookup { | ||
return []*HostInfo{}, nil | ||
} |
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.
Instead of adding this, I think we should make the ringRefresher
do a NOOP when this flag is set. getClusterPeerInfo
should only be about retriving the peers info from the server so it should be up to the caller whether this should be done or not.
If we make the func refreshRing(r *ringDescriber) error
function do nothing when the flag is set then it should solve all of the issues related to the driver not respecting the flag.
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.
Agree, refactored
cluster.go
Outdated
// mean that data_centre, rack and token information will not be available and as | ||
// such host filtering and token aware query routing will not be available. | ||
DisableInitialHostLookup bool | ||
DisableHostLookup bool |
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.
I don't think this is worth breaking applications. I agree that removing the Initial
word from the name does make sense but it's really not that big of a deal.
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.
At the very least we would have to keep both flags (+ deprecate the old one) and map it to a single internal flag so that we can do a "safe" rename of the flag without breaking user applications.
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.
Agree, I've returned the old name.
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 there's no update to this PR soon I'll descope it from the 2.0 release as this can be released in a minor released without an issue |
@joao-r-reis I'm going to update it by the end of next week, thanks for the comments! |
Hi. I’ve handed this PR over to @tengu-alt, who will finalize the remaining work. I’m switching to another task, so please feel free to tag him if you have any questions or need updates. |
6cd5280
to
1d13f9b
Compare
Made some updates: refactored tests, added new logic( |
@joao-r-reis Could you please take a look? |
CHANGELOG.md
Outdated
|
||
- Fix DisableInitialHostLookup flag ignored when querying system.peers (CASSGO-5) | ||
|
||
- Fix DisableInitialHostLookup flag ignored when querying system.peers (PR update) (CASSGO-5) |
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.
duplicate entry?
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.
Agree, deleted
for time.Now().Before(endDeadline) { | ||
iter := c.querySystemPeers(ctx, c.host.version) | ||
|
||
versions = make(map[string]struct{}) |
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.
why this change? resetting the map on each attempt made more sense to me
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.
Agree, fixed
disable_host_lookup_test.go
Outdated
"testing" | ||
) | ||
|
||
func TestDisableHostLookupRingRefresh(t *testing.T) { |
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 we not add this to an existing test file? Creating a new file just for this test seems excessive. Also this is running in "unit tests" step because it's missing the appropriate build flag at the top of the file. Also missing license header.
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.
Done, I've moved the test into the cassandra_test.go
Also, I'm considering pushing this to a 2.x minor release followup and descoping it from 2.0 because it doesn't really need a major release and I also want do some extensive testing with the |
…PR update) This commit provides update for the 'Modified DisableInitialHostLookup flag name and logic' refreshRing() does NOOP when 'DisableInitialHostLookup' is true. system.peers can be queried when flag is true for the schema version retrieving. patch by Oleksandr Luzhniy; for CASSGO-5
1d13f9b
to
f5b6f8a
Compare
This PR addresses issue #1665, which reports a bug where
system.peers
table is queried even ifDisableInitHostLookup
flag is set totrue
. According to the driver documentation,system.peers
should not be queried when the flag is set totrue
In this PR
DisableInitialHostLookup
flag renamed toDisableHostLookup
, code logic is fixed to querysystem.peers
only when the flag is set tofalse
.