-
Notifications
You must be signed in to change notification settings - Fork 59
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
Switch to use server side schema description for KeyspaceMetadata.ToCQL #210
Switch to use server side schema description for KeyspaceMetadata.ToCQL #210
Conversation
1b845a0
to
28ecd39
Compare
Does it work against all supported versions of Scylla? Fallback to the old logic is not necessary? |
28ecd39
to
6b659da
Compare
Tested on both old scylla and old cassandra, in both cases |
I think it LGTM, @wprzytula maybe you could give a second opinion? |
testdata/recreate/udt_golden.cql
Outdated
'class': 'SimpleStrategy', | ||
'replication_factor': '2' | ||
}; | ||
|
||
CREATE KEYSPACE gocqlx_udt WITH replication = {'class': 'org.apache.cassandra.locator.SimpleStrategy', 'replication_factor': '2'} AND durable_writes = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SimpleStrategy
is deprecated. Let's not use it anywhere and rather migrate to NetworkTopologyStrategy
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just expected result of .ToCQL(), schema is in other cql files, tcs[id].Input
.
For sake of not polluting this PR, let's have a separate issue on switching from SimpleStrategy
to NetworkTopologyStrategy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will you open the issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testdata/recreate/table_golden.cql
Outdated
AND speculative_retry = '99.0PERCENTILE' | ||
AND paxos_grace_seconds = 864000 | ||
AND tombstone_gc = {'mode': 'timeout', 'propagation_delay_in_seconds': '3600'}; | ||
CREATE TABLE gocqlx_table.monkeyspecies ( | ||
species text PRIMARY KEY, | ||
species text, | ||
average_size int, | ||
common_name text, | ||
population varint | ||
population varint, | ||
PRIMARY KEY (species) | ||
) WITH bloom_filter_fp_chance = 0.01 | ||
AND caching = {'keys':'ALL','rows_per_partition':'ALL'} | ||
AND caching = {'keys': 'ALL', 'rows_per_partition': 'ALL'} | ||
AND comment = 'Important biological records' | ||
AND compaction = {'class':'SizeTieredCompactionStrategy'} | ||
AND compression = {'sstable_compression':'org.apache.cassandra.io.compress.LZ4Compressor'} | ||
AND compaction = {'class': 'SizeTieredCompactionStrategy'} | ||
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'} | ||
AND crc_check_chance = 1 | ||
AND default_time_to_live = 0 | ||
AND gc_grace_seconds = 864000 | ||
AND max_index_interval = 2048 | ||
AND memtable_flush_period_in_ms = 0 | ||
AND min_index_interval = 128 | ||
AND speculative_retry = '99.0PERCENTILE'; | ||
|
||
AND speculative_retry = '99.0PERCENTILE' | ||
AND paxos_grace_seconds = 864000 | ||
AND tombstone_gc = {'mode': 'timeout', 'propagation_delay_in_seconds': '3600'}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how these changes are related to the PR description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just expected result of .ToCQL(), schema is in other cql files, tcs[id].Input
.
For sake of not polluting this PR, let's have a separate issue on switching from SimpleStrategy
to NetworkTopologyStrategy
Since now we read it from server side result has changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we 100% sure that in tests we would always use the server-side schema description? (i.e. under no circumstances will fallback to client-side description fire up)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will take care of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added logic to the test to handle both cases.
if !session.useSystemSchema { | ||
return nil, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I read some code and it seems to be an option to support ancient Cassandra versions without system_schema
keyspace. If so (please check my findings), do we really won't to keep this? Maybe we should file a PR to upstream that deletes this logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is fallback logic in ToCQL()
metadata_scylla.go
Outdated
if !session.useSystemSchema { | ||
return nil, nil | ||
} | ||
rows, err := session.control.query(fmt.Sprintf(`DESCRIBE KEYSPACE %s WITH INTERNALS`, keyspaceName)).SliceMap() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where this CQL syntax comes from? Can you provide a source? And put it in a comment for future readers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately nor scylla neither cassandra have a good page with this exact syntax that could be referred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So where did you get this syntax from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if len(km.CreateStmts) != 0 { | ||
return km.CreateStmts, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I dislike the heuristic that if km.CreateStmts
is empty, then server does not support DESCRIBE KEYSPACE. But it seems to work, so let it be.
6b659da
to
3bef1ea
Compare
@wprzytula ping |
I need to address one problem he pointed out |
a803fe6
to
0c53cd0
Compare
No need to keep client-side logic which needs to be updated every time there is changes on server-side.
0c53cd0
to
dcc0f67
Compare
Has this been resolved? |
No need to keep client-side logic which needs to be updated every time there is changes on server-side.
Closes #195