It just stumbled upon this in Fractal. I wrote a migration for the secrets we store, but when spawning 2 Item::delete(), we get portal::Error::TargetFileChanged(_) on one of them.
It seems like it is due to several tasks being able to read mtime in portal::Keyring::write(), because its in a RwLock. But as soon as the first task changes the file, portal::api::Keyring::dump() fails for subsequent tasks when checking if the mtime is still correct.
I believe this could be solved by using a Mutex instead for mtime. That way only one portal::api::Keyring::dump() can be called at a time, always with the latest mtime.
It just stumbled upon this in Fractal. I wrote a migration for the secrets we store, but when spawning 2
Item::delete()
, we getportal::Error::TargetFileChanged(_)
on one of them.It seems like it is due to several tasks being able to read
mtime
inportal::Keyring::write()
, because its in aRwLock
. But as soon as the first task changes the file,portal::api::Keyring::dump()
fails for subsequent tasks when checking if themtime
is still correct.I believe this could be solved by using a
Mutex
instead formtime
. That way only oneportal::api::Keyring::dump()
can be called at a time, always with the latestmtime
.