Skip to content
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

fix: set useSystemSchema before policy setup #1797

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from

Conversation

dipeshhkc
Copy link

@dipeshhkc dipeshhkc commented Aug 13, 2024

During NewSession followed by init,

AddHosts is called in the policy before useSystemSchema is set.

if v, ok := s.policy.(bulkAddHosts); ok {
		v.AddHosts(hosts)
	}

So, getKeyspaceMetadata called by updateReplicas during AddHosts will take useSystemSchema=false and so 2nd query system.schema_keyspaces is called instead of system_schema.keyspaces.

 func getKeyspaceMetadata(session *Session, keyspaceName string) (*KeyspaceMetadata, error) {
	keyspace := &KeyspaceMetadata{Name: keyspaceName}

	if session.useSystemSchema { // Cassandra 3.x+
		const stmt = `
		SELECT durable_writes, replication
		FROM system_schema.keyspaces
		WHERE keyspace_name = ?`
		.......................
        } else {
		const stmt = `
		SELECT durable_writes, strategy_class, strategy_options
		FROM system.schema_keyspaces
		WHERE keyspace_name = ?`	
                .......................
         } 
    	

so was getting following issue

control: error executing "In\t\tSELECT durable_writes, strategy_class, strategy-options\n
It\tFROM system.schema_keyspaces\n\t\tWHERE keyspace_name = ?": table system. schema_keyspa
ces does not exist

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.

1 participant