Closed Bug 1708643 Opened 4 years ago Closed 4 years ago

Add and use QM_OR_ELSE_WARN_IF/QM_OR_ELSE_NOTE_IF/QM_OR_ELSE_LOG_IF macros

Categories

(Core :: Storage: Quota Manager, task, P2)

task

Tracking

()

RESOLVED FIXED
90 Branch
Tracking Status
firefox90 --- fixed

People

(Reporter: janv, Assigned: janv)

References

Details

Attachments

(11 files, 1 obsolete file)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

In case the orElseFunc just propagates some kinds of errors, we output both a warning and then an error. This will cause a split in the stacks during processing despite the fact that errors are propagated.

The original patch for the warning macros has this comment:

// XXX In case the orElseFunc just propagates some kinds of errors, we will
// output both a warning and (then) an error. This is not too bad, but maybe
// also not the nicest thing. However, addressing this would require two steps:
// first determining whether an error of expr is going to be handled in some
// way, and then possibly passing it to that handler.

That is probably quite hard to implement, because the goal there is to report either one WARNING or one ERROR (if I understood it correctly).

However it would be quite easy to check the result of orElseFunc and either report an error or warning depending on new result produced by orElseFunc.

So, it would work like this:

  1. if there is no failure, QM_OR_ELSE just moves the success over.
  2. If there's a failure and orElseFunc returns Ok, a warning is reported and no error is reported by the enclosing QM_TRY
  3. If there's a failure and orElseFunc propagates the error, an error is reported and then another error is reported by the enclosing QM_TRY

This is still not ideal solution because instead of reporting just one WARNING or ERROR, we will report two ERRORs, but that is only a cosmetic issue (one extra ERROR event).
Actually, it quite makes sense because the error is "re-thrown" in orElseFunc

And we probably need a new name for the macro after these changes.

See Also: → 1708138

(In reply to Jan Varga [:janv] from comment #0)

However it would be quite easy to check the result of orElseFunc and either report an error or warning depending on new result produced by orElseFunc.

So, it would work like this:

  1. if there is no failure, QM_OR_ELSE just moves the success over.
  2. If there's a failure and orElseFunc returns Ok, a warning is reported and no error is reported by the enclosing QM_TRY
  3. If there's a failure and orElseFunc propagates the error, an error is reported and then another error is reported by the enclosing QM_TRY

This is still not ideal solution because instead of reporting just one WARNING or ERROR, we will report two ERRORs, but that is only a cosmetic issue (one extra ERROR event).
Actually, it quite makes sense because the error is "re-thrown" in orElseFunc

And we probably need a new name for the macro after these changes.

Checking the result of orElseFunc is not optimal either because it would cause wrong ordering of QM_TRY events.

I figured out something else. We basically need a new method Result::orElseIf and then QM_OR_ELSE_WARN_IF macro.
The idea is that orElseIf first checks if the error code should cause a fallback (using a predicate), if not, the error is just propagated.

Depends on D114846

Comment on attachment 9221510 [details]
Bug 1708643 - Add QM_OR_ELSE_LOG and QM_OR_ELSE_LOG_IF macros; r=#dom-storage

Revision D114936 was moved to bug 1701346. Setting attachment 9221510 [details] to obsolete.

Attachment #9221510 - Attachment is obsolete: true
Attachment #9221329 - Attachment description: Bug 1708643 - Use a common internal macro for definition of QM_OR_ELSE_WARN and QM_OR_ELSE_NOTE; r=#dom-storage → Bug 1708643 - Use a common internal macro for definition of QM_OR_ELSE_WARN, QM_OR_ELSE_NOTE and QM_OR_ELSE_LOG; r=#dom-storage
Attachment #9221334 - Attachment description: Bug 1708643 - Add QM_OR_ELSE_WARN_IF/QM_OR_ELSE_NOTE_IF macros; r=#dom-storage → Bug 1708643 - Add QM_OR_ELSE_WARN_IF/QM_OR_ELSE_NOTE_IF/QM_OR_ELSE_LOG_IF macros; r=#dom-storage
Attachment #9221509 - Attachment description: Bug 1708643 - Add generic predicate and fallback functions for QM_OR_ELSE_WARN_IF; r=#dom-storage → Bug 1708643 - Add generic predicate and fallback functions for QM_OR_ELSE_WARN_IF/QM_OR_ELSE_NOTE_IF/QM_OR_ELSE_LOG_IF; r=#dom-storage
Attachment #9221336 - Attachment description: Bug 1708643 - QM: Replace QM_OR_ELSE_WARN with QM_OR_ELSE_WARN_IF in places where the fallback needs to be called conditionally; r=#dom-storage → Bug 1708643 - QM: Replace QM_OR_ELSE_WARN/QM_OR_ELSE_LOG with QM_OR_ELSE_WARN_IF/QM_OR_ELSE_LOG_IF in places where the fallback needs to be called conditionally; r=#dom-storage
Summary: Improve QM_OR_ELSE_WARN → Add and use QM_OR_ELSE_WARN_IF/QM_OR_ELSE_NOTE_IF/QM_OR_ELSE_LOG_IF macros
Attachment #9221329 - Attachment description: Bug 1708643 - Use a common internal macro for definition of QM_OR_ELSE_WARN, QM_OR_ELSE_NOTE and QM_OR_ELSE_LOG; r=#dom-storage → Bug 1708643 - Use a common internal macro for definition of QM_OR_ELSE_(WARN|NOTE|LOG); r=#dom-storage
Attachment #9221477 - Attachment description: Bug 1708643 - Specify the severity in the comment for QM_OR_ELSE_WARN; r=#dom-storage → Bug 1708643 - Fix the comment for QM_OR_ELSE_WARN; r=#dom-storage
Attachment #9221509 - Attachment description: Bug 1708643 - Add generic predicate and fallback functions for QM_OR_ELSE_WARN_IF/QM_OR_ELSE_NOTE_IF/QM_OR_ELSE_LOG_IF; r=#dom-storage → Bug 1708643 - Add generic predicate and fallback functions for QM_OR_ELSE_(WARN|NOTE|LOG)_IF; r=#dom-storage
Attachment #9221336 - Attachment description: Bug 1708643 - QM: Replace QM_OR_ELSE_WARN/QM_OR_ELSE_LOG with QM_OR_ELSE_WARN_IF/QM_OR_ELSE_LOG_IF in places where the fallback needs to be called conditionally; r=#dom-storage → Bug 1708643 - QM: Replace QM_OR_ELSE_(WARN|LOG) with QM_OR_ELSE_(WARN|LOG)_IF in places where the fallback needs to be called conditionally; r=#dom-storage
Attachment #9221937 - Attachment description: Bug 1708643 - IDB: Replace QM_OR_ELSE_WARN/QM_OR_ELSE_LOG with QM_OR_ELSE_WARN_IF/QM_OR_ELSE_LOG_IF in places where the fallback needs to be called conditionally; r=#dom-storage → Bug 1708643 - IDB: Replace QM_OR_ELSE_(WARN|LOG) with QM_OR_ELSE_(WARN|LOG)_IF in places where the fallback needs to be called conditionally; r=#dom-storage
Keywords: leave-open
Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/f33d5c6ceb47 Use a common internal macro for definition of QM_OR_ELSE_(WARN|NOTE|LOG); r=dom-storage-reviewers,jstutte https://hg.mozilla.org/integration/autoland/rev/01be70418532 Rename orElseFunc argument to fallback in QM_OR_ELSE_REPORT definition; r=dom-storage-reviewers,jstutte https://hg.mozilla.org/integration/autoland/rev/16915d90a511 Fix the comment for QM_OR_ELSE_WARN; r=dom-storage-reviewers,jstutte
Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6cf5ba27193e Add QM_OR_ELSE_WARN_IF/QM_OR_ELSE_NOTE_IF/QM_OR_ELSE_LOG_IF macros; r=dom-storage-reviewers,asuth https://hg.mozilla.org/integration/autoland/rev/007ed77b9cf0 Add generic predicate and fallback functions for QM_OR_ELSE_(WARN|NOTE|LOG)_IF; r=dom-storage-reviewers,asuth
Keywords: leave-open
Pushed by jvarga@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3b6fea1b0638 QM: Replace QM_OR_ELSE_(WARN|LOG) with QM_OR_ELSE_(WARN|LOG)_IF in places where the fallback needs to be called conditionally; r=dom-storage-reviewers,asuth https://hg.mozilla.org/integration/autoland/rev/2962c68b44e5 IDB: Replace QM_OR_ELSE_(WARN|LOG) with QM_OR_ELSE_(WARN|LOG)_IF in places where the fallback needs to be called conditionally; r=dom-storage-reviewers,asuth https://hg.mozilla.org/integration/autoland/rev/a2ef523fd8b4 CACHE: Replace QM_OR_ELSE_(WARN|LOG) with QM_OR_ELSE_(WARN|LOG)_IF in places where the fallback needs to be called conditionally; r=dom-storage-reviewers,asuth https://hg.mozilla.org/integration/autoland/rev/fa200b5fb647 CACHE: Replace QM_TRY(QM_OR_ELSE_WARN(...)) with QM_WARNONLY_TRY(...) in MaybeUpdatePaddingFileInternal; r=dom-storage-reviewers,asuth https://hg.mozilla.org/integration/autoland/rev/cb1824657a65 CACHE: Replace QM_TRY(QM_OR_ELSE_WARN(...)) with QM_TRY and a cleanup function in CreateOrMigrateSchema; r=dom-storage-reviewers,asuth https://hg.mozilla.org/integration/autoland/rev/8ac77d476c0e LS: Replace QM_OR_ELSE_(WARN|LOG) with QM_OR_ELSE_(WARN|LOG)_IF in places where the fallback needs to be called conditionally; r=dom-storage-reviewers,asuth
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: