diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-12-08 17:29:49 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-12-09 13:22:11 +0000 |
commit | a9505a86fdcd789093732b800ba08e7a23c21070 (patch) | |
tree | 9f270d04c91a63865d6e02365b8208a02fc10baf /bitbake/lib/bb/server/process.py | |
parent | 8aa083f842cc54fb7c0ef3ff8724fed2dff40d66 (diff) | |
download | poky-a9505a86fdcd789093732b800ba08e7a23c21070.tar.gz |
bitbake: main/server: Add lockfile debugging upon server retry
We keep seeing server issues where the lockfile is present but we can't
connect to it. Reuse the lockfile debugging code from the server to
dump better information to the console from the client side when we
run into this issue. Whilst not pretty, this might give us a chance
of being able to debug the problems further.
(Bitbake rev: 22685460b5ecb1aeb4ff3436088ecdacb43044d7)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/server/process.py')
-rw-r--r-- | bitbake/lib/bb/server/process.py | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py index afd77ac0a5..f4ab80ba67 100644 --- a/bitbake/lib/bb/server/process.py +++ b/bitbake/lib/bb/server/process.py | |||
@@ -41,6 +41,35 @@ def serverlog(msg): | |||
41 | print(str(os.getpid()) + " " + datetime.datetime.now().strftime('%H:%M:%S.%f') + " " + msg) | 41 | print(str(os.getpid()) + " " + datetime.datetime.now().strftime('%H:%M:%S.%f') + " " + msg) |
42 | sys.stdout.flush() | 42 | sys.stdout.flush() |
43 | 43 | ||
44 | # | ||
45 | # When we have lockfile issues, try and find infomation about which process is | ||
46 | # using the lockfile | ||
47 | # | ||
48 | def get_lockfile_process_msg(lockfile): | ||
49 | # Some systems may not have lsof available | ||
50 | procs = None | ||
51 | try: | ||
52 | procs = subprocess.check_output(["lsof", '-w', lockfile], stderr=subprocess.STDOUT) | ||
53 | except subprocess.CalledProcessError: | ||
54 | # File was deleted? | ||
55 | pass | ||
56 | except OSError as e: | ||
57 | if e.errno != errno.ENOENT: | ||
58 | raise | ||
59 | if procs is None: | ||
60 | # Fall back to fuser if lsof is unavailable | ||
61 | try: | ||
62 | procs = subprocess.check_output(["fuser", '-v', lockfile], stderr=subprocess.STDOUT) | ||
63 | except subprocess.CalledProcessError: | ||
64 | # File was deleted? | ||
65 | pass | ||
66 | except OSError as e: | ||
67 | if e.errno != errno.ENOENT: | ||
68 | raise | ||
69 | if procs: | ||
70 | return procs.decode("utf-8") | ||
71 | return None | ||
72 | |||
44 | class ProcessServer(): | 73 | class ProcessServer(): |
45 | profile_filename = "profile.log" | 74 | profile_filename = "profile.log" |
46 | profile_processed_filename = "profile.log.processed" | 75 | profile_processed_filename = "profile.log.processed" |
@@ -306,30 +335,10 @@ class ProcessServer(): | |||
306 | return | 335 | return |
307 | 336 | ||
308 | if not lock: | 337 | if not lock: |
309 | # Some systems may not have lsof available | 338 | procs = get_lockfile_process_msg(lockfile) |
310 | procs = None | ||
311 | try: | ||
312 | procs = subprocess.check_output(["lsof", '-w', lockfile], stderr=subprocess.STDOUT) | ||
313 | except subprocess.CalledProcessError: | ||
314 | # File was deleted? | ||
315 | continue | ||
316 | except OSError as e: | ||
317 | if e.errno != errno.ENOENT: | ||
318 | raise | ||
319 | if procs is None: | ||
320 | # Fall back to fuser if lsof is unavailable | ||
321 | try: | ||
322 | procs = subprocess.check_output(["fuser", '-v', lockfile], stderr=subprocess.STDOUT) | ||
323 | except subprocess.CalledProcessError: | ||
324 | # File was deleted? | ||
325 | continue | ||
326 | except OSError as e: | ||
327 | if e.errno != errno.ENOENT: | ||
328 | raise | ||
329 | |||
330 | msg = ["Delaying shutdown due to active processes which appear to be holding bitbake.lock"] | 339 | msg = ["Delaying shutdown due to active processes which appear to be holding bitbake.lock"] |
331 | if procs: | 340 | if procs: |
332 | msg.append(":\n%s" % str(procs.decode("utf-8"))) | 341 | msg.append(":\n%s" % procs) |
333 | serverlog("".join(msg)) | 342 | serverlog("".join(msg)) |
334 | 343 | ||
335 | def idle_commands(self, delay, fds=None): | 344 | def idle_commands(self, delay, fds=None): |