Creating new files is not multi-goroutine safe
sfc-gh-thardie opened this issue · 1 comments
If you call New()
on the storage
objects from multiple goroutines at the same time, go runtime may error with fatal error: concurrent map writes
. This happens because the files
map inside the storage
struct has no concurrency protection around multiple access.
Other concurrency issues probably exist for accessing the children
map inside the storage
object.
@sfc-gh-thardie Yep, this is an issue that unfortunately ends up affecting go-git
as well. I would support a new implementation keeping the current as-is. Then offer users a way to opt into the safer approach.
From an API perspective, we could do something similar to the approach on the recent osfs
changes, in which we introduced sub-types with options. Is this something you would be keen to implement?