Skip to content

Conversation

tengu-alt
Copy link
Contributor

@tengu-alt tengu-alt commented Jul 24, 2024

This PR addresses issue #1706.

The driver was unable to discover nodes with an empty rack name because the isValidPeer() function incorrectly checked for an empty string in the rack value (which is a valid case). The correct validation should ensure the rack name is not null (as a null value indicates an invalid peer).

This PR fixes the method of retrieving the rack value from the system.peers and system.peers_v2 tables. Now, the rack value is set as a pointer to a string, allowing the value to be checked for null.

@joao-r-reis joao-r-reis changed the title 'Unable to discover cluster nodes with an empty rack name' issue fix CASSGO-6 'Unable to discover cluster nodes with an empty rack name' issue fix Oct 29, 2024
if err != nil {
return RowData{}, err
}
if column.Name == "rack" && column.Keyspace == "system" && (column.Table == "peers_v2" || column.Table == "peers") {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a hack, plus it could break backwards compatibility for existing users of RowData (outside of gocql) that read from those tables.
Could the issue be fixed another way, for example improving the API/adding new API for all users?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is #1834, which allows to handle a nullable value. After #1834 is merged, I will refactor this PR using the nullable scan functional. This should help to avoid the hack.

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with addressing #1834 first, @martin-sucha can you provide feedback on #1834 ? I see your original comment on that issue, but I'm not sure if #1834 accurately implements what you were proposing.

state nodeState
schemaVersion string
tokens []string
isRackNil bool
Copy link
Contributor

Choose a reason for hiding this comment

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

We can change rack to be *string, it's a private field. A conversion has to happen in the Rack() function though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me!
Let's wait for the feedback that you have asked for.

@joao-r-reis
Copy link
Contributor

Just for future reference in case anyone checks the status of this: we're currently waiting on #1834 and #1834 is waiting on #1855

@jameshartig
Copy link
Contributor

I have an alternative solution that I can propose soon without depending on any other PRs.

@tengu-alt
Copy link
Contributor Author

I have an alternative solution that I can propose soon without depending on any other PRs.

Sounds good, let's see it when it arrives.

@jameshartig
Copy link
Contributor

Alternative fix: #1895

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