This problem may be caused by the use of database transactions.
A transaction is a set of SQL operations that can be committed or rolled back together as a single unit of work. If your code uses transactions when performing SQL operations, then in some cases it may cause the behavior you describe.
When you use transactions, all SQL operations are cached until you call the commit operation to commit them to the database. If an error occurs during the execution of a transaction, you can use a rollback operation to undo all operations in the transaction. If the commit operation is not called, the transaction will automatically roll back, so all operations will be undone and the database will be restored to its original state.
Therefore, if your code uses transactions when performing SQL operations, make sure you commit the transaction promptly after performing the operation. Otherwise, you may encounter similar problems where data in the database is updated but cannot be saved.