Open Bug 1834046 Opened 1 years ago Updated 1 year ago

Annotate crash reports with the currently running Sqlite query

Categories

(Toolkit :: Places, task, P3)

task

Tracking

()

People

(Reporter: mak, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [sng])

This is something that may help optimizing queries and reducing shutdown crashes.
What we currently see in async shutdown crash reports is that Sqlite is busy somewhere in the btree code, but we don't know what it's doing, since most of the times it's from an asynchronous executeStep.
When we crash and one of the threads is doing Sqlite work, we could annotate the crash with the currently running SQL query (if any).
We could use sqlite3_normalized_sql() to remove any bound parameters and preserve privacy (though we may have to skip indexedb/domstorage if they may allow to somehow recognize a site, we could start with an allowlist maybe).

This means we should somewhere annotate the currently running queries.
Gabriele, is there some way to add code section specific annotations? The idea may be to annotate the running query before this loop and remove the annotation once the loop is done.
It's possible there will be multiple queries running at once, so multiple annotations of this type.

Any other alternative idea to achieve a similar result is welcome.

Flags: needinfo?(gsvelto)

not sure if it helps, but we have a profiler label there https://searchfox.org/mozilla-central/rev/7a7414158c6b073e0ba2c566a0952c711a38ae8d/storage/mozStorageConnection.cpp#1356 (that should probably use normalized_sql...)

I'm about to land a large refactoring of the crash annotations that should make implementing this easier. Right now annotations are strings that you need to set explicitly under lock, with the new system annotations can be a pointer to pretty much anything. You could realistically store a pointer to the query directly if it's a string. Processing - like stripping unwanted data - can then be done at crash time before we submit a crash.

I need to land bug 1776197 to introduce the new code (which will happen soon) and bug 1831092 to remove the messy stuff that mixes old-style with new-style annotations.

Flags: needinfo?(gsvelto)
Whiteboard: [sng]
You need to log in before you can comment on or make changes to this bug.