Skip to content

Replace on-disk lock by in-memory lock - #1475

Merged
michielbdejong merged 1 commit into
masterfrom
feature/async-lock
Sep 9, 2020
Merged

michielbdejong merged 1 commit into
masterfrom
feature/async-lock

Conversation

@RubenVerborgh

Copy link
Copy Markdown
Contributor

Background

Prior to #1116, two simultaneous PATCH requests could corrupt files. The solution in #1116 was built with the design goals:

  • to function in a multi-worker environment
  • to not require external services (like Redis)

The file-based locking system—although meeting the above two goals—did cause some annoyances (notably #1372).

What this PR does

This PR switches the file-based locking to in-memory locking.

Closes #1372
Obsoletes #1464

Advantages

  • no more gratuitous writes to disk
  • uses an external library that is well-tested
  • still no dependencies on external services

Disadvantages

  • does not function with multiple workers or threads
    • …but neither do a a lot of other parts of NSS, so multi-worker support is future work anyway

What this PR does not

@michielbdejong

Copy link
Copy Markdown
Member

Nice! Is it covered by a unit test?

@bourgeoa what do you think? Especially given your remark in https://github.com/solid/node-solid-server/pull/1464/files#diff-42068aebd9eb6d9326293ef88bb61b3dR32 - why did you discardasync-lock originally?

I don't have a strong preference either way, as long as it works :) Eventually I want to implement a proper caching layer with write-through so we will no longer need locking (writes to the cache will be synchronous).

@RubenVerborgh

Copy link
Copy Markdown
Contributor Author

Nice! Is it covered by a unit test?

Yes, all the LDP logic covers it.

@bourgeoa

bourgeoa commented Sep 8, 2020

Copy link
Copy Markdown
Member

@michielbdejong
I did find this solution and thought it could be used as a read cache for resources with text/turtle contentType, if the idea was wellcomed.

@RubenVerborgh

Copy link
Copy Markdown
Contributor Author

It's probably too early for a cache, before we have the single read/write layer. Plus, we still need to solve the locking then with regard to disk writing.

@michielbdejong
michielbdejong merged commit 6cac896 into master Sep 9, 2020
@michielbdejong
michielbdejong deleted the feature/async-lock branch September 9, 2020 11:37
@RubenVerborgh

RubenVerborgh commented Sep 9, 2020 •

Copy link
Copy Markdown
Contributor Author

I think your SSD will be very happy, @timbl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stop creating lock files in the filestore for each read operation

3 participants