Skip to content

Move to parking_lot::Mutex in logins, places and sync_manager - #4663

Merged
mhammond merged 1 commit into
mozilla:mainfrom
mhammond:parking_lot
Nov 22, 2021
Merged

mhammond merged 1 commit into
mozilla:mainfrom
mhammond:parking_lot

Conversation

@mhammond

Copy link
Copy Markdown
Member

Avoiding panics in all cases, like #4661 and #4662, is going to be whack-a-mole, and when one happens, we pollute sentry with many many Caught a panic calling rust code: "called `Result::unwrap()` on an `Err` value: PoisonError { .. }" errors.

I don't think we rely on the poisoning strategy for correctness, so we should consider moving to parking_lot.

(Not requesting review yet - I think we should discuss a little - so thoughts welcome!)

@tarikeshaq

Copy link
Copy Markdown
Contributor

I think I agree with this change, but before landing this, I wonder if we can audit our panics? Just in case there is a situation where the poisoning of the mutex is better than the alternative - I can't think of a situation right away (which I guess is a good sign for this change?) I think the only way the poisoning would be better is if there is some type of data inconsistency or vulnerability that can be exposed if something is half done in one call, then another call goes ahead

That all said, I'm thinking if we CAN audit our panics extensively then we wouldn't have ended up in the situation we are in (where poison errors keep popping up..)

This is a long way for rubberstamping on my end if we can't think of any situations where the poison is better 🤷

@lougeniaC64

Copy link
Copy Markdown
Contributor

Agree with @tarikeshaq's sentiments. Worse case scenario the poison errors are reported as elusive panics in Sentry, but at least that gets us closer to identifying what caused the invalid state and resolving the crashes. Best case the actual issues are easy to identify and resolve. Either way, nervous but r+.

@mhammond

Copy link
Copy Markdown
Member Author

I wonder if we can audit our panics?

I don't think we can in any reasonable way. Eg, the 2 issues linked above are clearly logic errors that should be impossible. We could replace those 2 instances with errors, but I don't think that solves the general whack-a-mole problem. One is an "index out of range" error - I don't think it makes sense to try and have a coding style that forbids some_vec[i] because it might panic. We also have a number of assert statements in our real code - we could remove them, but I think they have value.

IOW, the point of this patch is about making panics less damaging, making it less necessary to try and avoid panics at all costs.

that gets us closer to identifying what caused the invalid state and resolving the crashes.

Actually, I think the opposite it true - for every panic, you are likely to see that cause many poison errors - eg, once there is a single panic in logins, every single other attempt to use the logins API will cause the poison panic, which might be dozens of times before the app restarts.

The poison errors carry no information about the panic, so these errors are just noise which drown out the actual panic which set off the cascading poison errors.

@codecov-commenter

codecov-commenter commented Nov 19, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #4663 (2a12ce9) into main (249e718) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4663   +/-   ##
=======================================
  Coverage   80.55%   80.55%           
=======================================
  Files          48       48           
  Lines        5226     5226           
=======================================
  Hits         4210     4210           
  Misses       1016     1016           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 249e718...2a12ce9. Read the comment docs.

@bendk bendk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me based on the discussion we had on the call. There's a part of me that's still a bit paranoid about panics, but I can't really think of a solid case for it.

@mhammond
mhammond merged commit 2661c5d into mozilla:main Nov 22, 2021
@mhammond
mhammond deleted the parking_lot branch November 22, 2021 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

⌂ Proxy