{"action":"created","issue":{"url":"https://api.github.com/repos/ccgus/fmdb/issues/444","labels_url":"https://api.github.com/repos/ccgus/fmdb/issues/444/labels{/name}","comments_url":"https://api.github.com/repos/ccgus/fmdb/issues/444/comments","events_url":"https://api.github.com/repos/ccgus/fmdb/issues/444/events","html_url":"https://github.com/ccgus/fmdb/issues/444","id":120430727,"number":444,"title":"FMDBQueue and SQLite Database is locked","user":{"login":"nawar","id":928095,"avatar_url":"https://avatars.githubusercontent.com/u/928095?v=3","gravatar_id":"","url":"https://api.github.com/users/nawar","html_url":"https://github.com/nawar","followers_url":"https://api.github.com/users/nawar/followers","following_url":"https://api.github.com/users/nawar/following{/other_user}","gists_url":"https://api.github.com/users/nawar/gists{/gist_id}","starred_url":"https://api.github.com/users/nawar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nawar/subscriptions","organizations_url":"https://api.github.com/users/nawar/orgs","repos_url":"https://api.github.com/users/nawar/repos","events_url":"https://api.github.com/users/nawar/events{/privacy}","received_events_url":"https://api.github.com/users/nawar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-12-04T15:58:16Z","updated_at":"2015-12-04T18:54:06Z","closed_at":null,"body":"I've been having this issue with FMDBQueue `dispatch_sync(_queue)` queue as it is not respecting the FIFO order that is supposed to be having and allowing a **write** from a different thread, to have a lock on the database while a another **write**, from another different thread, will be getting the \"Database is locked\" error. \r\n\r\nExample:\r\n\r\nThread 23:  executeUpdate() ==> (FMDBDatabaseBusyHandler)\r\nThread 19: executeUpdate() ==> (Can't access the database because it is locked)\r\n\r\nI am using FMDB user version 2.5 and I am using `inDatabase` to run the block of the SQL needed to be executed.\r\n\r\nSo I am wondering why the serial queue of FMDBQueue is not allowing Thread 23 to finish then allow Thread 19 to finish next. I am not sure if this is an issue with the implementation.\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/ccgus/fmdb/issues/comments/162050804","html_url":"https://github.com/ccgus/fmdb/issues/444#issuecomment-162050804","issue_url":"https://api.github.com/repos/ccgus/fmdb/issues/444","id":162050804,"user":{"login":"ccgus","id":60178,"avatar_url":"https://avatars.githubusercontent.com/u/60178?v=3","gravatar_id":"","url":"https://api.github.com/users/ccgus","html_url":"https://github.com/ccgus","followers_url":"https://api.github.com/users/ccgus/followers","following_url":"https://api.github.com/users/ccgus/following{/other_user}","gists_url":"https://api.github.com/users/ccgus/gists{/gist_id}","starred_url":"https://api.github.com/users/ccgus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ccgus/subscriptions","organizations_url":"https://api.github.com/users/ccgus/orgs","repos_url":"https://api.github.com/users/ccgus/repos","events_url":"https://api.github.com/users/ccgus/events{/privacy}","received_events_url":"https://api.github.com/users/ccgus/received_events","type":"User","site_admin":false},"created_at":"2015-12-04T18:54:06Z","updated_at":"2015-12-04T18:54:06Z","body":"Looks like you might have two FMDatabaseQueue instances- is that correct?  If that's true, then you'll need to share a single one across threads for the locking not to happen."}}