Open LMDB files with MDB_NOLOCK if no write access#3088
Conversation
274c88a to
08e313b
Compare
|
I think if we're going to allow this kind of behavior, it should be explicitly specified by the user, no? (This is still subject to @hyc's concerns, right?) Allowing the user to demand something dangerous is okay; falling back to dangerous behavior isn't, IMO, log messages notwithstanding. |
|
In fact I've been running into this myself lately, so I think I'm favor of having this functionality, but as an explicit (build?) option. |
08e313b to
19f8149
Compare
Ok, build option added. Does I also rearranged a few lines in the build files from #2523 and #3081 to standardize on the order |
|
"Allow readonly" doesn't feel right to me; you're always allowed to read a read-only LMDB. The issue is whether you're allowed to open an LMDB without locking (and indeed, the flag in question is Rearranging lines is fine, but let's have a separate commit for that. |
Enforcing a consistent ordering - OpenCV, LevelDB, LMDB This will allow me to add the ALLOW_LMDB_NOLOCK option just after the USE_LMDB option, while keeping the IO dependency options together.
This option lets you open LMDB files with the MDB_NOLOCK flag. You should not set this flag if you will be reading LMDBs with any possibility of simultaneous read and write.
19f8149 to
b93afe8
Compare
Haha ok that's what I started with initially but I changed my mind. Changed it back.
Done.
Done. |
|
Looks good except:
|
They both default to OFF/0 already. I didn't add the
Seemed strange to me too. I think it gave me an error. Either way, it's what the docs say to do:
|
Oops, I misread it. This seems pretty ready to me, I'll leave it momentarily to see if there is further discussion, but then I think we can merge. |
Ping. |
Open LMDB files with MDB_NOLOCK if no write access
|
Sorry for the wait! This looks good to me, merging. Thanks @lukeyeager, this provides a nice workaround for a common annoyance. |
Implement similar patch to BVLC/caffe#3088 If we can't open the LMDB database, try again with no locking. If this fails again, throw a human-readable error, for example: 2015-11-11 21:29:33 [INFO ] opening LMDB database: /fast-scratch/gheinrich/ws/digits/digits/jobs/20151111-210842-a4ec/train_db /fast-scratch/gheinrich/ws/torch/install/bin/luajit: ...nrich/ws/torch/install/share/lua/5.1/threads/threads.lua:264: [thread 4 callback] /fast-scratch/gheinrich/ws/digits/tools/torch/data.lua:117: Failed to open LMDB database: Permission denied
Implement similar patch to BVLC/caffe#3088 If we can't open the LMDB database, try again with no locking. If this fails again, throw a human-readable error, for example: 2015-11-11 21:29:33 [INFO ] opening LMDB database: /fast-scratch/gheinrich/ws/digits/digits/jobs/20151111-210842-a4ec/train_db /fast-scratch/gheinrich/ws/torch/install/bin/luajit: ...nrich/ws/torch/install/share/lua/5.1/threads/threads.lua:264: [thread 4 callback] /fast-scratch/gheinrich/ws/digits/tools/torch/data.lua:117: Failed to open LMDB database: Permission denied
Similar to [the first half of] #2384. The difference is that MDB_NOLOCK is only used if you were unable to acquire the lock, and a WARNING will appear in the logs.
/cc @cypof @hyc