This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
Add locks for pinning #2103
Closed
Description
Currently there is no locking mechanism when modifying pins.
We should take a lock when performing any kind of pin operation, in order to prevent simultaneous pin operations from interfering with each other.
For example when adding a pin, we
- resolve the path
- get the object
- flush the pins
- store direct pins (1)
- store recursive pins (2)
- store a reference to the direct/recursive nodes (1 & 2)
- save the resulting CID to the datastore
Without locking, any of these asynchronous operations may occur concurrently and cause out-of-date or incomplete pin sets to to be stored.
The pin operations are currently managed in
I believe changes will only need to be made in pin.js, however the Garbage Collection PR includes some refactoring such that this structure will change somewhat, so I would suggest implementing a fix for this issue after the GC PR has landed.
We can refer to the go implementation of pinning for inspiration.