Skip to content

Commit f23d73e

Browse files
committed
RefDirectory#refreshPathToLooseRef: also refresh loose ref itself
We observed that newly generated Gerrit auth tokens weren't visible on all pods in an HA deployment of k8s-gerrit. I debugged resolving loose user refs with core.trustStat = after_open and found that we refresh the attributes of all the directories above a loose ref by opening an inputstream but we don't do this on the loose ref itself. It looks like this could cause the issue we observed. In the example I debugged it was the user ref refs/users/00/10000000 and I found that the attributes of the directories refs/ refs/users/ refs/users/00 were refreshed but the loose ref itself refs/users/00/10000000 was not refreshed. Fix this by also opening the ref's file itself if refreshing its parent directories succeeded. Change-Id: I37aaca2a1f448ca9a1caa325a0c18952cc023121
1 parent a17c4aa commit f23d73e

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,7 @@ class LooseItems {
13201320
* path of a loose ref relative to the repository root
13211321
*/
13221322
void refreshPathToLooseRef(Path refPath) {
1323+
boolean failed = false;
13231324
for (int i = 1; i < refPath.getNameCount(); i++) {
13241325
File dir = fileFor(refPath.subpath(0, i).toString());
13251326
// Use Files.newInputStream(Path) as it is consistent with other
@@ -1328,7 +1329,16 @@ void refreshPathToLooseRef(Path refPath) {
13281329
try (InputStream stream = Files.newInputStream(dir.toPath())) {
13291330
// open the dir to refresh attributes (on some NFS clients)
13301331
} catch (IOException e) {
1331-
break; // loose ref may not exist
1332+
failed = true;
1333+
break; // directory may not exist
1334+
}
1335+
}
1336+
if (!failed) {
1337+
try (InputStream stream = Files.newInputStream(refPath)) {
1338+
// open the loose ref to refresh attributes (on some NFS
1339+
// clients)
1340+
} catch (IOException e) {
1341+
// loose ref may not exist
13321342
}
13331343
}
13341344
}

0 commit comments

Comments
 (0)