The covenant with David would not be broken, even though David's sons would be punished for their sins.
psalm 89 applies the covenant god made with david to situations his descendants faced throughout their generations.