3 ms·
Is there any technical information on how the database works? For a supposed Sqlite replacement, there is a surprising lack of the information. The only referen
by theamk 10y ago
Is there any technical information on how the database works? For a supposed Sqlite replacement, there is a surprising lack of the information. The only reference to concurrency mode I have found is this:
> All changes to an object (addition, modification and deletion) must be done within a write transaction.
> Write transactions incur non-negligible overhead - you should architect your code to minimize the number of write transactions.
So is there a single write lock? If you try to start two transactions, will the second one be delayed or retried? Can reads proceed while the transaction is processing?
> Results instances are live, auto-updating views into the underlying data
So if I am doing x.first, x.second while the object is being updated in a second thread, will I get mixed state?
Is database crash proof? If the phone runs out of battery while in write transaction, will the database get damaged?
... so many questions
- brmunk 10y agoIt's ACID & Serializable. A write will block all other writes, but multiple reads can occur without overhead or blocking due to MVCC. Reads are consistent within the runloop, but updates to your objects occurs when you start a write transaction, so you know you always work on the latest version of the data. Basically, you are in an implicit read transaction all the time, except when you are in a write transaction :-). > So if I am doing x.first, x.second while the object is being updated in a second thread, will I get mixed state? So no you will not get mixed state. > Is database crash proof? If the phone runs out of battery while in write transaction, will the database get damaged? Yes it is crashproof. Fully ACID. Any other questions? This article goes a bit more into the details of threading: https://realm.io/news/threading-deep-dive/ https://realm.io/news/threading-deep-dive/ And this one more into the core design: https://realm.io/news/jp-simard-realm-core-database-engine/ https://realm.io/news/jp-simard-realm-core-database-engine/