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

fix(lock): fix early release of lock #1256

Merged
merged 2 commits into from
Apr 1, 2024

Conversation

kishore03109
Copy link
Contributor

@kishore03109 kishore03109 commented Mar 31, 2024

Problem

Currently, we are releasing the lock before the promise gets resolved, which then leads to the lock becoming effectively useless as it does not guarantee that each mutation on the repo is isolated from one another. This would prob lead to more users complaining that there are concurrent editors, but there might be further optimisations that could be done to reduce the frequency of this.

Solution

dont release lock early

Breaking Changes

  • Yes - this PR contains breaking changes
    • Details ...
  • No - this PR is backwards compatible with ALL of the following feature flags in this doc

Before & After Screenshots

BEFORE:

Screenshot 2024-04-01 at 7 37 00 AM

AFTER:

Screenshot 2024-04-01 at 7 39 11 AM

Tests

[ ] Go into any site and perform CRUD operations on a page level for a repo in efs.

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @kishore03109 and the rest of your teammates on Graphite Graphite

@kishore03109 kishore03109 marked this pull request as ready for review March 31, 2024 23:42
@kishore03109 kishore03109 requested a review from a team March 31, 2024 23:42
@kishore03109 kishore03109 force-pushed the 04-01-fix_lock_fix_early_release_of_lock branch from 8f811e8 to 0d4e209 Compare March 31, 2024 23:46
@kishore03109 kishore03109 merged commit 42cf0bd into develop Apr 1, 2024
12 checks passed
@mergify mergify bot deleted the 04-01-fix_lock_fix_early_release_of_lock branch April 1, 2024 05:39
Copy link
Contributor

@timotheeg timotheeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for a very targeted fix 👍

As discussed, a few things are "dirty" and could be refactored.

  • We're mixing functional promise chains with .then()/.catch() and async/await style which make things confusing
  • The express control flow is not being hijacked correctly: next is supplied to routeHandler(), which could call it, and so we calling next() again later (say, if we cannot release the lock for example) might lead to inconsistent behaviour. As a wrapper to a route handler, the code should take over management of the middleware sequence.

The above issues have potential for some run-time errors, but it looks like in practice, the system has been behaving ok 🤞😰

@alexanderleegs alexanderleegs mentioned this pull request Apr 1, 2024
@timotheeg
Copy link
Contributor

Argh, I just spotted we need to do the same for attachWriteRouteHandlerWrapper(), it has the same early release issue.
I'll open a PR for it now, and we should release urgently too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants