-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
downloader: manual .lock remove may lead to race and creation of data files without .torrent #9782
Conversation
if !tf.exists(name) && !prohibited { | ||
err = tf.create(name, res) | ||
if err != nil { | ||
return nil, false, false, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created
is always false
.
Does it makes sense to just check lock file exists on the start instead of checking it per file? Like, we started, downloads either prohibited or not, that's it. Could be changed only with restart.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“ instead of checking it per file? ” - this feature is just introduced by Giulio - to prevent downloading 1 type of file (he working on nee type of file): #9766
Don’t know: maybe it was doable by creating special branch in “erigon-snapshots” repo (maybe not).
Quality Gate passedIssues Measures |
} | ||
func (tf *TorrentFiles) create(torrentFilePath string, res []byte) error { | ||
|
||
func (tf *TorrentFiles) CreateIfNotProhibited(name string, res []byte) (ts *torrent.TorrentSpec, prohibited, created bool, err error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prohibited
and created
results are not used anywhere - are they going to be used in a future PR? if not then should we remove them from the func signature?
also looks like created
is always returned as false - seems like we are missing a statement to set created to true
and return that in the case of a file getting created
such pattern is always race - even if
prohibited
/exists()
/create()
are atomic inside.to eliminate race - need move towards analog of
CompareAndSwap
-CreateIfNotProhibited
which in 1 mutex lock will: check_lock, existence, create.