Skip to content

Conversation

RostislavPorohnya
Copy link

@RostislavPorohnya RostislavPorohnya commented Aug 1, 2024

This PR addresses issue #1665, which reports a bug where system.peers table is queried even if DisableInitHostLookup flag is set to true. According to the driver documentation, system.peers should not be queried when the flag is set to true

In this PR DisableInitialHostLookup flag renamed to DisableHostLookup, code logic is fixed to query system.peers only when the flag is set to false.

@joao-r-reis joao-r-reis changed the title Fix DisableInitialHostLookup flag ignored when querying system.peers CASSGO-5 Fix DisableInitialHostLookup flag ignored when querying system.peers Oct 29, 2024
Copy link
Contributor

@joao-r-reis joao-r-reis left a 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
}
Copy link
Contributor

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.

Copy link
Contributor

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
}
Copy link
Contributor

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.

Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor

@joao-r-reis joao-r-reis Nov 12, 2024

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.

Copy link
Contributor

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.

Copy link
Contributor

@OleksiienkoMykyta OleksiienkoMykyta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like your PR helps with (#1789) and (#1665), but what is the status of it? Should it be updated according to comments, or closed in favor of some other PR?

@joao-r-reis
Copy link
Contributor

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

@RostislavPorohnya
Copy link
Author

@joao-r-reis I'm going to update it by the end of next week, thanks for the comments!

@RostislavPorohnya
Copy link
Author

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.

@tengu-alt tengu-alt force-pushed the disable-host-lookup branch from 6cd5280 to 1d13f9b Compare April 2, 2025 11:16
@tengu-alt
Copy link
Contributor

tengu-alt commented Apr 2, 2025

Made some updates: refactored tests, added new logic(refreshRing() from now does NOOP when DisableInitialHostLookup is true), and refactored code according to feedback. Also fixed the conflicts .

@tengu-alt
Copy link
Contributor

@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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate entry?

Copy link
Contributor

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{})
Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, fixed

"testing"
)

func TestDisableHostLookupRingRefresh(t *testing.T) {
Copy link
Contributor

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.

Copy link
Contributor

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

@joao-r-reis
Copy link
Contributor

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 DisableInitialHostLookup flag as I believe there's some other issues that still need to be fixed (e.g. system.local still being queried I think)

…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
@tengu-alt tengu-alt force-pushed the disable-host-lookup branch from 1d13f9b to f5b6f8a Compare April 24, 2025 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants