A Mary Sue can still fail, they just usually succeed. The biggest issues with a Mary Sue aren’t their success, its the believability of their success. Is it reasonable for this person to be so skilled. If they have PHD level knowledge in 15 different fields, that’s a bit much. But they may have PHD level knowledge in 1 or 2 fields, and they may be able to get through like that without coming off as a Mary Sue, look at The Martian by Andy Weir (or the movie with Matt Damon) The premise of sending people with 2 PHDs in complementary fields to reduce the number of people needing to be sent makes logical sense, so him being an expert, and also being the right kind of expert, to survive makes sense. And the fact he isn’t an expert in everything else helped drive the narrative and provided the direction and the plot in a reasonable and believable way.
I think that’s what is important, not making your character flawless, or even introducing some flaws to a flawless character, because that still ends up coming off weird, but instead start with a flawed character and then remove flaws until you have just enough to make everything the character needs to survive believable. Another view of this, Die Hard, John McClaine wasn’t the typical Mary Sue, he wasn’t perfect and the audience feels like he’s constantly in danger and just a mixture of skill and luck gets him through it. A flawed character is more impactful to the reader. I am a flawed person, I relate better to flawed people.
You joke, but Trevor Noah ate a whole bag of biltong (South African jerky) in front of customs because customs would not let him into the country with it.