mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-07-16 13:47:03 +00:00
sync: do not init sibling submodules in parallel
Initializing a submodule requires locking <parent>/.git/config. As the implementation was currently doing this in parallel for sibling submodules, it lead to a race condition causing intermittent errors like: error: could not lock config file .git/config: File exists This commit enforces that sibling submodules are initialized sequentially, eliminating the race condition. Change-Id: I5ffb3de90276ba43e262d0e279a3d34324220b63 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/591241 Tested-by: Josef Malmstrom <Josef.Malmstrom@arm.com> Commit-Queue: Josef Malmstrom <Josef.Malmstrom@arm.com> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com>
This commit is contained in:
committed by
gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com
parent
d9d86fb595
commit
4b462634e0
@@ -340,6 +340,7 @@ class FakeProject:
|
||||
self.name = name or relpath
|
||||
self.objdir = objdir or relpath
|
||||
self.worktree = relpath
|
||||
self.parent = None
|
||||
|
||||
self.use_git_worktrees = False
|
||||
self.UseAlternates = False
|
||||
@@ -397,6 +398,65 @@ class SafeCheckoutOrder(unittest.TestCase):
|
||||
],
|
||||
)
|
||||
|
||||
def test_sibling_submodules_with_shared_parent_are_serialized(self):
|
||||
parent = mock.Mock(worktree="/worktree/parent")
|
||||
other_parent = mock.Mock(worktree="/worktree/other")
|
||||
p_parent = FakeProject("parent")
|
||||
p_other = FakeProject("other")
|
||||
p_parent_sub1 = FakeProject("parent/sub1")
|
||||
p_parent_sub1.parent = parent
|
||||
p_parent_sub2 = FakeProject("parent/sub2")
|
||||
p_parent_sub2.parent = parent
|
||||
p_other_sub = FakeProject("other/sub")
|
||||
p_other_sub.parent = other_parent
|
||||
|
||||
out = sync._SafeCheckoutOrder(
|
||||
[p_parent_sub2, p_other_sub, p_parent, p_parent_sub1, p_other]
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
out,
|
||||
[
|
||||
[p_other, p_parent],
|
||||
[p_other_sub, p_parent_sub1],
|
||||
[p_parent_sub2],
|
||||
],
|
||||
)
|
||||
|
||||
def test_nested_submodules_respect_delayed_parent_level(self):
|
||||
parent = mock.Mock(worktree="/worktree/parent")
|
||||
sub1 = mock.Mock(worktree="/worktree/parent/sub1")
|
||||
sub2 = mock.Mock(worktree="/worktree/parent/sub2")
|
||||
p_parent = FakeProject("parent")
|
||||
p_parent_sub1 = FakeProject("parent/sub1")
|
||||
p_parent_sub1.parent = parent
|
||||
p_parent_sub1_nested = FakeProject("parent/sub1/nested")
|
||||
p_parent_sub1_nested.parent = sub1
|
||||
p_parent_sub2 = FakeProject("parent/sub2")
|
||||
p_parent_sub2.parent = parent
|
||||
p_parent_sub2_nested = FakeProject("parent/sub2/nested")
|
||||
p_parent_sub2_nested.parent = sub2
|
||||
|
||||
out = sync._SafeCheckoutOrder(
|
||||
[
|
||||
p_parent_sub2_nested,
|
||||
p_parent_sub2,
|
||||
p_parent_sub1_nested,
|
||||
p_parent,
|
||||
p_parent_sub1,
|
||||
]
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
out,
|
||||
[
|
||||
[p_parent],
|
||||
[p_parent_sub1],
|
||||
[p_parent_sub1_nested, p_parent_sub2],
|
||||
[p_parent_sub2_nested],
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class Chunksize(unittest.TestCase):
|
||||
"""Tests for _chunksize."""
|
||||
|
||||
Reference in New Issue
Block a user