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

Validate compaction strategy option values #2336

Closed
raphaelsc opened this issue Apr 28, 2017 · 10 comments · Fixed by #13956
Closed

Validate compaction strategy option values #2336

raphaelsc opened this issue Apr 28, 2017 · 10 comments · Fixed by #13956
Assignees
Labels
area/cassandra 3.x compatibility area/compaction Field-Tier3 Nice to have issues as per FieldEngineering request good first issue symptom/ux Concerns regarding the user experience in working with Scylla.
Milestone

Comments

@raphaelsc
Copy link
Member

raphaelsc commented Apr 28, 2017

Compaction strategy option value should be validated when either creating or altering a column family's schema. A bad value can lead the strategy to behave very badly.

@slivne slivne added this to the x-ray milestone Apr 30, 2017
@raphaelsc raphaelsc changed the title Validate compaction strategy options Validate compaction strategy option values Dec 8, 2017
@glommer glommer added the Field-Tier3 Nice to have issues as per FieldEngineering request label Jan 10, 2019
@tzach tzach added area/cassandra 3.x compatibility symptom/ux Concerns regarding the user experience in working with Scylla. n00b labels Jul 28, 2019
@tzach tzach modified the milestones: x-ray, 3.x Jul 28, 2019
@tzach
Copy link
Contributor

tzach commented Jun 17, 2020

@raphaelsc can you provide a list of valid values?

@bhalevy
Copy link
Member

bhalevy commented Dec 12, 2021

@raphaelsc can you provide a list of valid values?

@tzach I sent a patch to the mailing list validating:

min_threshold > 2
max_threshold >= min_threshold

On top of that, we should probably have per-compaction-strategy validation to CS-specific options / semantics.

fee-mendes added a commit to fee-mendes/scylla that referenced this issue Sep 11, 2022
Scylla mistakenly allows an user to configure an invalid TWCS window_size <= 0, which effectively breaks the notion of compaction windows.
Interestingly enough, a <= 0 window size should be considered an undefined behavior as either we would create a new window every 0 duration (?) or the table would behave as STCS, the reader is encouraged to figure out which one of these is true. :-)

Cassandra, on the other hand, will properly throw a ConfigurationException when receiving such invalid window sizes and we now match the behavior to the same as Cassandra's.

Refs: scylladb#2336
@bhalevy
Copy link
Member

bhalevy commented Mar 13, 2023

@Deexie can you please pick this up?
We've hit an issue in the field where the user got themselves into trouble by mixing configuration options for different compaction strategies.

@bhalevy
Copy link
Member

bhalevy commented Mar 13, 2023

What we want is each compaction strategy to validate the <key, value> map of options to make sure it recognizes all keys and also validate the values if needed.

@mykaul mykaul modified the milestones: 5.x, 5.3 Mar 14, 2023
@Deexie
Copy link
Contributor

Deexie commented Mar 14, 2023

What we want is each compaction strategy to validate the <key, value> map of options to make sure it recognizes all keys

LCS and TWCS have an attribute: size_tiered_compaction_strategy_options _stcs_options. With these options size_tiered_compaction_strategy is temporarily created in some methods. Should options for aforementioned strategies be allowed to contain STCS-specific fields?

and also validate the values if needed.

Are the following constraints exhaustive and strict enough?

Common options:

  • tombstone_threshold >= 0.0 && tombstone_threshold <= 1.0
  • tombstone_compaction_interval > 0s

Size Tiered Compaction Strategy:

  • bucket_low <= bucket_high
  • bucket_high > 1.0
  • bucket_low > 0.0 && bucket_low < 1.0
  • min_sstable_size >= 0
  • min_threshold < max_threshold
  • min_threshold > 2

Leveled Compaction Strategy:

  • sstable_size_in_mb > 0

For Time Window Compaction Strategy checks are already done.

(Docs of all strategies and their options: https://github.com/scylladb/scylladb/blob/master/docs/cql/compaction.rst)

Do we want to do the checks for Date-tiered Compaction Strategy (it's deprecated)?

@bhalevy
Copy link
Member

bhalevy commented Mar 14, 2023

@raphaelsc ☝️

@bhalevy
Copy link
Member

bhalevy commented Apr 25, 2023

ping @raphaelsc please confirm #2336 (comment)

@raphaelsc
Copy link
Member Author

@Deexie

please check check_restricted_table_properties() in cql3/statements/create_table_statements.cc. It currently performs some validation, and we should call strategy-specific validation from there.

All strategies inherit common strategy options (tombstone_threshold, etc), see: compaction_strategy_impl in compaction/compaction_strategy_impl.hh .

I suggest adding a validate(options) method to compaction_strategy_impl class. the options can be retrieved via schema->compaction_strategy_options().

Then we'd do the same for size_tiered_compaction_strategy. Add a validate(options) method to it, which in turn calls compaction_strategy_impl::validate(options), and performs validation on STCS options.

The same logic applies to LCS and TWCS, where both inherit STCS options.

DTCS is deprecated, we can just ignore it.

@bhalevy
Copy link
Member

bhalevy commented May 17, 2023

@Deexie ping

@DoronArazii DoronArazii removed this from the 5.3 milestone Jul 17, 2023
@avikivity
Copy link
Member

Only affects invalid DDL input, not backporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/cassandra 3.x compatibility area/compaction Field-Tier3 Nice to have issues as per FieldEngineering request good first issue symptom/ux Concerns regarding the user experience in working with Scylla.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants