Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

Combining queries in transaction and outside transactions from multiple threads #22

Open
Lopdo opened this issue Mar 16, 2015 · 2 comments

Comments

@Lopdo
Copy link

Lopdo commented Mar 16, 2015

I have an app that downloads bunch of data and saves it into DB, I save this data in transaction in background thread.
I also make simple SELECT queries from main thread that are not in any transaction. There are some weird crashes in my app (transaction closure, not sure where exactly) that led me to check this method:

private static func putOnThread(task: ()->Void) {
    if SQLiteDB.sharedInstance.inTransaction || SQLiteDB.sharedInstance.savepointsOpen > 0 || SQLiteDB.sharedInstance.openWithFlags {
        task()
    } else {
        dispatch_sync(SQLiteDB.sharedInstance.queue) {
            task()
        }
    }
}

If I am reading this correctly then it means that if I execute any query while one of transactions is in progress (in background thread), that new query will not be run in SD queue but it will be executed immediately. Is this intentional? Can it cause some problems in situation I described above?

@dziedziela
Copy link

Is anyone going to look into this?

@8ggmaker
Copy link

It makes me confused ,too

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants