Skip to content

Rewrite of the locking interface - #536

Merged
jvherweg merged 5 commits into
masterfrom
feat/lock-readwrite
Jan 22, 2021
Merged

jvherweg merged 5 commits into
masterfrom
feat/lock-readwrite

Conversation

@jvherweg

@jvherweg jvherweg commented Jan 21, 2021 •

Copy link
Copy Markdown
Member

This PR combines several locking-related changes:

  • ResourceLocker now works with two getReadLock/getWriteLock functions. This is both in preparation of read/write locks and multi-threaded locks since there no longer is a reference to the lock object. The main reason for doing this change now is because it also allows more control over what happens within a locked run, which was needed to detect locking conflicts. Adds the interface of Distinguish between read and write locks #32 but does not actually provide a read/write locking algorithm.
  • WrappedExpiringResourceLocker consequently also needed a change. Its locking functions will now error when a timeout occurs, allowing for easier problem detection.
  • Locking has been removed from the patch handler, closes SparqlUpdatePatchHandler should likely not be locking? #137. In the future we might want to make some changes regarding this, but for now this would otherwise interfere with adding the LockingResourceStore to the store stack.
  • LockingResourceStore was also updated with the new interface. It now returns an error in case the operation was not able to succeed within the timeout.
  • LockingResourceStore has been added to the default config, so perhaps in the future some locking related issues are going to pop up since this is the first time we actually added full locking for all requests. Closes Integrate LockingResourceStore in the configs #355.

Every bullet corresponds to a single commit.

Getting all the promise to interact nicely with eachother was an interesting experience.

@jvherweg jvherweg added the ☀️ enhancement New feature or request label Jan 21, 2021

@RubenVerborgh RubenVerborgh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Only a whole bunch of style nits; I added them because I think they will help understanding what is very crucial and sensitive code.

Comment thread src/storage/LockingResourceStore.ts Resolved
Comment thread src/storage/LockingResourceStore.ts Resolved
Comment thread src/storage/LockingResourceStore.ts Resolved
Comment thread src/storage/LockingResourceStore.ts Resolved
Comment thread src/storage/LockingResourceStore.ts Resolved
By making use of withReadLock and withWriteLock instead
of acquiring the locks themselves it's easier to keep control
of what happens.
Due to the new interface, it is now possible to throw an error
if there is a timeout which should make it easier
to find locking issues.
Due to not having re-entrant locks this would cause deadlocks
with the LockingResourceStore or require more advanced configurations.
If this is needed in the future we can potentially add a LockingPatchHandler.
This has as added bonus that, in the case of getRepresentation,
the stream will be destroyed with an error in case of a timeout.
@jvherweg
jvherweg force-pushed the feat/lock-readwrite branch from 239d26c to 576ef9d Compare January 22, 2021 10:28
@jvherweg
jvherweg merged commit 69c3144 into master Jan 22, 2021
@jvherweg
jvherweg deleted the feat/lock-readwrite branch January 22, 2021 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☀️ enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Integrate LockingResourceStore in the configs SparqlUpdatePatchHandler should likely not be locking?

2 participants