Docs / EventSourcingDB / Errors / backup-ahead-of-clock

backup-ahead-of-clock

An event of the backup lies more than an hour beyond the clock of the server.

  • Route: restore-backup
  • Description: backup is ahead of the clock: the event in line <line> is dated <time>, more than an hour beyond the clock of the server; restore it once the clock has caught up
  • Details: line, the number of the line in the request body that holds the event, counting from 1, heartbeats included, and value, the time of the event as the backup holds it.

Why It Happens#

The time of an event is never earlier than the time of the event before it, so while the clock of the server is behind the latest event, every new event takes the time of the latest event, see Watching the Clock. A restored event dated far in the future, such as 9999-12-31, would give its time to every event written after the restore, until the clock had caught up with it. So a restore checks every event of the backup against the clock of the server as it reads the event, and refuses one that lies more than an hour beyond it.

An hour covers the difference between the clocks of two servers, so a backup from a server whose clock ran slightly ahead still restores, and new events take the time of its latest event until the clock has caught up. A restore that fails this way removes what it has restored so far, so the database is empty again, see When a Restore Fails.

How to Fix It#

Check the clock of the server and the time that value names. If the clock is behind, correct it, and restore the backup again. Otherwise, restore the same backup once the clock has caught up, as the description says; until then, resending the request fails the same way.

Example#

For a restore whose fifth line holds an event dated 9999-12-31T23:59:59.999999999Z, 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/backup-ahead-of-clock",
    "description": "backup is ahead of the clock: the event in line 5 is dated 9999-12-31T23:59:59.999999999Z, more than an hour beyond the clock of the server; restore it once the clock has caught up",
    "details": {
      "line": 5,
      "value": "9999-12-31T23:59:59.999999999Z"
    }
  }
}