kinto.js icon indicating copy to clipboard operation
kinto.js copied to clipboard

Perform the whole sync (pull + push) within a single transaction

Open n1k0 opened this issue 10 years ago • 6 comments

So we can abort the whole import process on error, avoiding leaving the db in an inconsistent state.

n1k0 avatar Jun 17 '15 07:06 n1k0

Not sure if this is relevant here, but just wanted to mention how important batching together writes to IndexedDB is, for performance. This is also a topic in localForage, we are trying to do automatic batching of writes there. The basic principle of that is:

  • you add or update one record -> it starts updating IndexedDB
  • you add or update more records -> it queues them up until IndexedDB is idle
  • the first transaction completes -> it creates a new batch transaction from everything that was added to the queue in the meantime

michielbdejong avatar Aug 12 '15 10:08 michielbdejong

After a quick discussion with @ametaireau, here's the current state of our thinking on this:

  • Having transactions would provide a neat way to cancel local persistence operations;
  • It would also improve performances on large batches of persistence operations;
  • localStorage adapter would need a specific manually implemented solution to cover all the use cases;
  • We should heavily challenge if we actually need this feature: for now, nobody has explicitly expressed a need for it;
  • We should also discuss this with @leplatrem which I remember was having opinions on the matter.

Thoughts?

n1k0 avatar Sep 07 '15 09:09 n1k0

#303 has now landed and is a huge step towards this goal.

n1k0 avatar Jan 28 '16 13:01 n1k0

When https://bugzilla.mozilla.org/show_bug.cgi?id=1193394 will land in Firefox, it will be possible to have IndexedDB transactions across promises in Chrome+Firefox.

leplatrem avatar Jul 05 '17 10:07 leplatrem

That's it! It landed!

Firefox 60 supports promises within IndexedDB transactions \o/

There is a lot of things that could be simplified, quite a huge amount of work.

leplatrem avatar Mar 07 '18 09:03 leplatrem

Wow! :)

michielbdejong avatar Mar 07 '18 10:03 michielbdejong