I've read the documentation and found very little about multiple processes (readers and writers) accessing a single kyotocabinet database. It appears you can create multiple readers, but unless you specify ONOLOCK multiple writers will block trying to open the db. Can anyone shed any light on how this works or if it is possible? I understand KyotoTycoon is one option, but am curious specifically about KyotoCabinet.
Found this on the tokyocabinet manpage:
Tokyo Cabinet provides two modes to connect to a database: "reader" and "writer". A reader can perform retrieving but neither storing nor deleting. A writer can perform all access methods. Exclusion control between processes is performed when connecting to a database by file locking. While a writer is connected to a database, neither readers nor writers can be connected. While a reader is connected to a database, other readers can be connect, but writers can not. According to this mechanism, data consistency is guaranteed with simultaneous connections in multitasking environment.
Guessing then, that this applies to kyoto as well.
Kyoto Cabinet is thread safe, but you cannot have separate processes reading and writing at the same time. You can have multiple reader processes as long as there is no writer connected.
From the website:
Sharing One database by Multiple Processes
Multiple processes cannot access one database file at the same time. A database file is locked by reader-writer lock while a process is connected to it. Note that the `BasicDB::ONOLOCK' option should not be used in order to escape the file locking mechanism. This option is for workaround against some file systems such as NFS, which does not support file locking mechanisms.
If you want to get multiple processes to share one database, use Kyoto Tycoon instead. It is a lightweight database server as network interface to Kyoto Cabinet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With