For starters, I'm not advocating tanking something on purpose or do to lack of effort. The failure we are talking about here is the kind that comes in spite of an honest preparation, effort and execution. I'll use myself as an example. The first 100 mile race I ever entered in was one of the most miserable, but in the end - best running and racing experiences I have ever had.
For the most part, I have been very successful at competitive running. When I transitioned to ultra-marathon running, this was no different - I placed 3rd in my age group in my very first race and was stoked to have done so well in such uncharted territory. Running 100 miles is THE major milestone in ultra distance events. Plain and simple - it's bad ass. Most casual people hear that distance and look at you with a stupefied look on their face - like its not possible for humans to do. I think that's kinda cool, mythical in a way and I wanted to do it.
Looking back, I was able to pull more valuable info for my future races from a seemingly negative experience than I ever have from any of my previous race successes. So next something doesn't go the way you planned, don't fret. Look back and I'm sure there will be takeaways that you can use to ensure your future success. This doesn't only apply to competitive pursuits. Use every opportunity you can to take the situations you find yourself in on a daily basis and deconstruct them. Keep what works and discard the rest. What you take away will lead you down a path of self-realization and goal reaching that you might not have thought possible.