database recovering

Asked by Michael Nesterenko

I wonder what about persistence database integrity and recovering process after crashes? How seriously mosquito treat client subscriptions, messages etc? Will I lose that information if crash happens before autosave_interval triggers flush to disk?

Are there pluggable database api so it will be possible to use custom database for persistence.

How backup process can be organized? Is it possible just copy database file while mosquito server is working?

Thank you in advance.

Question information

Language:
English Edit question
Status:
Answered
For:
mosquitto Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Roger Light (roger.light) said :
#1

All information for durable clients (clean session=false) is saved in the persistence database. Nothing is saved for non durable clients. If the broker crashes or power is lost then when the broker restarts you will have information from the last time the file was saved, nothing more.

There is currently no way to use a custom database for persistence, but a pluggable api is planned for the future.

The persistence file is only open during writing, so it's safe to copy between writes.

Revision history for this message
Michael Nesterenko (misha-nesterenko) said :
#2

How efficient is writing? Does it write whole database or just some delta? For example I put autosave_interval to 1 sec will disk system suffer when database size grows?

> The persistence file is only open during writing, so it's safe to copy between writes.
Is is allowed to open file for reading when write process is going? If so how can I check if it is safe to copy database?

Revision history for this message
Michael Nesterenko (misha-nesterenko) said :
#3

Forgot to ask, what if crash happens when database is flushed to disk? Will it be corrupted?

Revision history for this message
Roger Light (roger.light) said :
#4

It writes the whole database in one go, there are no deltas. You may wish to consider using the "uautosave_on_changes" option, which changes autosave_interval from a time based measurement to one that counts the number of relevant changes (subscriptions, retained messages, queued messages) before writing to disk.

If there is a crash part way through the disk write, the file will be corrupted. Thanks for the reminder, I've been meaning to fix this for ages.

Can you help with this problem?

Provide an answer of your own, or ask Michael Nesterenko for more information if necessary.

To post a message you must log in.