-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
periodic compaction seconds not working as expected #12165
Comments
You may want to consider using delete triggered compaction if the goal is to remove files with many tombstones:
Another thing to consider to is do manual compaction after you issue deletions. |
oh so I did misunderstand what this feature does, what does also I did read in the docs about setting
regarding this, I initially considered it but after asking around in the community, it seems this feature is best suited for when deletion is concentrated in a specific range where as my deletes are all over the place. Is this accurate?
This definitely sounds like a great idea and I'll likely go with this approach and maybe combine it with the ttl based compaction. Also regarding https://github.com/facebook/rocksdb/wiki/Manual-Compaction#compactrange, do you recommend I change any of the defaults to achieve what I want of removing tombstones? I'm guessing I need to set CompactRangeOptions::bottommost_level_compaction to BottommostLevelCompaction::KforceOptimized since I don't have a custom compaction filter setup and I want to compact the bottommost level? |
It lets files go through compaction filter periodically. The option has a different meaning for universal compaction.
I don't see it in C API. Feel free to submit a PR to add it.
You can specify a file to be compacted if it has more than a D tombstones in a window of X entries, or that the ratio of tombstones exceed some value.
Yeah, setting it to kForceOptimized should be enough. |
I wonder if we could get away with the following behavior change: in leveled compaction, also trigger compaction to the next level for upper-level files whose data age exceeds |
As a user, I believe it would be better if we could trigger compaction to the next level. I can submit a PR to resolve this if it sounds good to maintainers. |
I also agree that it would be great to trigger compaction to the next level. |
I've created a pr to expose options ttl via c api #12170 |
I see, seems |
right, based on my understanding, I completely misunderstood how periodic_compaction_seconds works, what I was looking for is the TTL option |
I checked the implementation, and the TTL option only triggers the next-level compaction without caring about the input file level. So I also think it's good to switch to the TTL option since we're using the level compaction. |
Probably not, this can also prevent
I'm fine with this change. It should not affect users who configure ttl <= periodic_compaction_seconds. The change may not make sense when |
It sounds good to me |
Sure, thank you! |
I just stumbled on this exact same gotcha. Perhaps the documentation / comments around |
This is required until RocksDB fixes the behavior of periodic compaction seconds: facebook/rocksdb#12165
…_compaction_seconds (#12175) Summary: Currently, the data are always compacted to the same level if exceed periodic_compaction_seconds which may confuse users, so we change it to allow trigger compaction to the next level here. It's a behavior change to users, and may affect users who have disabled their ttl or ttl > periodic_compaction_seconds. Relate issue: #12165 Pull Request resolved: #12175 Reviewed By: ajkr Differential Revision: D52446722 Pulled By: cbi42 fbshipit-source-id: ccd3d2c6434ed77055735a03408d4a62d119342f
|
My understanding is that with periodic compaction seconds, we can schedule files to be compacted. And when compaction runs, tombstones are removed to keep db size small among other things.
My db size is small (around 5gb) so leaving all the defaults in place for rocksdb will mean I will accumulate a lot of tombstones so before trying to use periodic compactions seconds (because it wasn't exposed via c api so I couldn't use it), I used less optimal settings to force compaction:
opts.set_max_bytes_for_level_base(25 * 1024 * 1024);
opts.set_target_file_size_base(32 * 1024 * 1024);
which was fine but it's not ideal. After periodic compaction seconds was exposed via c api, I removed the two settings above and set periodic compaction seconds to run every 3 hours (i delete data on a cron every 4 hours).
As we can see, periodic compaction seconds doesn't seem to force compaction? or at least doesn't delete tombstones like I expected:
Here is the LOG file as well in case it helps:
LOG.txt
Any idea why periodic compaction seconds is not working? Or at least is not doing the same thing as setting the "bad" options
The text was updated successfully, but these errors were encountered: