Thread-safety of leveldb snapshot

leveldb

Solution

According to the docs:

A database may only be opened by one process at a time. The leveldb implementation acquires a lock from the operating system to prevent misuse. Within a single process, the same leveldb::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.

https://github.com/google/leveldb/blob/master/doc/index.md#concurrency

Problem

Is reading snapshot a completely thread-safe operation of leveldb? Specifically, is it thread-safe that one thread reads a snapshot of a leveldb database, while another thread is reading/writing on the same database? And what about another thread may concurrently close the database or remove the snapshot in reading?

Original source