apache / apache/cassandra-gocql-driver
Fix disableHostLookup flag logic
- Dominant language
- Go
- Stars
- 2.7k
- Forks
- 658
- PR merge metrics
- No merged PRs in 30d
Description
According to the Contributor comment on #1665 issue:
It seems the behavior was like this since commit 83932d6de9af9257339038f8a3a017941c34921d that introduced the option. It seems reasonable to me to treat this as a bug since the documentation says that the driver won't try to discover the hosts. Although `DisableHostLookup` would indeed be better name for a config option like that. And it is not clear to me how users use the DisableInitialHostLookup option, resp. if disabling the lookup always can break someone's program.
Currently, gocql queries `system.peers` in these cases:
* During `Session.init` if `DisableInitialHostLookup` is `false`.
* When reconnecting control connection.
* When calling `Session.AwaitSchemaAgreement` explicitly.
* When a [schema change query successfully executes](https://github.com/gocql/gocql/blob/6132f789ad22c1d19a66c58ac789402d5f1f9be5/conn.go#L1438).
* When a [keyspace change event is received](https://github.com/gocql/gocql/blob/6132f789ad22c1d19a66c58ac789402d5f1f9be5/events.go#L128).
* When a node is added or removed from the cluster. (`Session.addNewNewNode`, `Session.handleNewNode`, `Session.handleRemovedNode`)
We would need to disable it in all these cases, not just during reconnection.
_Originally posted by @martin-sucha in https://github.com/apache/cassandra-gocql-driver/issues/1665#issuecomment-1319988023_
The flag should disable host lookup procedures in cases mentioned above.
Contributor guide
Research direction
Trace the host lookup paths from Session.init and the reconnect logic, then inspect conn.go, events.go, Session.AwaitSchemaAgreement, Session.addNewNewNode, Session.handleNewNode, and Session.handleRemovedNode. Verify how DisableInitialHostLookup is currently checked and ensure the flag governs every listed system.peers lookup case; done means all specified procedures consistently skip host lookup when it is enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100