Comments (6)
@kaedroho absolutely! The release I cut today will be a patch for 0.4, and it will also be in master for our upcoming 0.5 release.
from rust-rocksdb.
Indeed, only the underlying native type for DB
is thread-safe β so all its methods can be &self
, but for the others like WriteBatch
, etc., theyβll need &mut self
methods where appropriate.
Thanks for sorting this out.
On 13 Nov 2016, at 12:01, Tyler Neely [email protected] wrote:
I'm in favor of making any of the &mut self methods &self if their underlying implementations are thread-safe. From the rocksdb docs:
A database may only be opened by one process at a time. The rocksdb implementation acquires a lock from the operating system to prevent misuse. Within a single process, the same rocksdb::DB object may be safely shared by multiple concurrent threads. I.e., different threads may write into or fetch iterators or call Get on the same database without any external synchronization (the leveldb implementation will automatically do the required synchronization). However other objects (like Iterator and WriteBatch) may require external synchronization. If two threads share such an object, they must protect access to it using their own locking protocol. More details are available in the public header files.
Scanning the source code, I actually need to make a few things that are &self &mut self! (WriteBatch, DBIterator::valid, maybe some others) This may already be causing bugs for users of this library! I'll get on this right now and cut a new release, as safety issues like this deserve rapid attention. I really appreciate you bringing up this issue, even though this outcome may not be the one you were hoping for :)We can talk about whether we want to provide optional thread-safe access patterns that use RWLock or something under the hood. We need to think about a clean way to support both, but in the mean time I will perform an audit and make the methods we provide safe.
β
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub #91 (comment), or mute the thread https://github.com/notifications/unsubscribe-auth/AAEF3GWqtb0emV0n9Da2qtzf0SmEH3N1ks5q9vwDgaJpZM4KvNYg.
from rust-rocksdb.
I'm in favor of making any of the &mut self
methods &self
if their underlying implementations are thread-safe. From the rocksdb docs:
A database may only be opened by one process at a time. The rocksdb implementation acquires
a lock from the operating system to prevent misuse. Within a single process, the same
rocksdb::DB object may be safely shared by multiple concurrent threads. I.e., different threads
may write into or fetch iterators or call Get on the same database without any external
synchronization (the leveldb implementation will automatically do the required synchronization).
However other objects (like Iterator and WriteBatch) may require external synchronization. If two
threads share such an object, they must protect access to it using their own locking protocol.
More details are available in the public header files.
Scanning the source code, I actually need to make a few things that are &self
&mut self
! (WriteBatch, DBIterator::valid, maybe some others) This may already be causing bugs for users of this library! I'll get on this right now and cut a new release, as safety issues like this deserve rapid attention. I really appreciate you bringing up this issue, even though this outcome may not be the one you were hoping for :)
We can talk about whether we want to provide optional thread-safe access patterns that use RWLock or something under the hood. We need to think about a clean way to support both, but in the mean time I will perform an audit and make the methods we provide safe.
from rust-rocksdb.
@ngaut heads up, you may have addressed this already in your code but this is a safety issue you should be aware of if not.
from rust-rocksdb.
This may already be causing bugs for users of this library! I'll get on this right now and cut a new release, as safety issues like this deserve rapid attention.
Would you consider making a stable/0.4.x
branch, based on 0.4.2, which we can cherry-pick safety fixes like this to and release as 0.4.3 (and so on).
0.5 currently has some API breakages so I think it's worth including this fix in both a patch for 0.4.x as well as the forthcoming 0.5 release.
from rust-rocksdb.
cut v0.4.2 that uses a RwLock to preserve the API, and in the 0.5.0 branch remove Writeable and have operations on a WriteBatch be &mut self
.
https://github.com/spacejam/rust-rocksdb/releases/tag/v0.4.2
from rust-rocksdb.
Related Issues (20)
- Build broken for 0.8.3+7.4.4 HOT 1
- Is WriteBatchWithIndex supported? HOT 4
- `delete_range` and `delete_range_cf` not implemented for `TransactionDB` or `OptimisticTransactionDB` HOT 3
- multi-threaded-cf feature produces incompatible API--does not adhere to docs.rust-lang.org guidelines
- write_opt consumes WriteBatch
- Request to be added as a maintainer HOT 4
- Why librocksdb-sys recompilation not cached?
- plan to new release version? HOT 6
- [security] cargo audit found vulnerabilities HOT 1
- is FlushOptions missing Send and Sync impl's?
- enabling the jemalloc feature doesn't actually enable jemalloc HOT 12
- error: failed to run custom build command for `librocksdb-sys v0.8.0+7.4.4` (arch linux) HOT 6
- Fail to build on Windows msys2 rust (x86_64-pc-windows-gnu toolchain) HOT 1
- flush isn't exposed for TransactionDB
- compaction_filter on a column family not triggered HOT 1
- Failed to build using Clang-18
- why `share_table_files` option is not support?
- TransactionDB `open_default` panic HOT 5
- Support for RocksDB 9.X HOT 1
- Way to ensure checkpoint is completed? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust-rocksdb.