I shoot factory ammo almost all the time, which should imply a high degree of reliability. But a few months ago, at the beginning of a shotgun stage at a local 3-gun match, the very first 12-gauge birdshot round failed to fire. I racked the pump and kept going. Later we recovered the round, tried it twice more in my Mossberg and then in at least three other shotguns—nothing. We could not get this thing to fire.
It sits on my bench now as a reminder that being able to react quickly and correctly to any type of malfunction is absolutely critical for the armed citizen. When trouble comes calling, you will probably be alone, most likely within yards if not feet of the threat, and maybe without cover. So you and you alone have to save your own life.
Prevention is preferred. Make sure your firearm is properly lubricated. Dry guns have a hard time performing reliably. Next, make sure you know how to properly load it (this will eliminate a lot of failure-to-fire events). Last, make sure you know how to fix it when something goes wrong, and can do so without pausing to think about the steps.
For semi-automatic handguns or carbines, clearing a failure to fire is arguably the most common task, and "Tap, Rack, Ready" is a good way to proceed should you have an empty chamber, bad ammo or an unseated magazine. An offshoot of this procedure is "Tap, Rack, Reload." These are the steps to follow when the slide fails to lock to the rear after the last round from the magazine has been fired. Usually it's due to a bad magazine or an improper grip that unintentionally keeps the slide lock from engaging, but sometimes it just happens with no good explanation. In the Tap, Rack, Reload procedure, the shooter manually locks the slide back during the "rack" part, and then performs a reload once he/she sees the chamber is empty.
Invest in some good dummy rounds, mix them in with your live ammo next time you go to the range, and train until you can fix the problem without thinking about it.