Closed Bug 462173 Opened 16 years ago Closed 16 years ago

We treat transaction errors as fatal when we should not

Categories

(Toolkit :: Storage, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla1.9.2a1

People

(Reporter: sdwilsh, Assigned: sdwilsh)

References

Details

(Keywords: fixed1.9.1)

Attachments

(1 file, 1 obsolete file)

For the async statements (note the plural), we open a transaction, and then commit it when we are done.  However, it is possible that this returns an error, in which case we can try to handle it (if it is SQLITE_BUSY), or we should rollback.  Right now we do neither.  We'll need bug 451851 to fix this properly.

Requesting blocking because this breaks places pretty badly when it comes up.
Flags: blocking1.9.1?
Shouldn't ship async statements with a bug like this.
Flags: blocking1.9.1? → blocking1.9.1+
For reviewer reference:
http://www.sqlite.org/lang_transaction.html
Attached patch v1.0 (obsolete) — Splinter Review
Attachment #345318 - Flags: review?(bugmail)
Whiteboard: [has patch][needs review asuth]
Does this really fix places' problem?  I would expect that the places badness would be that places has an outstanding SELECT that is still active when the async thread goes to commit its transaction.  That transaction commit will fail with SQLITE_ERROR, so no retry attempt will be made and you are hosed for good unless your code starts manually trying to issue a commit/rollback on its own (without a new BEGIN).  Change mozilla's sqlite3.c:48348 to SQLITE_BUSY and these changes come into play.
So, as of right now it's safe to retry this if we get SQLITE_ERROR.  They may end up changing it so that it will return SQLITE_BUSY.  They will investigate this and change (to make sure it doesn't have implications elsewhere) and get back with us.

For now, I can change this patch to retry on SQLITE_ERROR
(In reply to comment #5)
> For now, I can change this patch to retry on SQLITE_ERROR

Change it to use the logic for rollback too, since rollback can have the same problem happen to it.
I don't think we can fix this without getting a fix for SQLite.  There is no way to know what SQLITE_ERROR is recoverable and which are not.
(In reply to comment #7)
> I don't think we can fix this without getting a fix for SQLite.  There is no
> way to know what SQLITE_ERROR is recoverable and which are not.

Well, we could have mozStorageConnection effectively maintain its own activeVdbeCnt; as statements transition to and from executing, they notify the connection.  This has the upside that instead of busy-sleep-waiting, the transaction commit could actually block on a proper notification primitive.  On the other hand, that's a lot of additional book-keeping overhead.

Is there a problem with just changing the one line I called out in mozilla's copy of sqlite until we get the official fix from sqlite command?  Granted, we are changing an error return from fatal to non-fatal, but... 1) it's still an error, 2) people could keep retrying regardless of the error code, 3) the error code was as-is is content-free and accordingly not actionable.
We have a strict policy of not making any changes to the sqlite files and only accept official copies of sqlite.  This may mean that we end up asking them for a special branch with this fix in it, but it has their qa stamp of approval then.
Whiteboard: [has patch][needs review asuth] → [needs new patch]
Attachment #345318 - Attachment is obsolete: true
Attachment #345318 - Flags: review?(bugmail)
SQLite 3.6.5 has a much better behavior - commits always succeed (they are already on disk anyway), but rollbacks may end up being busy.  We can busy wait on rollback since it's a rare condition anyway.  That change makes our lives so much easier :)
Target Milestone: mozilla1.9.1b2 → mozilla1.9.1
Attached patch v2.0Splinter Review
When we upgrade to a newer SQLite (not 3.6.5 since it crashes in FTS3), I think this is what we'll want.
Attachment #347847 - Flags: review?(bugmail)
Whiteboard: [needs new patch] → [has patch][needs review asuth]
Blocks: 460300
Depends on: 464803
Comment on attachment 347847 [details] [diff] [review]
v2.0

Yes, this all turns out much better/simpler with the new sqlite.
Attachment #347847 - Flags: review?(bugmail) → review+
Whiteboard: [has patch][needs review asuth] → [has patch][has review]
Whiteboard: [has patch][has review] → [has patch][has review][can land when m-c opens]
Per blocking rankings, this needs to be fixed by release, but doesn't need to block the proposed beta 3.
Status: NEW → ASSIGNED
Priority: -- → P2
Whiteboard: [has patch][has review][can land when m-c opens] → [has patch][has review][can land]
http://hg.mozilla.org/mozilla-central/rev/5384f38dc5e5
Status: ASSIGNED → RESOLVED
Closed: 16 years ago
Resolution: --- → FIXED
Whiteboard: [has patch][has review][can land]
Target Milestone: mozilla1.9.1 → mozilla1.9.2a1
Target Milestone: mozilla1.9.2a1 → mozilla1.9.1b3
Target Milestone: mozilla1.9.1b3 → mozilla1.9.2a1
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: