From a51d1e209da4037d58b4203de7477ecd2298fb85 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 1 Sep 2026 09:08:06 +0200 Subject: [PATCH 1/3] fix(sync): do not check for conflicts during sync The document may be in the middle of getting saved. When the file has been updated but the metadata in the documents table has not it may seem like the file was overwritten even though text is saving the file. This does not indicate an actual conflict. Avoid triggering the conflict screen in that race condition. Signed-off-by: Max --- lib/Service/ApiService.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/Service/ApiService.php b/lib/Service/ApiService.php index f471009fe31..d03944d8844 100644 --- a/lib/Service/ApiService.php +++ b/lib/Service/ApiService.php @@ -217,7 +217,6 @@ public function sync(Session $session, Document $document, int $version = 0, ?st // ensure file is still present and accessible $file = $this->documentService->getFileForSession($session, $shareToken); $result['readOnly'] = $this->documentService->isReadOnly($file, $shareToken); - $this->documentService->assertNoOutsideConflict($document, $file); } catch (NotPermittedException|NotFoundException|InvalidPathException $e) { $this->logger->info($e->getMessage(), ['exception' => $e]); return new DataResponse([ @@ -228,16 +227,9 @@ public function sync(Session $session, Document $document, int $version = 0, ?st return new DataResponse([ 'message' => 'Document no longer exists' ], Http::STATUS_NOT_FOUND); - } catch (DocumentSaveConflictException) { - try { - /** @psalm-suppress PossiblyUndefinedVariable */ - $result['outsideChange'] = $file->getContent(); - } catch (LockedException) { - // Ignore locked exception since it might happen due to an autosave action happening at the same time - } } - return new DataResponse($result, isset($result['outsideChange']) ? Http::STATUS_CONFLICT : Http::STATUS_OK); + return new DataResponse($result, Http::STATUS_OK); } public function save(Session $session, Document $document, int $version, string $autosaveContent, string $documentState, bool $force = false, bool $manualSave = false, ?string $shareToken = null): DataResponse { From 97d1d614f0a1b69f8a69368afdd0117bf03261be Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 1 Sep 2026 19:01:04 +0200 Subject: [PATCH 2/3] fix(save): extend ttl for document save lock to 1 Minute We observed save requests that took longer than 30 seconds. The lock needs to outlive those in order to prevent superfluous 409 responses. Signed-off-by: Max --- lib/Service/DocumentService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Service/DocumentService.php b/lib/Service/DocumentService.php index a99c4929ea5..8eb19426e6e 100644 --- a/lib/Service/DocumentService.php +++ b/lib/Service/DocumentService.php @@ -427,7 +427,7 @@ public function autosave(Document $document, File $file, int $version, string $a return $document; } - $this->cache->set('document-save-lock-' . $documentId, true, 10); + $this->cache->set('document-save-lock-' . $documentId, true, 60); try { $this->lockManager->runInScope(new LockContext( $file, From 97e994997b29a2f7786b1fdeb36b05e4a4f2d342 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 2 Sep 2026 04:27:43 +0200 Subject: [PATCH 3/3] fix(save): autosave only every ten seconds Abort autosave if another save is still under way. We observed save requests taking up to 30 seconds. In this timespan autosave requests would still be processed as the lastSavedTime in the database has not been updated yet. Signed-off-by: Max --- lib/Service/DocumentService.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/Service/DocumentService.php b/lib/Service/DocumentService.php index 8eb19426e6e..5b99acc4e83 100644 --- a/lib/Service/DocumentService.php +++ b/lib/Service/DocumentService.php @@ -385,6 +385,11 @@ public function autosave(Document $document, File $file, int $version, string $a $this->assertNoOutsideConflict($document, $file, $force); + // Abort autosave if already saving. + if ($this->cache->get('document-save-lock-' . $documentId) && $manualSave === false) { + return $document; + } + // Do not save if newer version already saved // Note that $version is the version of the steps the client has fetched. // It may have added steps on top of that - so if the versions match we still save.