Have a way to specifically report warnings around QM_TRY
Categories
(Core :: Storage: Quota Manager, task)
Tracking
()
People
(Reporter: sg, Assigned: janv)
References
Details
Attachments
(5 files, 7 obsolete files)
Currently, the QM_TRY mechanism doesn't allow to distinguish between errors that cause the failure of some operation and warnings for non-standards situations that can be mitigated without failing the overall operation. The choice in the latter case is currently between not using QM_TRY (and, in particular, having no telemetry report) or reporting it like an error. While it's possible to identify these from the telemetry reports, it requires additional work for each analyzed build. It would be better to allow distinguishing this in the first place, ideally in a way that expresses the intent in code and allows to remove additional comments.
Reporter | ||
Comment 1•4 years ago
|
||
Assignee | ||
Comment 2•4 years ago
|
||
(In reply to Simon Giesecke [:sg] [he/him] from comment #1)
This could be used, e.g. at https://searchfox.org/mozilla-central/rev/31ddf859c57e812878a5f817e4097efb06de4d97/dom/quota/ActorsParent.cpp#9743
Yes, and also here: https://phabricator.services.mozilla.com/D98076#inline-569530 (not critical though).
Reporter | ||
Comment 3•4 years ago
|
||
One way to address this might seem to change the implementation of the existing QM_TRY macros to automatically detect cases where an error is not propagated, because a custom result is provided that is not an error (not GenericErrorResult<T>
and not a non-NS_OK
nsresult
), but this seems to be too smart. It is also not sufficient alone, since it wouldn't cover uses of Result::orElse
, which consume an error result.
Possible approaches to this include:
- Add a function to explicitly add a warning, and have the implementation of that function emit that as a dom.quota.try telemetry event
- Add *_WARN variants of QM_TRY that don't propagate the error, and doesn't simply use a custom return value, but accepts a functor like the one that can be passed to
Result::orElse
. This would allow to cover most of the existing uses; it would make the syntax for the simple case where a custom non-error return value was provided a bit more verbose (e.g.QM_TRY_WARN(OkIf(originProps.mType != OriginProps::eInvalid), [](const nsresult) { return mozilla::Ok{}; ))
).
While the first approach doesn't require the introduction of new macro variants, it will lead to a less uniform handling and miss the self-documenting property of the second approach. While this might be added additionally for very special situations, implementing the second approach might actually be sufficient, and could replace all NS_WARNING
s with custom messages.
Reporter | ||
Comment 4•4 years ago
|
||
The module argument in LogError is redundant: the module information can
already be determined from the source file path. Indeed, reporting the module
separately in the telemetry events seems unnecessary. Instead, the relative
path is now reported. This is what the analysis of the telemetry data did
reconstruct anyway.
As a consequence, it's no longer necessary to define module-specific
HandleError functions, and therefore it's also unnecessary to define
module-specific TRY macros. These are retained as simple aliases for now,
but can be removed in a later patch entirely.
This also avoids misuses of a TRY macros in the wrong module, which were
happening a few times before, resulting in confusing output or telemetry
events.
Since Bug 1686191 will add some more TRY macro variants that warn, so
simplifying the module-specific aspects will simplify that task. Furthermore,
this is in preparation of moving the TRY macro extensions to MFBT.
Updated•4 years ago
|
Reporter | ||
Comment 5•4 years ago
|
||
Depends on D102767
Reporter | ||
Comment 6•4 years ago
|
||
Depends on D102768
Reporter | ||
Comment 7•4 years ago
|
||
Depends on D102769
Reporter | ||
Comment 8•4 years ago
|
||
Depends on D102770
Reporter | ||
Comment 9•4 years ago
|
||
Depends on D102771
Updated•4 years ago
|
Reporter | ||
Comment 10•4 years ago
|
||
Depends on D102772
Reporter | ||
Comment 11•4 years ago
|
||
Depends on D102945
Reporter | ||
Comment 12•4 years ago
|
||
Depends on D103031
Reporter | ||
Comment 13•4 years ago
|
||
Depends on D103166
Reporter | ||
Updated•4 years ago
|
Comment 14•4 years ago
|
||
Comment 15•4 years ago
|
||
bugherder |
Assignee | ||
Comment 16•4 years ago
|
||
I've been thinking about this lately, but I need to do a bit more investigation.
So far, it looks like these patches don't require a lot of discussion:
https://phabricator.services.mozilla.com/D102767
https://phabricator.services.mozilla.com/D102770
https://phabricator.services.mozilla.com/D102772
https://phabricator.services.mozilla.com/D102945
I'll try to put my investigation into a comment here. Then we can go through all the patches.
Assignee | ||
Comment 17•4 years ago
|
||
This is a WIP patch which can be used as a base for a broader discussion about
the support for warnings in QM_TRY telemetry.
Assignee | ||
Comment 18•4 years ago
•
|
||
(In reply to Simon Giesecke [:sg] [he/him] from comment #0)
Currently, the QM_TRY mechanism doesn't allow to distinguish between errors that cause the failure of some operation and warnings for non-standards situations that can be mitigated without failing the overall operation. The choice in the latter case is currently between not using QM_TRY (and, in particular, having no telemetry report) or reporting it like an error. While it's possible to identify these from the telemetry reports, it requires additional work for each analyzed build. It would be better to allow distinguishing this in the first place, ideally in a way that expresses the intent in code and allows to remove additional comments.
I collected a list of areas which need to be addressed:
-
Conversion of existing (not necessarily all) NS_WARNING/QM_WARNING
Currently,QM_TRY
can only report errors, and in case of an error, it alwaysreturn
from a function.
Example: https://searchfox.org/mozilla-central/rev/87a8afd9f57ee4bc542ba0ec3f96a891042b6db7/dom/cache/CacheParent.cpp#60 -
Missing warnings in cases when a specific errors is converted to a success
This is not directly aboutQM_TRY
, but rather about having a way to issue a warning which is reported to telemetry too.
Example: https://searchfox.org/mozilla-central/rev/87a8afd9f57ee4bc542ba0ec3f96a891042b6db7/dom/cache/QuotaClientImpl.h#99
Another problem is that passing a generic (template) function toorElse
makes it impossible to report concrete line in the source.
Example: https://searchfox.org/mozilla-central/rev/87a8afd9f57ee4bc542ba0ec3f96a891042b6db7/dom/indexedDB/ActorsParent.cpp#671 -
Having no way to report harmless errors (like syntax errors)
Example: https://searchfox.org/mozilla-central/rev/87a8afd9f57ee4bc542ba0ec3f96a891042b6db7/dom/indexedDB/IDBDatabase.cpp#372 -
Errors which don't cause overall failures and which should be reported as warnings only
Example: https://searchfox.org/mozilla-central/rev/87a8afd9f57ee4bc542ba0ec3f96a891042b6db7/dom/indexedDB/ActorsParent.cpp#7683 -
Special NS_ERROR_ABORT error which is used to cancel operations for example during shutdown and which propagates through multiple functions
Example: https://searchfox.org/mozilla-central/rev/87a8afd9f57ee4bc542ba0ec3f96a891042b6db7/dom/indexedDB/ActorsParent.cpp#13745
which is called from: https://searchfox.org/mozilla-central/rev/87a8afd9f57ee4bc542ba0ec3f96a891042b6db7/dom/indexedDB/ActorsParent.cpp#13862
I think there are actually two things which QM_TRY
currently lacks:
- Log severity
- Custom control flow (including no flow control)
Assignee | ||
Comment 19•4 years ago
|
||
(In reply to Jan Varga [:janv] from comment #18)
I think there are actually two things which
QM_TRY
currently lacks:
- Log severity
- Custom control flow (including no flow control)
Custom control flow has been rejected at the meeting, TRY
implies return
if there's an error and having an argument for custom flow control could be confusing and easily overlooked, example:
QM_WARNING_TRY(OkIf(Send__delete__(this)), QM_NO_CTRL);
Comment 20•4 years ago
|
||
Updated•4 years ago
|
Comment 21•4 years ago
|
||
Comment 22•4 years ago
|
||
bugherder |
Assignee | ||
Comment 23•4 years ago
|
||
The new macros are also used in several places.
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Reporter | ||
Updated•4 years ago
|
Reporter | ||
Comment 24•4 years ago
|
||
Re-assigning the bug to jan, as the remaining patch is owned by him. The patches already landed on this bug are not solving the core problem, but are preparations for that.
Updated•4 years ago
|
Comment 25•4 years ago
|
||
Comment 26•4 years ago
|
||
Backed out for causing bustages on QuotaCommon.h.
Backout link: https://hg.mozilla.org/integration/autoland/rev/aa879295448fb1614a7549d7c0a96361c12417ea
Failure log: https://treeherder.mozilla.org/logviewer?job_id=334243479&repo=autoland&lineNumber=8681
Comment 27•4 years ago
|
||
Comment 28•4 years ago
|
||
bugherder |
Assignee | ||
Comment 29•3 years ago
|
||
This has been fixed.
Description
•