Recently I'd started working on a project with a leading expert in the relevant field where the result we'd worked on turned out to be already in the literature unbeknownst to either of us. So this can happen even to leading experts. (Our method of proof was slightly different, but that part of the project instead of being a new result just becomes the pushout of a known result with a known technique proving a similar result, and so not really worth publishing. (Though it was still a project where I learned valuable things!) Fortunately we hadn't actually started writing.)
So how did we figure out that this result was in the literature? One day I decided to read the mathscinet reviews of every paper with primary subject classification 46L37. The reason I did this was actually to try to learn where subfactor papers were published, but a nice side affect was that I learned about this prior excellent work so we didn't put in a bunch of effort only to discover that someone else had done it several years ago!
I highly highly recommend at least skimming through the mathscinet listings of subject classifications that you tend to publish in. It really gives a nice birds eye view of the field (albeit a couple years out of date). (Of course, this is easier to do in fields that have only existed for 30 years.)