Skip to content

Object cache inconsistent after fetch #34

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

Closed
eswierk opened this issue Oct 21, 2011 · 2 comments
Closed

Object cache inconsistent after fetch #34

eswierk opened this issue Oct 21, 2011 · 2 comments

Comments

@eswierk
Copy link

eswierk commented Oct 21, 2011

If I create a new remote, call remote.fetch() and then try to obtain one of the newly-fetched commits by its sha, I get a BadObject exception deep inside gitdb:

Traceback (most recent call last):
File "/home/foobar/ggit/ggit/repo.py", line 134, in foreach
results[i] = fn(items[i], m, _args, *_kargs)
File "/home/foobar/ggit/gg", line 185, in mergepull
sb = repo.commit(headRev)
File "/usr/local/lib/python2.7/dist-packages/GitPython-0.3.2.RC1-py2.7.egg/git/repo/base.py", line 378, in commit
return self.rev_parse(str(rev)+"^0")
File "/usr/local/lib/python2.7/dist-packages/GitPython-0.3.2.RC1-py2.7.egg/git/repo/fun.py", line 151, in rev_parse
obj = name_to_object(repo, rev[:start])
File "/usr/local/lib/python2.7/dist-packages/GitPython-0.3.2.RC1-py2.7.egg/git/repo/fun.py", line 89, in name_to_object
return Object.new_from_sha(repo, hex_to_bin(hexsha))
File "/usr/local/lib/python2.7/dist-packages/GitPython-0.3.2.RC1-py2.7.egg/git/objects/base.py", line 64, in new_from_sha
oinfo = repo.odb.info(sha1)
File "/usr/local/lib/python2.7/dist-packages/gitdb-0.5.4-py2.7-linux-x86_64.egg/gitdb/db/base.py", line 256, in info
return self._db_query(sha).info(sha)
File "/usr/local/lib/python2.7/dist-packages/gitdb-0.5.4-py2.7-linux-x86_64.egg/gitdb/db/base.py", line 243, in _db_query
raise BadObject(sha)
BadObject: BadObject: 4634b83087e4744ee980a17a63952412374b1b95

I can work around the problem by calling repo.odb.update_cache() after the fetch but before looking up the commit.

It would be nice if Remote.fetch() did this automatically to ensure cache consistency.

@Byron
Copy link
Member

Byron commented Jun 7, 2012

This issue relates to #61 .

For consistency, GitDB should update its cache automatically when it encounters a cache-miss.
Currently this is deactivated for performance reasons, but I assume it wouldn't be any performance penalty under normal circumstances, as it would just work the same way the git command does.

@Byron Byron added this to the v0.3.5 - bugfixes milestone Nov 19, 2014
@Byron Byron closed this as completed in 46889d1 Jan 8, 2015
@Byron
Copy link
Member

Byron commented Jan 8, 2015

Fetch and Pull operations, if performed like repo.remotes.origin.fetch(), will automatically update their respective ODBs caches.
Please note that manual calls to repo.odb.update_cache() should now be removed from client calls to avoid cache trashing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants