{"action":"closed","issue":{"url":"https://api.github.com/repos/Level/levelup/issues/518","repository_url":"https://api.github.com/repos/Level/levelup","labels_url":"https://api.github.com/repos/Level/levelup/issues/518/labels{/name}","comments_url":"https://api.github.com/repos/Level/levelup/issues/518/comments","events_url":"https://api.github.com/repos/Level/levelup/issues/518/events","html_url":"https://github.com/Level/levelup/issues/518","id":268348845,"node_id":"MDU6SXNzdWUyNjgzNDg4NDU=","number":518,"title":"Support for waiting on levelup leveldb lock","user":{"login":"hellais","id":424620,"node_id":"MDQ6VXNlcjQyNDYyMA==","avatar_url":"https://avatars0.githubusercontent.com/u/424620?v=4","gravatar_id":"","url":"https://api.github.com/users/hellais","html_url":"https://github.com/hellais","followers_url":"https://api.github.com/users/hellais/followers","following_url":"https://api.github.com/users/hellais/following{/other_user}","gists_url":"https://api.github.com/users/hellais/gists{/gist_id}","starred_url":"https://api.github.com/users/hellais/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hellais/subscriptions","organizations_url":"https://api.github.com/users/hellais/orgs","repos_url":"https://api.github.com/users/hellais/repos","events_url":"https://api.github.com/users/hellais/events{/privacy}","received_events_url":"https://api.github.com/users/hellais/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-10-25T10:40:05Z","updated_at":"2018-06-15T21:33:15Z","closed_at":"2018-06-15T21:33:15Z","author_association":"NONE","body":"First let me explain my use-case.\r\n\r\nI am planning on using levelup (and in particular leveldb) as a simple key value store to be embedded inside of a CLI application.\r\n\r\nThe readme states:\r\n> Stores like LevelDB are thread-safe but they are not suitable for accessing with multiple processes\r\n\r\nWhich I think is reasonable.\r\n\r\nHow I have been trying to adapt level DB to my use case is that basically I wrap every operation I do in the various leveldb databases managed by my application, in blocks that open the database and when they are done with it (having written or read from it), they close it.\r\n\r\nHowever, there is the risk of race conditions in opening the database, if another instance of the CLI application (because the user ran a couple of the same command) is at that time acquiring the lock.\r\n\r\nIn my use-case performance is not a big issue, that is to say it's acceptable for me to even wait some seconds to acquire the lock (realistically it will not be that much).\r\n\r\nIs there an API call for levelup that I can call to wait on the DB lock instead of throwing an exception (maybe with a timeout value after which it just gives up)?\r\n\r\nI suspect there are other people also with this use-case, how do you handle concurrency?\r\n\r\nSome of the things I have been thinking of are:\r\n* Implementing my own file system based locking on each database\r\n* Poll the leveldb waiting for the lock to be released\r\n\r\nIs perhaps leveldb not the best solution to my use-case? Would you have a suggestion for an alternative?"}}
{"actor":{"display_login":"vweevers"}}