nextcloud / documentserver_community

Document server for onlyoffice
https://apps.nextcloud.com/apps/documentserver_community
131 stars 29 forks source link

File changes are shown in OnlyOffice but don't appear in Files app #12

Open rnwgnr opened 4 years ago

rnwgnr commented 4 years ago

How to use GitHub

Steps to reproduce

Nextcloud: 18.0.0 (happens with SQLite and MariaDB Backend) , internal store only. DocumentServer_Communtiy version: 0.1.1 Still happens 18.0.3 and Document Server 0.1.5

Whenever editing a file in OnlyOffice, the changes are not reflected in the "Files" app:

Nevertheless when opening the file again in OnlyOffice, the changes are there.

I guess OnlyOffice caches the document internally and the changes are not copied back to the users storage folder.

rnwgnr commented 4 years ago

It seems that this will be no issue in the future anymore: https://help.nextcloud.com/t/onlyoffice-removed-web-mobile-editing-from-version-5-5-0-of-community-document-server/74360

I wasn't aware of this change 'til now. Seems my "best practice" to stick with simple text/markdown files whereever possible is still the way to go.

I stepped back from using OnlyOffice, so this issue is "solved" for me now.

biva commented 4 years ago

It seems that this will be no issue in the future anymore:

AFAI, it's about the mobile editing, edit a document online in a desktop browser is still possible, isnt' it? (https://www.onlyoffice.com/compare-server-editions.aspx)

szaimen commented 4 years ago

AFAI, it's about the mobile editing, edit a document online in a desktop browser is still possible, isnt' it? (https://www.onlyoffice.com/compare-server-editions.aspx)

Yes, thats also how I understood it. I reopen the issue because the issue still isn't solved yet. Please note: I am not related to the Nextcloud GmbH.

rnwgnr commented 4 years ago

I don't care anymore. :)

bunjes commented 4 years ago

no, for us it was a general problem, not only for mobile editing

biva commented 4 years ago

@jospoortvliet Unless I missed it, we don't see any nextcloud dev here. I guess you have more important priorities at Nextcloud (and I respect that). But could you just tell us if you have seen this issue, and what's your plan about that? Thanks a lot in advance!

The issue on ONLYOFFICE github was closed, the dev there say it's a Nextcloud issue (https://github.com/ONLYOFFICE/onlyoffice-nextcloud/issues/21#issuecomment-607822941)

I have some questions to make it work better for me.

  1. It was mentioned in https://github.com/ONLYOFFICE/onlyoffice-nextcloud/issues/21#issuecomment-568745636 that

    "There is one more option for now except force saving - it is "sessionidle": parameter in default.json config of the Document Server that is responsible for closing editing sessions due to users' inactivity. Its value can be set, for example, in the following way: "1h" or "1d" or "50m" etc.".

Apparently (thanks @szaimen in https://github.com/ONLYOFFICE/onlyoffice-nextcloud/issues/21#issuecomment-607820917), this file is removed during the build process. Where should I find default.json or another config file to reduce the inactivity time with sessionidle parameter? I'm using the Community Document Server App and the OnlyOffice App on Nextcloud and there's nothing under /etc/

  1. @googol42 I'd like to add the cronjob that you mention in https://github.com/nextcloud/documentserver_community/issues/12#issuecomment-583101254 But I'm not sure to understand. In which file to you add this line? Your main cron file? The nextcloud cron file?

Thanks for your support!

mvv588 commented 4 years ago

Got an answer from NC on twitter:

https://twitter.com/Nextclouders/status/1245591177753006081

'fraid not, the OO team will have to add a save function #Nextcloud can call using the close button we added.

tjareson commented 4 years ago
  1. @googol42 I'd like to add the cronjob that you mention in #12 (comment) But I'm not sure to understand. In which file to you add this line? Your main cron file? The nextcloud cron file?

I've adjusted googol42's suggestion to run it in the crontab of the docker host: * * * * * root /usr/bin/docker exec -t containername sudo -u www-data php occ documentserver:flush
But if there is an option that more than one user is working on a file at the same time, I strongly disadvice this workaround. More than one user could by the way also be the case if you open and close with the same user in a short time. It shows then a second/third user which is yourself from the editing before. In my case I ended sometimes with the situation that only the changes were left in the saved file. It was weird.

RNCTX commented 4 years ago

Got an answer from NC on twitter:

https://twitter.com/Nextclouders/status/1245591177753006081

'fraid not, the OO team will have to add a save function #Nextcloud can call using the close button we added.

So the short answer is they had time to remove features to try and drive sales with artificial scarcity but don't have time for QA and integration testing.

Which means the solution is to use anything but this software.

stweil commented 4 years ago

@LukasReschke, I suggest to stop publishing OnlyOffice as a Nextcloud app, because it is unusable as long as the changes done with it are not written back to the Nextcloud filesystem.

I think this is urgent because I consider the damage resulting from this issue for the reputation of Nextcloud is very high.

stweil commented 4 years ago

@jospoortvliet, I saw your comment on Twitter and also the comment from OnlyOffice. Currently nobody seems to be able to address and fix this severe problem. That's why I suggest to stop propagating the OnlyOffice Community Document Server App for Nextcloud and warn users that they should not use it until the issue is solved.

RNCTX commented 4 years ago

It really baffles me that there was this big presentation of new integration and ease of deployment with OO and no one bothered to actually verify that the most basic core functionality required of a collaborative tool (the ability for different users to save different revisions) was present and working.

stweil commented 4 years ago

@RNCTX, such things happen. Now it's time to avoid that more people get annoyed by this misfunction. Then fixing it and learning from this experience comes next.

stweil commented 4 years ago

Flushing the document cache does not work for me:

# sudo -u www-data php /var/www/nextcloud/occ documentserver:flush
An unhandled exception has been thrown:
Error: Call to a member function getUID() on null in /var/www/nextcloud/lib/private/Files/View.php:1690
kesselb commented 4 years ago
Index: lib/Document/ChangeStore.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- lib/Document/ChangeStore.php    (revision d6a76d2ceae02f3c2cee087971147ee14e4ba0ef)
+++ lib/Document/ChangeStore.php    (date 1586105831578)
@@ -76,6 +76,17 @@
        return ($index === false) ? -1 : (int)$index;
    }

+   public function getMaxTimeForDocument(int $documentId): int {
+       $query = $this->connection->getQueryBuilder();
+
+       $query->select($query->func()->max('time'))
+           ->from('documentserver_changes')
+           ->where($query->expr()->eq('document_id', $query->createNamedParameter($documentId, \PDO::PARAM_INT)));
+       $time = $query->execute()->fetchColumn();
+
+       return ($time === false) ? 0 : (int)$time;
+   }
+
    public function getChangesForDocument(int $documentId): array {
        $query = $this->connection->getQueryBuilder();

Index: lib/BackgroundJob/Cleanup.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- lib/BackgroundJob/Cleanup.php   (revision d6a76d2ceae02f3c2cee087971147ee14e4ba0ef)
+++ lib/BackgroundJob/Cleanup.php   (date 1586105987629)
@@ -22,6 +22,7 @@
 namespace OCA\DocumentServer\BackgroundJob;

 use OCA\DocumentServer\Channel\SessionManager;
+use OCA\DocumentServer\Document\ChangeStore;
 use OCA\DocumentServer\Document\DocumentStore;
 use OCA\DocumentServer\Document\LockStore;
 use OCA\DocumentServer\Document\SaveHandler;
@@ -33,6 +34,7 @@
 class Cleanup extends Job {
    private $sessionManager;
    private $documentStore;
+   private $changeStore;
    private $saveHandler;
    private $lockStore;
    private $databaseIPCBackend;
@@ -42,6 +44,7 @@
        ITimeFactory $time,
        SessionManager $sessionManager,
        DocumentStore $documentStore,
+       ChangeStore $changeStore,
        SaveHandler $saveHandler,
        LockStore $lockStore,
        DatabaseIPCBackend $databaseIPCBackend,
@@ -51,6 +54,7 @@

        $this->sessionManager = $sessionManager;
        $this->documentStore = $documentStore;
+       $this->changeStore = $changeStore;
        $this->saveHandler = $saveHandler;
        $this->lockStore = $lockStore;
        $this->databaseIPCBackend = $databaseIPCBackend;
@@ -63,8 +67,11 @@
        $this->sessionManager->cleanSessions();

        $documents = $this->documentStore->getOpenDocuments();
+       $time = $this->time->getTime();
+
        foreach ($documents as $documentId) {
-           if (!$this->sessionManager->isDocumentActive($documentId)) {
+           $noChangesWithinTwoMinutes = ($time - $this->changeStore->getMaxTimeForDocument($documentId)) > 120;
+           if ($noChangesWithinTwoMinutes || !$this->sessionManager->isDocumentActive($documentId)) {
                try {
                    $this->saveHandler->flushChanges($documentId);
                } catch (\Exception $e) {

I patched my instance to write back changes to Nextcloud if there are no changes within the last two minutes (or like before if there are no more active sessions). That will probably create more versions of a file then before.

szaimen commented 4 years ago

I patched my instance to write back changes to Nextcloud if there are no changes within the last two minutes (or like before if there are no more active sessions). That will probably create more versions of a file then before.

I think that makes much more sense then always waiting for the last one to close the file. 👍

@kesselb Thank you for the patch! Is this something you could make available for everyone with a PR?

nursoda commented 4 years ago

Wait, I'm OK with intermediate saves, but my issue was that the close event does NOT lead to a save. After closing, I should not have to wait 2 minutes until the files app sees the changes IF I regularly close the onlyoffice app!

szaimen commented 4 years ago

Wait, I'm OK with intermediate saves, but my issue was that the close event does NOT lead to a save. After closing, I should not have to wait 2 minutes until the files app sees the changes IF I regularly close the onlyoffice app!

I think this has to get implemented by the onlyoffice app for nextcloud and is not doable by the documentserver_community allone as they said on twitter recently...

kesselb commented 4 years ago

not have to wait 2 minutes until the files app sees the changes

That also depends on the cron. It's at least 2 minutes.

IF I regularly close the onlyoffice app!

image

https://github.com/ONLYOFFICE/onlyoffice-nextcloud/blob/f9e427ea53866568271a950c27343ca0ebee8aae/js/main.js#L145-L158

The button belongs to onlyoffice-nextcloud app. I don't see any callback on editor close. Not sure how the onlyoffice documentserver detects a editor close event.

Is this something you could make available for everyone with a PR?

I have no plans to do that. It does work for me but I'm not using onlyoffice on a daily base. There might be other disadvantages by this approach.

szaimen commented 4 years ago

There might be other disadvantages by this approach.

I've thought about this a bit more and I think this might be because of the sync process in mind: if it would save every time a user is closing a document or every 2min after no changes to the file have happend, then it would sync the changes every time to the end devices which would use a lot of processing power of the server (when a lot of users have opened that file).

Having this in mind, I think the best time to save the file is when the last one clicks on "close the file". Although the app should preserve the current background job (so that the file gets definitely saved back to the files app because it could happen that e.g. the last user isn't clicking on that button)...

Additionally I could imagine the shortcut "CTRL+S" to force syncing back all changes.

But maybe the best way to fit for all usecases would be if the time/algorithm when to sync was configurable by the admin to configure it depending on the usecase?

box18box commented 4 years ago

I have the save problem in the last Nextcloud 18.

biva commented 4 years ago

Agree with @szaimen. I would also add a saving when anybody clicks "save". Like in by desktop application, the sync is done every time a user saves a new version of any file. It would also improve the accuracy and the number of versions

szaimen commented 4 years ago

Agree with @szaimen. I would also add a saving when anybody clicks "save". Like in by desktop application, the sync is done every time a user saves a new version of any file. It would also improve the accuracy and the number of versions

@biva I think you haven't read my comment completely. I would actually vote for saving the changes back to the storage only if the last one closes the file. (or via the current background job) Also as I said above, I definitely could imagine a force save with the shortcut "CTRL+S".

szaimen commented 4 years ago

ref: https://github.com/ONLYOFFICE/onlyoffice-nextcloud/issues/257

box18box commented 4 years ago

In my case is the same probeme if a stop auto-saving.

jinhucheung commented 4 years ago

+1

jcgerhard commented 4 years ago

I have the same issue as everybody here. No matter what I'll setup (auto-save on/off, using different browsers, open file in new tab, and so on..) the documents' changes won't get written back to the file in Nextcloud.

The only (manual) reliable workaround for me is to call occ with "documentserver:flush".

The integration of OnlyOffice into Nextcloud Hub is a great thing and both applications are very great. But this unreliable and inscrutable save mechanism is an absolute show-stopper. In my case it prevents my company to switch from google to the Nextcloud platform.

It would be damn nice if this could be fixed as soon as possible. The changes should be flushed from the database every time the file will be saved.

szaimen commented 4 years ago

FYI: https://github.com/nextcloud/documentserver_community/issues/100#issuecomment-610453575

ogmkp commented 4 years ago

FYI (i'm a private user): https://github.com/nextcloud/documentserver_community/issues/103#issuecomment-612260830

rlKoekie commented 4 years ago

So I've also been doing some experimenting with this. I've tried the patch from https://github.com/nextcloud/documentserver_community/issues/12#issuecomment-609448775 , but this seemed to make little difference. I did leave it in place however. A work-around for me was to set up a cronjob that both flushes the documentserver, and then does a generic cron: * * * * * bash -l -c 'php -f /var/www/nextcloud/occ documentserver:flush; php -f /var/www/nextcloud/cron.php' (keep in mind that this needs to run as the www-data user, or whatever user is running your nextcloud instance) This probably creates a very large number of file versions, and is probably not at all failproof. I'm a nextcloud newbie, so I have no idea if there are major drawbacks to calling cron.php so often :-)

---- edit 1 month later ---- The manual flush with a forced cron afterwards did not solve all issues for my users, so instead I installed the documentserver into a separate LXC container and configured nextcloud to use this instead

Serverfox commented 4 years ago

I'm facing the same issue as guzzisti.

Also, Nextcloud logs the following error on each cron-update:

OCA\DocumentServer\Document\DocumentConversionException: namespace error : Namespace prefix wp14 ....

I'm not sure if these are related, there are discussions on https://help.nextcloud.com/t/errors-with-officeonline/75665 as well.

box18box commented 4 years ago

I did the suggestion of @Serverfox that (uninstall and reinstall) and NOT help. The Onlyoffice is not saving the changer.

Serverfox commented 4 years ago

Will Nextcloud 18.04 settle the issue?

box18box commented 4 years ago

No, I don't think so. But I solved it temporarly like that: crontab -u www-data -e and then in crontab:

But of course, it is not yet properly solve.

thomasfirnschrott commented 4 years ago

I also have the same problem since installing the community document server. All changes made via OnlyOffice were in cache and not written to NextCloud.

At some point of time the CDS (Community Document Server) was getting into a struggle and did not show the temporary changes any more.

I tried restoring a backup, but that was never touched by the changes made in OnlyOffice. So I lost all changes made in OnlyOffice. The problem is, that it seems to work quite nice, since different users can open the document and see each others changes, but never have they been written to disk.

The flush command works for me. Any document I create is not beeing saved at editor close or somewhere within an hour. But if I manuall call flushing sudo -u www-data php occ documentserver:flush the changes are immediately written to nextcloud and the disk.

This is no solution tho. Please try to get this working.

As I read through the whole post I suggest external OnlyOffice Server (docker/images) will produce the same errors. Am I correct or can anybody confirm that this would be a solution?

Is there anybody not having this problem? May we only have a common misconfiguration? If anybody could confirm working automativ flushes to the nextcloud an filesystem it would also be very important to fix the bug I guess.

And I also have to say, that it's quite dissapointing not to get any confirmation or comment on such a terrible bug form the devs within weeks.

stweil commented 4 years ago

@thomasfirnschrott, did you configure the Nextcloud cron job in your installation? It should trigger the flushing, too (every 5 minutes).

thomasfirnschrott commented 4 years ago

I have configured the background jobs to AJAX. The settings page shows green light and says that it just ran. I did not configure a cron job on the system.

In the meantime I found out, that running the flushing whilst people are online and editing a document breaks the sync to nexcloud sometimes. So I can not use that, too.

Does cron.php use another kind of flushing?

stweil commented 4 years ago

Does cron.php use another kind of flushing?

I suggest to try it (and please report your result here).

thomasfirnschrott commented 4 years ago

Thanks for the tip, it seems to me as if the cron.php does a somehow better job than the simple flush command.

I changed from AJAX to system CRON every 5 minutes.

So a closed file gets written back to nextcloud every 5 minutes - if there were changes. I even tried to have files open, where a flush whilst keeping files open destroyed the further writings of the user having the file open. In that case, cron.php does not trigger a write of the file back to nextcloud, even with pending changes.

It seems to me, as if cron.php checks if there is no one left that has the file open, and if so, it writes it back, pending changes.

That would even explain why AJAX isn't working. AJAX calls the cron.php script on user interaction, and while the user is online, it is not writing back. When the users close the files nobody triggers the cron.php call, so it does not work reliably.

For me the cron.php call in my www-data's crontab every 5 minutes seems to work.

# crontab -u www-data -e */5 * * * * php -f /var/www/html/nextcloud/cron.php

I'm keeping an eye on it for the next few days and will report back.

dirkpape commented 4 years ago

just to give my experience back to this thread: I 1st tried the cron solution but it failed because the documentserver:flush command yields an error, if you have at least one groupfolder active, als already documented in <https://github.com/nextcloud/documentserver_community/issues/110>. After realizing this, I changed to use the docker base onlyoffice documentserver. It seems that this one works in this manner, since we did not have any data losses since we switched to the docker based documentserver.

Serverfox commented 4 years ago

I have implemented the fix in lib/private/Files/View.php as suggested in <#110> by @dirkpape, however no change :-( I've also implemented cron job a little different from @thomasfirnschrott like this:

*/5 * * * * php -f /var/www/nextcloud/occ documentserver:flush; php -f /var/www/nextcloud/cron.php > /dev/null 2>&1

This one does the job for now.

The strong point in @dirkpape 's suggestion is, I don't see nextcloud logging errors anymore.

Let's cross fingers, that the next Onlyoffice release will fix this issue.

stweil commented 4 years ago

@Serverfox, occ documentserver:flush should not be needed as cron.php already triggers flushing.

Serverfox commented 4 years ago

@stweil for some reason, I wouldn't get any update without the occ documentserver:flush directive. Could there be anything wrong with my cron.php? My cron.php dates March 11. I've re-installed Nextcloud back in March from scratch as there where problems updating from V17.

clem8595 commented 4 years ago

I was having this same problem, and found a suggestion from "depasqualedavide" (on the NC forums here: https://help.nextcloud.com/t/documents-not-being-saved-when-editing-nextcloud-18-local-community-document-server-plugin/71382/41) to disable the Ransomware Protection app. Disabling the Ransomware app fixed the problem for me... OnlyOffice/Docker changes are now saving back to NC in less than a minute after all edit sessions are closed.

Serverfox commented 4 years ago

I was collaboratively edditing an EXCEL-Sheet with my colleague. All mutual changes became visible on screen during editing. Nice!

After leaving Onlyoffice all changes where gone for good. Not nice!!!

This is inspite of fixes mentioned by @dirkpape an @stweil. The Ransomware-app mentioned by @Jimbo11 isn't installed either.

Very much disappointing.

BenoitLacour commented 4 years ago

I had the same issue as everyone here, and spend a lot of time trying fixing it to figure out the integrated onlyoffice document server is not reliable.

I switched to the community edition provided by only office and mounted it on docker, and after some setup, managed to get it work properly.

Now my modifications are visible within 20 seconds on nextcloud and synced in less than a minute to my desktop.

The few tests I made produce a totally different result, I don't have any merge issue anymore, and the edition of .odt file seems much better.

All this to say that the nextcloud integrated only office version is not mature enough to be used seriously (I had merge issues on .odt as a single user !!!) and need to be improved.

timo12357 commented 4 years ago

It has been 5 months and this devastating bug is still open.

box18box commented 4 years ago

I installed this: https://helpcenter.onlyoffice.com/server/linux/document/linux-installation.aspx It is free for 20 users. It works perfectly. The problem is that it uses the same port as Nextcloud. I changed it to 8180. So apache2 with Nextcloud Onlyoffice with Nginx 8180 SSL 4443. And you need a DNS name for onlyoffice.domain.com like nextcloud.domaine.com. Thanks to @BenoitLacour

gregoryloichot commented 4 years ago

Same issue. Any news ? Any planned fix ?

Thanks.

kesselb commented 4 years ago
  • Please use the +1 reaction to show that you are affected by the same issue.
    • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
    • Subscribe to receive notifications on status change and new comments.

@gregoryloichot Thanks :+1: