WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
100903
IndexedDB: Move control of transaction completion to front end
https://bugs.webkit.org/show_bug.cgi?id=100903
Summary
IndexedDB: Move control of transaction completion to front end
Joshua Bell
Reported
2012-10-31 16:58:46 PDT
IndexedDB: Move control of transaction completion to front end
Attachments
Patch
(5.87 KB, patch)
2012-10-31 17:05 PDT
,
Joshua Bell
no flags
Details
Formatted Diff
Diff
Patch
(10.18 KB, patch)
2012-11-01 15:35 PDT
,
Joshua Bell
no flags
Details
Formatted Diff
Diff
Patch
(9.12 KB, patch)
2012-11-13 10:50 PST
,
Joshua Bell
no flags
Details
Formatted Diff
Diff
Patch
(9.87 KB, patch)
2012-11-13 12:20 PST
,
Joshua Bell
no flags
Details
Formatted Diff
Diff
Patch
(11.30 KB, patch)
2012-11-19 12:58 PST
,
Joshua Bell
no flags
Details
Formatted Diff
Diff
Patch
(10.21 KB, patch)
2012-11-20 15:47 PST
,
Joshua Bell
no flags
Details
Formatted Diff
Diff
Show Obsolete
(5)
View All
Add attachment
proposed patch, testcase, etc.
Joshua Bell
Comment 1
2012-10-31 17:05:16 PDT
Created
attachment 171742
[details]
Patch
Joshua Bell
Comment 2
2012-10-31 17:08:26 PDT
Incomplete (and untested). We may be able to simplify the IDBTransactionBackendImpl further: * Eliminate the dual timers - one should be enough * Eliminate the didCompleteTaskEvents message routing - the back end should no longer need to be aware of the status of the front end * Subsume
webkit.org/b/97738
and run multiple events per tick.
Joshua Bell
Comment 3
2012-11-01 14:26:00 PDT
Extra complexity: asynchronous operations that don't have associated requests - i.e. store and index creation/deletion - are invisible to the front end. The back end needs to wait for those to complete as well.
Joshua Bell
Comment 4
2012-11-01 15:35:07 PDT
Created
attachment 171945
[details]
Patch
Joshua Bell
Comment 5
2012-11-13 10:50:40 PST
Created
attachment 173928
[details]
Patch
Joshua Bell
Comment 6
2012-11-13 10:57:58 PST
Comment on
attachment 173928
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=173928&action=review
A few explanatory notes (mostly to myself)
> Source/WebCore/Modules/indexeddb/IDBRequest.cpp:542 > + if (m_transaction && m_readyState == DONE)
This is moved up so that the transaction's requestList is (possibly) empty when setActive(false) is called, so it can try and commit.
> Source/WebCore/Modules/indexeddb/IDBTransaction.cpp:99 > + , m_state(Unfinished)
The distinction between Used and Unused was only to support triggering commits from the front end for unused transactions. Now the front-end is always responsible, so we can remove the distinction.
> Source/WebCore/Modules/indexeddb/IDBTransaction.cpp:206 > + if (!active && m_requestList.isEmpty())
Here's the critical bit of the change.
> Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp:211 > + m_commitPending = true;
The front end thinks it's done...
> Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp:213 > + if (m_pendingEvents || m_pendingPreemptiveEvents || !isTaskQueueEmpty())
But the back end may be busy processing a createIndex so we need to wait.
> Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp:-208 > - ASSERT(m_state == Unused || m_state == Running);
Moved up.
> Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp:-209 > - ASSERT(isTaskQueueEmpty());
Implied by above if() test.
> Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp:276 > + if (!m_pendingEvents && !m_pendingPreemptiveEvents && isTaskQueueEmpty()) {
Possible existing bug - commit might occur if there are pending pre-emptive events.
> Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp:277 > + ASSERT(m_commitPending);
We shouldn't hit this state unless the front-end is already done.
Alec Flett
Comment 7
2012-11-13 11:07:11 PST
Comment on
attachment 173928
[details]
Patch this is awesome. lgtm with minor nits View in context:
https://bugs.webkit.org/attachment.cgi?id=173928&action=review
>> Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp:213 >> + if (m_pendingEvents || m_pendingPreemptiveEvents || !isTaskQueueEmpty()) > > But the back end may be busy processing a createIndex so we need to wait.
make this a comment - I think this check is pretty critical. (do we want to move this to a descriptive helper function?)
>> Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp:276 >> + if (!m_pendingEvents && !m_pendingPreemptiveEvents && isTaskQueueEmpty()) { > > Possible existing bug - commit might occur if there are pending pre-emptive events.
And this is just !(m_pendingEvents || m_pendingPreemptiveEvents || !isTaskQueueEmpty()) so I think a helper is justified.
Joshua Bell
Comment 8
2012-11-13 12:18:50 PST
(In reply to
comment #7
)
> > make this a comment - I think this check is pretty critical. (do we want to move this to a descriptive helper function?)
Good call. New patch coming. Another thing we could consider (for later) is to have these "sync" operations (createObjectStore, createIndex) create "hidden" IDBRequests on the front end, so the lifetime is managed by the transaction just like regular async operations.
Joshua Bell
Comment 9
2012-11-13 12:20:12 PST
Created
attachment 173955
[details]
Patch
Alec Flett
Comment 10
2012-11-13 13:31:31 PST
(In reply to
comment #8
)
> Another thing we could consider (for later) is to have these "sync" operations (createObjectStore, createIndex) create "hidden" IDBRequests on the front end, so the lifetime is managed by the transaction just like regular async operations.
+1
Joshua Bell
Comment 11
2012-11-19 12:58:31 PST
Created
attachment 175029
[details]
Patch
Joshua Bell
Comment 12
2012-11-19 12:59:48 PST
Rebased. Also merged m_active (boolean) into m_state (enum) since the latter was changing anyway. alecflett@ - another look please?
Alec Flett
Comment 13
2012-11-19 15:05:13 PST
Comment on
attachment 175029
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=175029&action=review
> Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp:51 > + , m_commitPending(false)
How does m_commitPending work with m_state? I'm concerned (more from a code maintenance perspective than a correctness perspective) that we're now doubling the possible "states" - to the combinations of m_state and m_commitPending (even if most of the "new" ones are invalid) - i.e. is m_state Finished && m_commitPending = false possible? etc...
> Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp:127 > + m_abortTaskQueue.removeFirst();
why this change?
Joshua Bell
Comment 14
2012-11-19 15:51:37 PST
Comment on
attachment 175029
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=175029&action=review
>> Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp:51 >> + , m_commitPending(false) > > How does m_commitPending work with m_state? I'm concerned (more from a code maintenance perspective than a correctness perspective) that we're now doubling the possible "states" - to the combinations of m_state and m_commitPending (even if most of the "new" ones are invalid) - i.e. is m_state Finished && m_commitPending = false possible? etc...
In theory orthogonal - can enter commitPending in parallel with Unused or Running. Logically can't enter commitPending when in StartPending because the front-end has queued tasks that haven't completed. This is covered by the ASSERT(m_state == Unused || m_state == Running) in ::commit(). Given that a commit() of an Unused transaction should be a no-op, I'll see if I can collapse it to an extra state "after" Running.
>> Source/WebCore/Modules/indexeddb/IDBTransactionBackendImpl.cpp:127 >> + m_abortTaskQueue.removeFirst(); > > why this change?
Good catch. This is a rebase glitch. I'll undo.
Joshua Bell
Comment 15
2012-11-20 15:45:30 PST
(In reply to
comment #14
)
> Given that a commit() of an Unused transaction should be a no-op, I'll see if I can collapse it to an extra state "after" Running.
Bleah, it ends up being messier since commit() can be called more than once and the "unused" state is important for sending the correct notifications. However, m_commitPending was only used for ASSERT() so I'll just remove it.
Joshua Bell
Comment 16
2012-11-20 15:47:46 PST
Created
attachment 175293
[details]
Patch
Joshua Bell
Comment 17
2012-11-20 15:50:40 PST
tony@ - r?
WebKit Review Bot
Comment 18
2012-11-20 16:35:50 PST
Comment on
attachment 175293
[details]
Patch Clearing flags on attachment: 175293 Committed
r135332
: <
http://trac.webkit.org/changeset/135332
>
WebKit Review Bot
Comment 19
2012-11-20 16:35:54 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug