maximkosov commented on issue #1918:
URL:
https://github.com/apache/cassandra-gocql-driver/issues/1918#issuecomment-3852066797
Hello, we are noticing the same issue when connecting to 3+ clusters. I ran
analysis with the help of AI and I think it correctly identified the root
cause. I double checked the source code and I think that investigation was
correct.
Root Cause
The initialization order in session.init() is incorrect. In session.go:
1. Lines ~318-335: Hosts are added to the policy via s.policy.AddHost() or
AddHosts()
2. Lines ~353-362: s.useSystemSchema is set based on cluster version
When tokenAwareHostPolicy.AddHost() is called, it triggers:
- AddHost() → updateReplicas() → getKeyspaceMetadata()
At this point, session.useSystemSchema is still false (the default value),
so getKeyspaceMetadata() in metadata.go takes the legacy code path and queries
system.schema_keyspaces instead of
system_schema.keyspaces.
Call Chain
session.init()
└─ s.policy.AddHost(host) // line ~320
└─ tokenAwareHostPolicy.AddHost() // policies.go:504
└─ t.updateReplicas() // policies.go:509
└─ t.getKeyspaceMetadata() // policies.go:471
└─ checks session.useSystemSchema (still false!)
└─ queries system.schema_keyspaces (wrong table)
└─ s.useSystemSchema = version.AtLeast(3,0,0) // line ~360 (too late!)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]