Investigate '"undefined method `lines' for nil:NilClass" during import, using import.rake task
While measuring results for 10x Initiative summary #196540 (closed), I used XL data set for measuring the import.
I encountered error:
"undefined method lines' for nil:NilClass"`
Backtrace:
"/Users/nikola/Projects/gitlab-development-kit/gitlab/lib/gitlab/diff/lines_unfolder.rb:61:in `block in unfold_required?'"
Investigation
This error only happens using XL data set and import.rake task.
Testing with GitlabHQ does not trigger this error.
Further investigation shows that if we disable RequestStorage in rake task, everything works fine.
In case when RequestStorage is enabled, repository.exists? method will always return false, and actual blob for diff file will never be retrieved from the repository.
This will cause unfolding diff lines to crash.
For more detailed explanation check !24258 (merged)
Proposed solution
We should clear the cache by running expire_exists_cache, once repository is created from bundle