Skip to content
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

[backend] reduce race condition in debian repo update #4517

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

suihkulokki
Copy link
Contributor

Regenerating, compressing and signing the debian repository index
files takes a while, updates taking over a minute have been observed.
Any "apt-get update" during this period can fail. To fix this, update
the indexes in a temporary directory and then replace all index files at
once.

There still remains a race condition, but now only during
milliseconds rather than over minute.

Use of temporary directory means the functions can now be cleaned from
temporary filenames, and this compress_and_rename becomes copy_compress.

@DavidKang DavidKang added the Backend Things regarding the OBS backend label Feb 20, 2018
@suihkulokki
Copy link
Contributor Author

Fixed two mistakes from original PR

  1. added chomp, so $tmpdir no longer has trailing newline
  2. replaced rename() with qsystem("mv", ...
  • $tmpdir is often tmpfs and rename system call does not work over filesystem boundaries

@suihkulokki
Copy link
Contributor Author

There is apparently another place where Release.gpg is deleted. Looking at obspublisher logs:

publishing home:test/Debian
      - Release.gpg
      ! armhf/gir1.2-gstreamer-1.0_1.12.2-1_armhf.deb

Adding patch to fix this as well

@suihkulokki
Copy link
Contributor Author

Please take a look. We've deployed a backport of this, and it would be good to know if it's broken ;)

@fboudra
Copy link

fboudra commented Apr 12, 2018

@DavidKang @mlschroe ping

@suihkulokki
Copy link
Contributor Author

The travis failure appears a network infrastructure error.

@bgeuken
Copy link
Member

bgeuken commented May 15, 2018

@mlschroe Please review:-)

@mlschroe
Copy link
Member

I don't see the point of the tmpdir. Wouldn't it be enough to just move the .new files at the end of the function instead of right after the compression?

@suihkulokki
Copy link
Contributor Author

@mlschroe operating in temporary directory with correct filename to begin with just seemed cleaner. We can't just move the files in the end of the function, since they are used as input for generating the md5sums of the Release file.

I'll update the PR with an (untested) version that uses .new files. If you still like way better in principle, test and finish that version, else I'll revert to the tmpdir approach.

@Ana06
Copy link
Member

Ana06 commented Jan 7, 2019

@mlschroe ping!

@vpereira
Copy link
Contributor

any update here @mlschroe ? do you want to close it or accept it? @suihkulokki thank you for your contribution.. could you maybe rebase it with master to fix the conflict?

Regenerating, compressing and signing the debian repository index
files takes a while, at least upto an minute observed. Any
"apt-get update" during this period will fail.

Move temporary files copy to the end, so compress_and_rename is
now just copy_compress. Adapt the createrelease_debian funtion
to use .new files while printing the names of the final files
into the release files.

Finally, treat Release.gpg like all the other generated repo files,
skip deleting it unless the whole repo is deleted.

There still remains a race condition, but now only during
milliseconds while the rename loop runs, rather than over
minute.
@codecov
Copy link

codecov bot commented May 24, 2019

Codecov Report

Merging #4517 into master will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4517      +/-   ##
==========================================
+ Coverage   90.73%   90.76%   +0.02%     
==========================================
  Files         499      499              
  Lines       21330    21330              
==========================================
+ Hits        19354    19360       +6     
+ Misses       1976     1970       -6     

@suihkulokki
Copy link
Contributor Author

I've updated the review against the current master - this is the version using .new files as suggested by @mlschroe . In production we are still using the temporary directory based approach which I find cleaner.

I'm ready to proceed with either version, assuming there is some hope of getting it merged.

@dmarcoux
Copy link
Contributor

It looks like @mlschroe isn't particularly interested in merging this. Sorry @suihkulokki

@dmarcoux dmarcoux closed this Apr 30, 2020
@nickbroon
Copy link
Contributor

That's a shame, as this would be definitely be nice to have, as we occasionally see the race on our deployment.

@adrianschroeter
Copy link
Member

Do not close submissions which are not for your code ...

@nickbroon
Copy link
Contributor

What is the status of this PR? Is there any prospect of it being merged to fix this race condition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend Things regarding the OBS backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants