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

Stale Rugged::Config#each_key values if another process changes .git/config #785

Open
stanhu opened this issue Feb 28, 2019 · 1 comment

Comments

@stanhu
Copy link
Contributor

stanhu commented Feb 28, 2019

This looks like a regression from libgit2 0.28.0, but I'm not sure yet if it's a Rugged issue or a libgit2 one. Here's a sample reproduction:

require 'rugged'

repo = Rugged::Repository.new('.')
start_values = repo.config.each_key.to_a
system('git config --local core.foobar "asdf"')

new_values = repo.config.each_key.to_a
puts "Inserted value: #{repo.config['core.foobar']}"

system('git config --local --unset core.foobar')

puts start_values == new_values

With Rugged 0.27.5, I get:

Inserted value: asdf
false

With Rugged 0.28.0, I get:

Inserted value: asdf
true

What's curious is that the lookup works fine, but the each_key seems to be cached in the 0.28.0 case.

@pks-t @carlosmn I think this has to do with the in-memory config backend in libgit2/libgit2#4767.

@stanhu
Copy link
Contributor Author

stanhu commented Feb 28, 2019

What's even weirder is that if I do a lookup before running repo.config.each_key, the cache seems to get flushed. This returns the right result for 0.28.0:

require 'rugged'

repo = Rugged::Repository.new('.')
start_values = repo.config.each_key.to_a
system('git config --local core.foobar "asdf"')

# Do a lookup before each_key is called
puts "Inserted value: #{repo.config['core.foobar']}"
new_values = repo.config.each_key.to_a

system('git config --local --unset core.foobar')

puts start_values == new_values

tigefa4u pushed a commit to tigefa4u/gitlabhq that referenced this issue Mar 19, 2019
This version bump makes things consistent between Gitaly and
fixes a significant number of bugs:
https://github.com/libgit2/libgit2/releases

This also decreases disk space of Omnibus builds by ~30 MB.

There is also a workaround for
libgit2/rugged#785. If Gitaly or another
process changes .gitconfig while Rugged has the file loaded,
Rugged::Repository#each_key will report stale values unless a lookup is
done first.

This bug only manifests in a spec because we are using both Gitaly and
Rugged at the same time there, and we normally don't use Rugged in the
CE/EE code in this way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant