This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 11396 - Add a callback to IDBDatabaseSync.transaction
Summary: Add a callback to IDBDatabaseSync.transaction
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: Indexed Database API (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-24 06:21 UTC by Pablo Castro
Modified: 2011-03-08 03:42 UTC (History)
3 users (show)

See Also:


Attachments

Description Pablo Castro 2010-11-24 06:21:29 UTC
In the TPAC folks proposed to tweak the sync API such that it prevents code patterns that cause deadlocks at the start of a transaction.

We ended up with a proposal where we'd add a callback to IDBDatabaseSync.transaction, and work in that transaction can only happen within the callback.

The change would be:
- add a callback argument to IDBDatabaseSync.transaction(), the callback will receive one argument that's the transaction object
- once the callback returns, the transaction is committed
- if an exception is thrown and not caught inside the callback then the transaction must be aborted
- make the method void, no transaction object is returned
- a call to transaction() from within a transaction callback or an async API callback that involves a transaction will fail with NOT_ALLOWED_ERR.
Comment 1 Jeremy Orlow 2010-11-24 10:48:38 UTC
It's worth making clear that the callback will be called synchronously.  (i.e. no code after the transaction call will execute until after the callback executes (if it'll ever execute).  The callback is just to make the scope of the transaction more explicit.