ONLYOFFICE / DocumentServer

ONLYOFFICE Docs is a free collaborative online office suite comprising viewers and editors for texts, spreadsheets and presentations, forms and PDF, fully compatible with Office Open XML formats: .docx, .xlsx, .pptx and enabling collaborative editing in real time.
https://www.onlyoffice.com
GNU Affero General Public License v3.0
4.71k stars 1.07k forks source link

Keep Database after restart #2787

Open MarcelCoding opened 1 month ago

MarcelCoding commented 1 month ago

This issue is unique.

Your idea.

If nextcloud is down, or the changes can otherwise not be saved back to nextcloud (e.g. because of https://github.com/ONLYOFFICE/onlyoffice-nextcloud/issues/931), the onlyoffice database contains all the user data and should absolutely not be dropped on startup! ~ https://github.com/NixOS/nixpkgs/pull/319858#issue-2353763414

Not to drop the database is currently not possible:

The only problem I could think of is the absence of database migrations because upstream is dropping everything on startup. ~ https://github.com/NixOS/nixpkgs/pull/319858#issuecomment-2180566587

I've also noticed that OnlyOffice displays in the bottom corner that all changes are saved. image

The actual error when saving changes back to OnlyOffice only occurs when using the save button in the menu. image

It would be nice, that the user would be informed instantly if there are errors writing to the underlying storage provider. (e.g. Nextcloud)

igwyd commented 1 month ago

Hello @MarcelCoding, I think you need an forcesave option, in Nextcloud it's named "Keep intermediate version when editing (forcesave)". This changes the behavior of the "save" button: if Nextcloud is down and you will press "save" then you will get message "An error occured while saving the file...".

MarcelCoding commented 1 month ago

Cool, that would be a solution. But I think the database should not be dropped anyways. A user and an admin is not the same person and maybe to resolve the problem (why files cannot be saved) a restart is necessary. Therefore the data should be kept only when restarting onlyoffice.

MarcelCoding commented 1 month ago

Maybe the default should be changed in nextcloud or at least the wording with the explicit explanation that this can happen if you don't enable the option.

igwyd commented 1 month ago

Maybe the default should be changed in nextcloud or at least the wording with the explicit explanation that this can happen if you don't enable the option.

We have it in the connector documentation.

Cool, that would be a solution. But I think the database should not be dropped anyways. A user and an admin is not the same person and maybe to resolve the problem (why files cannot be saved) a restart is necessary. Therefore the data should be kept only when restarting onlyoffice.

Changes are deleted from the database after they are sent to the document server cache, for example, this will happen if the editor receives the status of a closed document and this is regardless of the availability of the storage. And then this cache will wait until the storage is turned on and the first user who called the document will receive changes from the cache.

MarcelCoding commented 1 month ago

Changes are deleted from the database after they are sent to the document server cache, for example, this will happen if the editor receives the status of a closed document and this is regardless of the availability of the storage. And then this cache will wait until the storage is turned on and the first user who called the document will receive changes from the cache

That's interesting because the time I encountered data loss I've looked into all directories and there weren't an files. Because there was a restart in between the data was deleted from the database and I was able to recover the data from database backups. Now the question is, why wasn't the data written to the files? I should have not been able to recover the data from the database days after is was written to the database ? https://github.com/ONLYOFFICE/Docker-DocumentServer/blob/0d5588d03a7672b8274e93d9151f9449f3dd499c/run-document-server.sh#L490 And because of that the cache is cleared all the time onlyoffice restarts, even if the data is not already written to the storage...

MarcelCoding commented 1 month ago

https://github.com/ONLYOFFICE/onlyoffice-nextcloud/issues/931#issuecomment-2061870498 is probably the reason files count not be moved from the database to the cache. But the data should not be automatically cleared from the database if the creation of the cache failed.

igwyd commented 1 month ago

That's interesting because the time I encountered data loss I've looked into all directories and there weren't an files. Because there was a restart in between the data was deleted from the database and I was able to recover the data from database backups. Now the question is, why wasn't the data written to the files? I should have not been able to recover the data from the database days after is was written to the database ? https://github.com/ONLYOFFICE/Docker-DocumentServer/blob/0d5588d03a7672b8274e93d9151f9449f3dd499c/run-document-server.sh#L490 And because of that the cache is cleared all the time onlyoffice restarts, even if the data is not already written to the storage...

When the container is restarted, it starts documentserver-prepare4shutdown.sh, that forcibly disconnects all users from documents and sends all changes from the database to the cache and then to the storage (nextcloud in your case). This is done to avoid data loss when stopping or restarting the container.

The entire cache /var/lib/onlyoffice/documentserver/App_Data/cache/files/ will be deleted when the container is restarted, you need to mount it like here to avoid this.

igwyd commented 1 month ago

But the data should not be automatically cleared from the database if the creation of the cache failed.

Agree, could you please describe the case of data loss in more detail so that I can repeat it?

MarcelCoding commented 1 month ago

The cache could probably not be created, because x2t failed: https://github.com/ONLYOFFICE/onlyoffice-nextcloud/issues/931 (https://github.com/ONLYOFFICE/onlyoffice-nextcloud/issues/931#issuecomment-2096548861)

(x2t is only failing for some document formats, not all)