Database transactions
Storing data can be a complex operation internally for a database. In some cases, it can include changing the data in a single place, but there are operations that can affect millions of records in a single operation, for example, "update all records created before this timestamp."
How broad and possible these operations are highly depends on the database, but they are very similar to relational databases. In that case, normally there's the concept of a transaction.
A transaction is an operation that happens in one go. It either happens or it doesn't, but the database is not left in an inconsistent state in the middle. For example, if the operation described before of "update all records created before this timestamp" can produce an effect where, through an error, only half of the records are changed, then it's not a transaction, but multiple independent operations.
It can happen that there's an error...