-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
(fix) rocksdb-compression-on-windows #22
Conversation
… any of the compression type
|
||
if (Platform.isWindows()) { | ||
// Seems like the rocksdb jni for Windows doesn't come linked with any of the compression type | ||
options.setCompressionType(CompressionType.NO_COMPRESSION); |
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.
可以不设置
.setLevel0FileNumCompactionTrigger(LEVEL0_FILE_NUM_COMPACTION_TRIGGER) // | ||
.setLevel0SlowdownWritesTrigger(LEVEL0_SLOWDOWN_WRITES_TRIGGER) // | ||
.setLevel0StopWritesTrigger(LEVEL0_STOP_WRITES_TRIGGER) // | ||
.setMaxBytesForLevelBase(MAX_BYTES_FOR_LEVEL_BASE) // | ||
.setTargetFileSizeBase(TARGET_FILE_SIZE_BASE) // | ||
.setMergeOperator(mergeOperator) // | ||
.setMemtablePrefixBloomSizeRatio(0.125); | ||
if (Platform.isWindows()) { |
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.
先不要 merge 吧,我把 export rocksdb options 一块改掉
@killme2008 再看下是否有其他意见? |
Runtime.getRuntime().addShutdownHook(new Thread(() -> { | ||
for (final DBOptions opts : rocksDBOptionsTable.values()) { | ||
if (opts != null) { | ||
opts.close(); |
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.
如果用户已经释放了,这里会 core dump 的。
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.
我记得这些选项会在 Storage 这些服务里 close,所以无论是用户,还是这些 shutdown hook,都没有必要去 close,选项统一交给使用的服务关闭。
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.
理论上只要允许用户传入 options,都阻止不了用户提前释放 options 产生的 core dump, 这个比较头疼;
StorageOptionsFactory 中其实是存储了一份 options 模板,getXXX 方法会返回一个 copy 副本,这些副本都是有使用者统一释放的;
shutdown hook 释放的是那一份模板 options
我做了以下改进:
- 增加 checkInvalid (opts) 方法,在 copy 之前先检查 opts 是否被释放, 如果已被用户释放则抛出异常,避免直接 copy 产生的 core dump,但先检查再拷贝不是原子操作,无法完全避免用户提前释放导致 core dump
- 去掉 shutdown hook, 增加 releaseAllOptions() , 用户可以在程序退出时选择主动调用该方法来释放所有模板options,但其实也可以不调用,因为 rocksdb 的options在进程退出时都会自动释放
Seems like the rocksdb jni for Windows doesn't come linked with any of the compression type