Docs / EventSourcingDB / Errors / last-backed-up-event-mismatched

last-backed-up-event-mismatched

The event that lastBackedUpEvent names has another hash in the database.

  • Route: create-backup
  • Description: last backed up event is mismatched: the event with its ID has another hash, so the events changed since the previous backup, or the anchor does not come unchanged from this database
  • Details: value, the hash of lastBackedUpEvent as the request gave it.

Why It Happens#

An increment of a backup follows on the event the previous backup ended at. So before it sends anything, EventSourcingDB looks up the event with the ID that lastBackedUpEvent names and compares its hash with the one the request gives. Here, the database holds an event with that ID, but with another hash, so it is not the event the previous backup ended at, and the increment would not fit onto that backup.

Events do not change once they are written, so this usually means that the request goes to another database than the one the previous backup was created from, or that the database was restored from another backup since. A hash that was changed on its way has the same effect, such as a hash of version 2 without its prefix esdb:hash:v2:. If you suspect that events were tampered with, audit the event store.

How to Fix It#

Send the id and hash exactly as the lastBackedUpEvent item of the previous backup named them, to the database that backup was created from. If the backups no longer fit the database, start anew with a full backup, with lastBackedUpEvent set to null. Resending the request unchanged fails the same way.

Example#

For an increment whose lastBackedUpEvent names the event 41 with a hash that the database does not hold for it, EventSourcingDB answers with this error, as a line of the stream, and then ends the stream with its end item:

{
  "type": "error",
  "data": {
    "code": "https://docs.eventsourcingdb.io/errors/last-backed-up-event-mismatched",
    "description": "last backed up event is mismatched: the event with its ID has another hash, so the events changed since the previous backup, or the anchor does not come unchanged from this database",
    "details": {
      "value": "esdb:hash:v2:ddbbcaefa79472f3fdb4ef45a519e73c497f5b2650bf88c03acaef9ffb6dc11a"
    }
  }
}