Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

feat: repo locking with fs2 #429

Merged
merged 13 commits into from
Nov 17, 2020
Merged

feat: repo locking with fs2 #429

merged 13 commits into from
Nov 17, 2020

Conversation

niklaslong
Copy link
Member

@niklaslong niklaslong commented Nov 10, 2020

supersedes #426 and resolves #243.

This implements repo locking with fs2. The only concern for this crate is that it is poorly maintained but the functionality we need seems stable enough for now.

Certain tests are currently failing, notably because multiple nodes are being created with the same repo (dag tests for instance). Not sure what the solution to this will be...

Update: running tests with --test-threads=1 passes all unit tests. The integration tests fail (I think because multiple nodes are being spun up with the same repo).

Update 2: all green, making sure test nodes use a different temp dir for the repo fixed the tests.

The introduction of repo locking caused tests with multiple
nodes using the same temporary repo directory to fail.
@niklaslong niklaslong marked this pull request as ready for review November 12, 2020 09:59
src/lib.rs Outdated Show resolved Hide resolved
src/repo/mod.rs Outdated Show resolved Hide resolved
src/repo/mod.rs Outdated Show resolved Hide resolved
This was after concerns were raised about potential time-of-check to
time-of-use (TOCTOU) issues. The check isn't
actually necessary as `OpenOptions::create` set to `true` will create
only if the file doesn't already exist.
Copy link
Collaborator

@koivunej koivunej left a comment

Choose a reason for hiding this comment

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

Minor nit on the perhaps extra #[async_trait]. Bigger issue with the unwraps. Great that this started working.

As we've already discussed, the fs2 dependency while not actively maintained is probably ok for the short/medium-term. I can't see many reasons why this functionality would have to change though, given the fact that libc stuff doesn't change to often.

src/repo/mod.rs Outdated Show resolved Hide resolved
src/repo/mem.rs Show resolved Hide resolved
src/repo/fs.rs Outdated Show resolved Hide resolved
Repo locking was previously performed on repo::new, this keeps
the Lock struct initialisation in repo::new but moves the locking into
repo::init.
Copy link
Collaborator

@koivunej koivunej left a comment

Choose a reason for hiding this comment

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

This one is looking good to go!

We did cover a lot of ground in chat outside of this higher latency review interface.

bors r+

@bors
Copy link
Contributor

bors bot commented Nov 17, 2020

Build succeeded:

@bors bors bot merged commit b1e83a6 into rs-ipfs:master Nov 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Repo locking
2 participants