Durability: what LeonsDB guarantees

Losing or corrupting data is the worst thing a database can do. This page states exactly what LeonsDB promises, and where the limits are.

Acknowledged writes are never lost

When the LeonsDB server answers “OK” to a write, the write has been written to disk and flushed with fsync. A crash, a kill -9 or a power cut after that point cannot lose it. Every write request is applied atomically: after a crash you see either all of its operations or none of them, never part of them.

The test suite proves this on every change in two ways:

As a check on the tests themselves, turning off the fsync makes them fail immediately with lost writes.

The connector’s write buffer

To keep the Minecraft main thread fast, the connector collects changes to normal fields and sends them to LeonsDB about once per second (adjustable), as well as when a player leaves and when the server shuts down.

The trade-off: if the Minecraft server process crashes, changes made in the last moment before the crash that were not yet sent are lost. In practice that is at most about one second of stat changes. Minecraft’s own world saving has the same kind of window, which is usually much longer.

Changes that must never be lost, such as money, should be made with update(...) (and the field marked @Transactional). They skip the buffer and are confirmed by the server before they count.

A single server is not a backup

A LeonsDB server stores its data on one disk. If that disk fails, the data on it is gone. Until replication is available, use automatic backups (on the roadmap) or snapshot the data directory regularly, and keep copies on another machine.

Requirements for the guarantee