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

Saving a Gdoc is happening in a race condition, reverting the save right after (sometimes) #2461

Closed
marcelgerber opened this issue Jul 19, 2023 · 2 comments

Comments

@marcelgerber
Copy link
Member

Description

There is a race condition in saving condition which, when hit, can lead to:

  • A gdoc being saved upon user request (e.g. published)
  • The same gdoc being unpublished right after, since it is overwritten by a periodic refresh from Google Docs:
    if (!gdoc.published) {
    await dataSource.getRepository(Gdoc).create(gdoc).save()
    }

From my own experience, I would say this behavior happens in about 30% of cases.

Additional context

Possible solutions:

  • Only call .save() if the gdoc revisionId has changed (easy; there's still a chance we erroneously overwrite it although far less likely)
  • Check that updatedAt hasn't changed before updating the record in the DB (easy; there's still a chance we erroneously overwrite it although far less likely)
  • Only update fields like content, and not slug or published
@ikesau
Copy link
Member

ikesau commented Oct 3, 2023

I think a relatively simple way to fix this would be to add an endpoint for publishing, and ignoring the property otherwise.

While we're at it, let's double check with the authors and make sure autosave is wanted at all. We could simplify things a lot without it.

@danyx23
Copy link
Contributor

danyx23 commented Mar 19, 2024

We're not doing the automatic preview anymore so this one is no longer relevant.

@danyx23 danyx23 closed this as completed Mar 19, 2024
@larsyencken larsyencken closed this as not planned Won't fix, can't repro, duplicate, stale Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants