-
Notifications
You must be signed in to change notification settings - Fork 812
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
Add Cassandra table options flag #2575
Conversation
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.
Overall I like the idea of being able to configure this. However, I think it would be better to do it using a well defined struct instead of just passing a string.
pkg/chunk/cassandra/table_client.go
Outdated
PRIMARY KEY (hash, range) | ||
)`, desc.Name) | ||
if c.cfg.TableWith != "" { | ||
query = fmt.Sprintf("%s WITH %s", query, c.cfg.TableWith) |
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.
IMO, joining a string like this for a query to Cassandra is dangerous. If the end goal is to change the compaction strategy, I think that would be better handled with a CompactionConfig
struct that a parameterizes all of the possible compactions strategies into a config and generates the appropriate query string.
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.
Thank you for review! I agree your opinion.
And there are some considerations.
Some of table options for Cassandra are related to duration, like this:
gc_grace_seconds = 864000
default_time_to_live = 0
tombstone_compaction_interval = 864000
max_sstable_age_days = 100
...
I thought table options like above are suitable for time.Duration
type.
But some of names for table options indicate time unit.
I am not sure if time.Duration
is suitable.
There is a way to rename the table options but I'm concerned about user confusion.
I am curious about your opinion.
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.
Since this is specifically for Cassandra,I recommend using types that will make input correspond to Cassandra. That way users already familiar with the system will be able to directly copy config values over.
So in the cases you mentioned above I would use int
values. Just make sure you document each option in the flag help text.
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.
In our use case, we are using ScyllaDB, which is compatible but contains many options that are not default in Cassandra.
https://docs.scylladb.com/getting-started/ddl/
CTRL-F scylla_encryption_options
It is a bad idea to assume what flags the Cassandra server will support. In my opinion this should be made extensible and the current PR does that nicely.
This is a niche flag that will only be used by those who fully understand the implications of changing the flag, better solved by documentation, and already have authorization on the Cassandra server through the configuration.
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.
@jtlisi
In addition to @coelho, there may be another use cases, such as DataStax products.
Also, table options depend on the Cassandra version.
It is hard to find all options and consider all differences.
My goals have been just caching and compaction strategy.
But this issue seems to have more considerations than I think.
If you still think joining string is dangerous, it may need another way.
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 see your point, and I agree in some cases a separate string makes sense. @pracucci WDYT?
@@ -66,6 +67,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { | |||
f.DurationVar(&cfg.MinBackoff, "cassandra.retry-min-backoff", 100*time.Millisecond, "Minimum time to wait before retrying a failed request. (Default = 100ms)") | |||
f.DurationVar(&cfg.MaxBackoff, "cassandra.retry-max-backoff", 10*time.Second, "Maximum time to wait before retrying a failed request. (Default = 10s)") | |||
f.IntVar(&cfg.QueryConcurrency, "cassandra.query-concurrency", 0, "Limit number of concurrent queries to Cassandra. (Default is 0: no limit)") | |||
f.StringVar(&cfg.TableWith, "cassandra.table-with", "", "Table options used to create index or chunk tables.(Default = \"\": use default table options of Cassandra") |
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 would recommend naming this variable TableOptions and the flag table-options
.
Also the help text should explain that the provided string will be concatenated to all table creation operations.
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.
@jtlisi
I have renamed table-with
to table-options
and improved the help text.
# Table options used to create index or chunk tables.(Default = "": use | ||
# default table options of Cassandra | ||
# CLI flag: -cassandra.table-with | ||
[table_with: <string> | default = ""] |
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.
Be sure to update https://github.com/cortexproject/cortex/blob/master/docs/production/storage-cassandra.md with information about this flag. As well as warnings about the potential issues a user could face by misconfiguring 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.
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.
LGTM
EDIT: Great English btw, no worries :)
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.
LGTM
Please rebase when you get a chance.
2474ab0
to
3caa5bb
Compare
@jtlisi |
b3180a1
to
3caa5bb
Compare
Signed-off-by: Kyeongwon Seo <[email protected]>
Signed-off-by: Kyeongwon Seo <[email protected]>
Signed-off-by: Kyeongwon Seo <[email protected]>
Signed-off-by: Kyeongwon Seo <[email protected]>
Signed-off-by: Kyeongwon Seo <[email protected]>
Signed-off-by: Kyeongwon Seo <[email protected]>
…unning Cortex with Cassandra Signed-off-by: Kyeongwon Seo <[email protected]>
Signed-off-by: Kyeongwon Seo <[email protected]>
3caa5bb
to
8a55066
Compare
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.
LGTM, thanks!
What this PR does:
This PR adds
cassandra.table-options
flag andstorage.cassandra.table_options
configuration option to customize Cassandra table options when creating index or chunk table by table-manager.Configuration Example
EDIT: rename
table_with
->table_options
Which issue(s) this PR fixes:
Fixes #2453
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]