diff options
author | Kuang-che Wu <kcwu@google.com> | 2024-11-06 13:03:42 +0800 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-11-06 16:33:17 +0000 |
commit | ab2d3211043e2cb42a55f56e5abf69d23103c105 (patch) | |
tree | 205a34d3964b45661fe9660c6d9879d4b1a66e30 | |
parent | aada468916936d034a9ac0f0c1e5ebeebd7f3e87 (diff) | |
download | git-repo-ab2d3211043e2cb42a55f56e5abf69d23103c105.tar.gz |
sync: fix connection error on macOSv2.49.3
With a large number of sync workers, the sync process may fail on
macOS due to connection errors. The root cause is that multiple
workers may attempt to connect to the multiprocessing manager server
at the same time when handling the first job. This can lead to
connection failures if there are too many pending connections, exceeding
the socket listening backlog.
Bug: 377538810
Change-Id: I1924d318d076ca3be61d75daa37bfa8d7dc23ed7
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/441541
Tested-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
-rw-r--r-- | subcmds/sync.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index decf559b..8e4dde6b 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -821,6 +821,16 @@ later is required to fix a server side protocol bug. | |||
821 | jobs = jobs_str(len(items)) | 821 | jobs = jobs_str(len(items)) |
822 | return f"{jobs} | {elapsed_str(elapsed)} {earliest_proj}" | 822 | return f"{jobs} | {elapsed_str(elapsed)} {earliest_proj}" |
823 | 823 | ||
824 | @classmethod | ||
825 | def InitWorker(cls): | ||
826 | # Force connect to the manager server now. | ||
827 | # This is good because workers are initialized one by one. Without this, | ||
828 | # multiple workers may connect to the manager when handling the first | ||
829 | # job at the same time. Then the connection may fail if too many | ||
830 | # connections are pending and execeeded the socket listening backlog, | ||
831 | # especially on MacOS. | ||
832 | len(cls.get_parallel_context()["sync_dict"]) | ||
833 | |||
824 | def _Fetch(self, projects, opt, err_event, ssh_proxy, errors): | 834 | def _Fetch(self, projects, opt, err_event, ssh_proxy, errors): |
825 | ret = True | 835 | ret = True |
826 | 836 | ||
@@ -913,6 +923,7 @@ later is required to fix a server side protocol bug. | |||
913 | # idle while other workers still have more than one job in | 923 | # idle while other workers still have more than one job in |
914 | # their chunk queue. | 924 | # their chunk queue. |
915 | chunksize=1, | 925 | chunksize=1, |
926 | initializer=self.InitWorker, | ||
916 | ) | 927 | ) |
917 | finally: | 928 | finally: |
918 | sync_event.set() | 929 | sync_event.set() |