Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty session content with single step in the database and file content preserved #5215

Closed
max-nextcloud opened this issue Jan 9, 2024 · 5 comments
Labels
bug Something isn't working high regression

Comments

@max-nextcloud
Copy link
Collaborator

max-nextcloud commented Jan 9, 2024

Describe the bug
We observed on two different instances that the content of a file turned empty.

Investigating it in more detail we found the following:

  • There was no .vue file in the documents app folder.
  • there was only one step entry in the database
  • there were two sessions in the database - most likely because we were looking at the document in two tabs.

To Reproduce
We are still to find reliable steps to reproduce the behavior.
In one case this is what triggered it:

  1. Open new page in collectives
  2. Edit it for a while
  3. Close the laptop lid
  4. Reopen after approx 1 hour
  5. reopen the document and see it empty.
  6. Markdown file content is preserved.

Expected behavior
The file content in the editing session should still exist.

Screenshots
Imagine an empty editor view here. 😉

Server details:

  • Nextcloud version: 27.1.15
  • PHP Version: 8.2
  • Database: MariaDB
@max-nextcloud max-nextcloud added the bug Something isn't working label Jan 9, 2024
@juliushaertl
Copy link
Member

As mentioned in the call we should check if this is reproducible somehow by manually resetting the document state and steps.

Another thing to check is if the cleanup of steps/document state is save-guarded to also cleanup sessions so at least a new session would be created then on reconnect?

@max-nextcloud
Copy link
Collaborator Author

I just tried the following:

  • edit a document
  • disconnect (via network throttling)
  • type some more before reconnect button shows
  • cleanup document with ./occ text:reset -f 1390
  • turn network on again

Text fails to reconnect automatically as the session is gone
After clicking reconnect the doc reopens with a clean state without the unsend steps.

So that seemed okay - not sure if it will always work that way though.

@max-nextcloud
Copy link
Collaborator Author

I think we will need to separate the sync service session and the yjs session conceptually and in practice.

Sync service session

Connects all users that are editing the document at the same time.

  • ephemeral
  • cleaned up when no users are active anymore
  • created as needed
  • backend for the SyncServiceProvider in yjs

Yjs session

  • long running
  • contains the editing history and the yjs document state at the time of saving
  • used to recover and resume the editing session
  • might contain info for user colors in the long run

@max-nextcloud
Copy link
Collaborator Author

Even if we keep the yjs doc around there's still a way to be missing steps from one peer:

  • one client keeps edits, closes lid
  • some steps send but not saved yet
  • session ends
  • session is cleaned up
  • document state does not have latest steps from that client yet even though client already send them.
  • lid opened again
  • new session created from existing yjs session
  • client proceeds
  • other clients that connect will miss the steps that the client send between the last save and closing the lid

Possible solution

When reconnecting:

  • apply document state from yjs file again to make sure we are in sync with edits that happened in between
  • compute diff between local yjs and document state on server
  • send diff as update if it exists.

We could even compute this regularly to make sure everyone stays in sync.

@mejo-
Copy link
Member

mejo- commented Mar 13, 2024

Given that we guess this is fixed with Nextcloud 27.1.6 and 28.0.2, let's close the issue for now. We can reopen it later on if there's new reports about this missbehaviour.

@mejo- mejo- closed this as completed Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high regression
Projects
Archived in project
Development

No branches or pull requests

3 participants