-
Notifications
You must be signed in to change notification settings - Fork 3.8k
17737 4.1 sstable preemptive open interval in mb #1758
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
17737 4.1 sstable preemptive open interval in mb #1758
Conversation
jonmeredith
left a comment
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.
Checking the virtual tables, I used the deprecated sstable_preemptive_open_interval_in_mb: -1 until I understand how to set the newer version. The backward compatibility doesn't handle converting back to sstable_preemptive_open_interval_in_mb and reports as null. I'm happy to live with it if it isn't an easy fix.
Connected to Test Cluster at 127.0.0.1:9042
[cqlsh 6.1.0 | Cassandra 4.1-alpha2-SNAPSHOT | CQL spec 3.4.6 | Native protocol v5]
Use HELP for help.
cqlsh> SELECT * FROM system_views.settings WHERE name = 'sstable_preemptive_open_interval';
name | value
----------------------------------+-------
sstable_preemptive_open_interval | null
(1 rows)
cqlsh> SELECT * FROM system_views.settings WHERE name = 'sstable_preemptive_open_interval_in_mb';
name | value
----------------------------------------+-------
sstable_preemptive_open_interval_in_mb | null
Then tried setting to 99 using JMX which worked fine.
(1 rows)
cqlsh> SELECT * FROM system_views.settings WHERE name = 'sstable_preemptive_open_interval_in_mb';
name | value
----------------------------------------+-------
sstable_preemptive_open_interval_in_mb | 99
(1 rows)
cqlsh> SELECT * FROM system_views.settings WHERE name = 'sstable_preemptive_open_interval';
name | value
----------------------------------+-------
sstable_preemptive_open_interval | 99MiB
(1 rows)
| public static void setSSTablePreemptiveOpenIntervalInMiB(int mib) | ||
| { | ||
| conf.sstable_preemptive_open_interval = new DataStorageSpec.IntMebibytesBound(mib); | ||
| if (mib == -1) |
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 (mib == -1) | |
| if (mib < 0) |
conf/cassandra.yaml
Outdated
| # Set sstable_preemptive_open_interval to null for disabled which is equivalent to the sstable_preemptive_open_interval_in_mb | ||
| # being negative |
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.
Comment is a lot longer than the rest of the block, would you mind wrapping it early. I'm guessing we still refer to deprecated parameters in other comments and we can remove them if the deprecated settings are actually removed.
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.
How do you set to null? I tried
sstable_preemptive_open_interval: null
but got this on startup.
Exception (org.apache.cassandra.exceptions.ConfigurationException) encountered during startup: Invalid yaml. Those properties [sstable_preemptive_open_interval] are not valid
ERROR [main] 2022-07-27 11:34:46,521 CassandraDaemon.java:896 - Exception encountered during startup: Invalid yaml. Those properties [sstable_preemptive_open_interval] are not valid
Invalid yaml. Those properties [sstable_preemptive_open_interval] are not valid
then
sstable_preemptive_open_interval:
and got
ERROR [main] 2022-07-27 11:37:15,213 CassandraDaemon.java:896 - Exception encountered during startup: Invalid yaml. Those properties [sstable_preemptive_open_interval] are not valid
Invalid yaml. Those properties [sstable_preemptive_open_interval] are not valid```
and of course `-1` still fails as expected.
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.
Good catch, null is valid only if it is default value in the Config class which is not the case here :(
I should have seen that. I will have to think about how to workaround it and add a startup test as now I double checked and it seems I made the same mistake yesterday with one more property so now I have to fix both of them. Thank you for catching it!
About the -1, it starts for me with sstable_preemptive_open_interval_in_mb = -1, then we see in the logs the converter loaded it as sstable_preemptive_open_interval = null; But I definitely null doesn't work.
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.
Thinking out loud.... we can do probably a mix of what you suggested initially and this fix for this special case. We can add a flag parameter to enable/disable which will be used with the new property if we want to disable it. If someone uses the old one we should prohibit setting the new flag then in parallel on startup if the old one was found in the yaml, WDYT?
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 might be able to workaround that need of additional flag actually and special case those two properties so that they do not error out when set to null.
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.
The more I think, the more I am convinced enable/disable flags should work for features and not individual properties
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 hope I didn't misunderstood your question.
I was asking if sstable_preemptive_open_interval_in_mb could set a new sstable_preemptive_open_enabled entry as well as sstable_preemptive_open_interval.
If you have a fix for setting null and don't need to create an enabled flag I'm fine with that. I thought you were saying you might need to create on to resolve this problem.
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 was asking if sstable_preemptive_open_interval_in_mb could set a new sstable_preemptive_open_enabled entry as well as sstable_preemptive_open_interval.
No, currently we map one or more old names to only one new property.
If you have a fix for setting null and don't need to create an enabled flag I'm fine with that. I thought you were saying you might need to create on to resolve this problem.
I created a quick one by special casing this particular property to be able to set it to null even if the default value is not null. So I will need to figure out then only the VT Converters
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.
...and more tests to prevent us from future regressions of course :-)
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.
Oh, seems it was me not that ticket that broke it (that one just changes to return null and not 0)... I already have a fix, adding more tests, will push a patch later tonight
|
About the VT, the conversion happens in the last method in the converter which was not handling the special case, I will fix it in a moment. |
|
Ha...about the VT, it seems that someone added null check in the unconvert() method and broke the special cases we have in the converter... I will see to fix it and add more tests to prevent that from happening in the future |
…ue for disabled Fix Settings Virtual Table backward compatibility for properties that would be assigned null now instead of -1 or negatives
|
@jonmeredith I just pushed review commits to address your feedback and follow up discussion plus improved the testing. The only current issue I see is with the |
.build/build-rat.xml
Outdated
| <exclude NAME="**/doc/antora.yml"/> | ||
| <exclude name="**/test/conf/cassandra.yaml"/> | ||
| <exclude name="**/test/conf/cassandra-old.yaml"/> | ||
| <exclude name="**/cassandra-converters-special-cases-old-names.yaml"/> |
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 think this should be <exclude name="**/test/conf/cassandra-converters-special-cases-old-names.yaml"/>
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.
Good point, it still works this way (tested locally) but it is inconsistent, I will change it, thanks
NEWS.txt
Outdated
|
|
||
| Upgrading | ||
| --------- | ||
| - `sstable_preemptive_open_interval_in_mb` being negatve for disabled is equivalent to `sstable_preemptive_open_interval` |
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.
| - `sstable_preemptive_open_interval_in_mb` being negatve for disabled is equivalent to `sstable_preemptive_open_interval` | |
| - `sstable_preemptive_open_interval_in_mb` being negative for disabled is equivalent to `sstable_preemptive_open_interval` |
| @@ -0,0 +1,3 @@ | |||
| sstable_preemptive_open_interval_in_mb: -1 | |||
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.
Maybe we could add a brief comment at the beginning of this file indicating what it's used for.
| @@ -0,0 +1,3 @@ | |||
| sstable_preemptive_open_interval: | |||
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.
Maybe we could add a brief comment at the beginning of this file indicating what it's used for.
|
|
||
| @Replaces(oldName = "sstable_preemptive_open_interval_in_mb", converter = Converters.MEBIBYTES_DATA_STORAGE_INT, deprecated = true) | ||
| @Nullable | ||
| @Replaces(oldName = "sstable_preemptive_open_interval_in_mb", converter = Converters.NEGATIVE_DATA_STORAGE_INT, deprecated = 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.
Should't this keep including MEBIBYTES in the name, as in NEGATIVE_MEBIBYTES_DATA_STORAGE_INT or MEBIBYTES_CUSTOM_DATA_STORAGE_INT?
|
|
||
| public static int getSSTablePreemptiveOpenIntervalInMiB() | ||
| { | ||
| if (conf.sstable_preemptive_open_interval == null) |
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'd add some JavaDoc to the getter mentioning that it might return negative.
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 info is in the JavaDoc for the JMX method but I guess it doesn't hurt to add it here too.
| public static void setSSTablePreemptiveOpenIntervalInMiB(int mib) | ||
| { | ||
| conf.sstable_preemptive_open_interval = new DataStorageSpec.IntMebibytesBound(mib); | ||
| if (mib < 0) |
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'd add some JavaDoc to this setter mentioning that it accepts negative values.
|
@adelapena I addressed your feedback. The new tests pass locally, but I started full CI #1823 https://app.circleci.com/pipelines/github/ekaterinadimitrova2/cassandra?branch=17737-4.1-sstable_preemptive_open_interval_in_mb |
|
CI shows some issue with @nullable, I think I need to change the scope in build.xml for the annotation, I will work it now. I will let you know when I have the fix pushed |
|
com.google.code.findbugs needs to have default compile and not provided scope for this patch to work. |
| public void set(Object object, Object value) throws Exception | ||
| { | ||
| if (value == null && get(object) != null) | ||
| if (value == null && get(object) != null && !allowsNull) |
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.
It seems inconsistent to only require an Nullable annotation for configuration that can be set null, but is not defaulted to be null. What do you think about dropping the get(object) != null check, and applying @Nullable to all cases in Config that can be legitimately set to null?
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 thought about that yesterday but my concern is that there are too many of those and they are not only from the new types and not only new ones...
Maybe we can open a follow up ticket only on trunk as an improvement? And add more testing, etc... I am afraid we are getting into another rabbit hole.
Also, it is good if we can keep this case as an exception and not make people think that it is a good practice. Why? Because if they start adding other default values and do not test properly that the null value is handled (and I am sure someone will do that) this can be reaaaally bad. What do you think?
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.
Understand about rabbit holes. I'd be happy with opening a follow up JIRA and adding a comment referencing it in this method.
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.
Ticket opened, I linked it to this ticket and added a TODO comment
| NEGATIVE_MEBIBYTES_DATA_STORAGE_INT(Integer.class, DataStorageSpec.IntMebibytesBound.class, | ||
| o -> o < 0 ? null : new DataStorageSpec.IntMebibytesBound(o), | ||
| o -> o == null ? -1 : o.toMebibytes()), |
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.
Trivial nit that can be addressed on commit: the parameters are misaligned after renaming the converter.
|
The last changes look good to me. It seems that CI hasn't been started. Also we'd need to apply the changes to the patch for trunk. |
jonmeredith
left a comment
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.
Looks good to me - assuming tests are passing and changes on this PR are propagated up to trunk
…acy_<version>_tuple" sstables. (apache#1758) Fix LegacySStableTest to only perform tuple checks on versions "ba" and higher because we are unable to generate tuple sstables in earlier versions.
No description provided.