In Psalm 59, David prays (1-2), complains (3-4), prays more (5) and then breaks into song. That is just in the first five verses. We see this repeated again as he complains (6-7), declares his confidence in God (8-10) and prays again (11-15) and ends with singing aloud God’s praises (16-17).
I love what Charles H. Spurgeon says about this verse in The Treasury of David:
The God of my mercy shall prevent me. God who is the giver and fountain of all the undeserved goodness I have received, will go before me and lead my way as I march onward. He will meet me in my time of need. Not alone shall I have to confront my foes, but he whose goodness I have long tried and proved will gently clear my way, and be my faithful protector. How frequently have we met with preventing mercy—the supply prepared before the need occurred, the refuge built before the danger arose. Far ahead into the future the foreseeing grace of heaven has projected itself, and forestalled every difficulty.