Replies: 1 comment
-
Hello @phitrti, I don't know how the app schedules writes and reads, I don't know what's a "thread", or a "user interaction", so I can't really comment. Clearly the app does not access the database states you expect. Maybe log sql statements, and make sure you log the actual connection so that you know which connection does what (writer, reader, etc): var configuration = Configuration()
configuration.prepareDatabase { db in
let dbName = db.description
db.trace { print("\(dbName)> \($0)") }
}
let dbPool = try DatabasePool(path: ..., configuration: configuration) This should help you understand why the various connections see the database states you describe. When the cause is understood, it will be easier to find the fix. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In our mobile app, we are using a DatabasePool. We pull wearable data and save potentially 1000s of records into the database. Once this save is complete (await db.insertReadings), we then kick off 2 async process to upload this data to 2 different end points. So lets say we wrote 5000 records to the database.
in the upload threads, we first query how many records there are to upload so we can chunk the upload. In theory, both threads should return that there are 5000 records to upload. But the truth is that 1 thread uploads all 5000 while the other thread might just upload 5 or 10 and it it isn't until a subsequent user interaction to upload that the 2nd uploader finally gets all the records to upload. So we do eventually get everything but i'm curious doing simultaneous async reads using DatabasePool why only 1 read gets everything while the other doesn't. These are reads so I would have expected both threads to get everything. I've read the concurrency section multiple times so I must be missing something.
thoughts?
Randy
Beta Was this translation helpful? Give feedback.
All reactions