Issue 2138: [gerrit gc] file locking issue in gerrit gc
Status:  New
Owner: ----
Reported by Ian.Kuml...@gmail.com, Sep 23, 2013
************************************************************
***** NOTE: THIS BUG TRACKER IS FOR GERRIT CODE REVIEW *****
***** DO NOT SUBMIT BUGS FOR CHROME, ANDROID, INTERNAL *****
***** ISSUES WITH YOUR COMPANY'S GERRIT SETUP, ETC.    *****
***** THOSE ISSUE BELONG IN DIFFERENT ISSUE TRACKERS!  *****
************************************************************

Affected Version:
2.7

What steps will reproduce the problem?
1. something uses <file>.idx
2. gerrit gc
3. gerrit gc fails

What is the expected output? What do you see instead?
Pausing or waiting for the file lock?
Or, indeed, skipping it for now

Please provide any additional information below.

The problem arose with a git that is located on a local ext3 filesystem - the file was there when the problem occurred which leads me to believe that it is a file locking issue.

I'm unsure of how easy this would be to recreate...

Stacktrace:
org.eclipse.jgit.api.errors.JGitInternalException: Could not get repository statistics
        at org.eclipse.jgit.api.GarbageCollectCommand.getStatistics(GarbageCollectCommand.java:145)
        at com.google.gerrit.server.git.GarbageCollection.run(GarbageCollection.java:83)
        at com.google.gerrit.sshd.commands.GarbageCollectionCommand.runGC(GarbageCollectionCommand.java:97)
        at com.google.gerrit.sshd.commands.GarbageCollectionCommand.access$500(GarbageCollectionCommand.java:41)
        at com.google.gerrit.sshd.commands.GarbageCollectionCommand$1.run(GarbageCollectionCommand.java:67)
        at com.google.gerrit.sshd.BaseCommand$TaskThunk.run(BaseCommand.java:429)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
        at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:337)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)
Caused by: java.io.FileNotFoundException: /path/to/git.git/objects/pack/pack-<sha1 id>.idx (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:146)
        at org.eclipse.jgit.internal.storage.file.PackIndex.open(PackIndex.java:94)
        at org.eclipse.jgit.internal.storage.file.PackFile.idx(PackFile.java:167)
        at org.eclipse.jgit.internal.storage.file.PackFile.getIndex(PackFile.java:193)
        at org.eclipse.jgit.internal.storage.file.GC.getStatistics(GC.java:867)
        at org.eclipse.jgit.api.GarbageCollectCommand.getStatistics(GarbageCollectCommand.java:143)
        ... 13 more
[2013-09-21 13:09:15,595] ERROR com.google.gerrit.server.git.GarbageCollection : [gerrit/project]
org.eclipse.jgit.api.errors.JGitInternalException: Could not get repository statistics
        at org.eclipse.jgit.api.GarbageCollectCommand.getStatistics(GarbageCollectCommand.java:145)
        at com.google.gerrit.server.git.GarbageCollection.run(GarbageCollection.java:83)
        at com.google.gerrit.sshd.commands.GarbageCollectionCommand.runGC(GarbageCollectionCommand.java:97)
        at com.google.gerrit.sshd.commands.GarbageCollectionCommand.access$500(GarbageCollectionCommand.java:41)
        at com.google.gerrit.sshd.commands.GarbageCollectionCommand$1.run(GarbageCollectionCommand.java:67)
        at com.google.gerrit.sshd.BaseCommand$TaskThunk.run(BaseCommand.java:429)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
        at java.util.concurrent.FutureTask.run(FutureTask.java:262)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
        at com.google.gerrit.server.git.WorkQueue$Task.run(WorkQueue.java:337)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
        at java.lang.Thread.run(Thread.java:724)
Caused by: java.io.FileNotFoundException: /path/to/git.git/objects/pack/pack-<sha1 id>.idx (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:146)
        at org.eclipse.jgit.internal.storage.file.PackIndex.open(PackIndex.java:94)
        at org.eclipse.jgit.internal.storage.file.PackFile.idx(PackFile.java:167)
        at org.eclipse.jgit.internal.storage.file.PackFile.getIndex(PackFile.java:193)
        at org.eclipse.jgit.internal.storage.file.GC.getStatistics(GC.java:867)
        at org.eclipse.jgit.api.GarbageCollectCommand.getStatistics(GarbageCollectCommand.java:143)
        ... 13 more