質問

Is it possible in Kyoto Cabinet database to make safely a database snapshot and concurrently write to database in the same time ?

The KyotoCabinet database class kyotocabinet.DB (for JAVA among other languages) provides the following methods:

 boolean    dump_snapshot(String dest) // Dump records into a snapshot file.
 boolean    copy(String dest) // Create a copy of the database file. 

Both operations could be quite long. I did not test this methods directly but by using the kcpolymgr utility from different process. I found that the operations blocks other writer process-es (kcpolymgr set) until the operations finish.

Is the behaviour the same when writes come from other threads in the same process ?

役に立ちましたか?

解決

The snapshot or copy of the database blocks concurrent database operations from other threads and processes.

To test within the same process I exposed the Kyoto Cabinet methods by JMX and tried to set or get any value from the database while concurrently a snapshot or a copy were being in progress.

Methods set and get were waiting for the concurrent snapshot or copy to finish.


I found a part of the documentation that covers the issue. It mansions the cache hash database but it looks like the other database implementations behaves similarly:

Chiefly for the cache hash database and the cache tree database, the "pseudo-snapshot" mechanism is provided. The BasicDB::dump_snapshot' dumps all records into a stream or a file. The BasicDB::load_snapshot' method loads records from a stream or a file. Although the operations are performed atomically, they don't finish momentarily but take time in proportion of the database size with blocking the other threads. Because the format of pseudo-snapshot data is common among the all database classes, it is useful to migrate records for each other.

db.dump_snapshot("backup.kcss"); 
db.load_snapshot("backup.kcss");
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top