Skip to contentSkip to conversation

gc warnings lock bitbake server

DISCUSSION Richard Purdie 2 participants 3 messages Apr 4, 2022

lore
Share & tools
lore
#0 lore raw

I noticed yet another hung oe-selftest on the autobuilder with memres bitbake enabled. I was able to log into the system and backtrace the hung bitbake process (gdb -p <pid>, then py-bt). The result was the trace below. Basically it shows python doing garbage collection within our locked critical section in the event handler.

The cause of the issue is a warning message being thrown up by gc for an unclosed asyncio event loop. I have patches in progress to try and fix that event loop issue but this does show that warnings triggered by gc are painful for us and we need to address that.

Ahhrg :)

Cheers,

Richard

Traceback (most recent call first):
File "/usr/lib/python3.9/multiprocessing/synchronize.py", line 95, in __enter__

    return self._semlock.__enter__()
  File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 742, in _send
    with self.wlock:
  File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 761, in send
    self._send(obj)

File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/event.py", line 199, in fire_ui_handlers
_ui_handlers[h].event.send(event)
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/event.py", line 226, in fire
fire_ui_handlers(event, d)
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/event.py", line 758, in emit
fire(record, None)
File "/usr/lib/python3.9/logging/__init__.py", line 948, in handle
self.emit(record)
File "/usr/lib/python3.9/logging/__init__.py", line 1657, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.9/logging/__init__.py", line 1595, in handle
self.callHandlers(record)
File "/usr/lib/python3.9/logging/__init__.py", line 1841, in _log

File "/usr/lib/python3.9/logging/__init__.py", line 1454, in warning
self._log(WARNING, msg, args, **kwargs)
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/main.py", line 112, in _showwarning
warnlog.warning(s)
File "/usr/lib/python3.9/warnings.py", line 365, in _showwarnmsg
# "file" is actually in a zipfile or something.
<built-in method warn of module object at remote 0x7f79d2762090>
File "/usr/lib/python3.Traceback (most recent call first):
File "/usr/lib/python3.9/multiprocessing/synchronize.py", line 95, in
__enter__

    return self._semlock.__enter__()

File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 742, in _send
with self.wlock:
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 761, in send

    self._send(obj)

File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/event.py", line 199, in fire_ui_handlers
_ui_handlers[h].event.send(event)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/event.py", line 226, in fire
fire_ui_handlers(event, d)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/event.py", line 758, in emit
fire(record, None)
File "/usr/lib/python3.9/logging/__init__.py", line 948, in handle
self.emit(record)
File "/usr/lib/python3.9/logging/__init__.py", line 1657, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.9/logging/__init__.py", line 1595, in handle
self.callHandlers(record)
File "/usr/lib/python3.9/logging/__init__.py", line 1841, in _log

File "/usr/lib/python3.9/logging/__init__.py", line 1454, in warning
self._log(WARNING, msg, args, **kwargs)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/main.py", line 112, in _showwarning
warnlog.warning(s)
File "/usr/lib/python3.9/warnings.py", line 365, in _showwarnmsg
# "file" is actually in a zipfile or something.
<built-in method warn of module object at remote 0x7f79d2762090> File "/usr/lib/python3.9/asyncio/base_events.py", line 681, in __del__
_warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
Garbage-collecting
File "/usr/lib/python3.9/multiprocessing/connection.py", line 205, in
send_bytes
self._send_bytes(m[offset:offset + size])
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 743, in _send
self.writer.send_bytes(obj)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 761, in send

    self._send(obj)

File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/event.py", line 199, in fire_ui_handlers
_ui_handlers[h].event.send(event)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/event.py", line 226, in fire
fire_ui_handlers(event, d)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/cache.py", line 1017, in progress
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/cache.py", line 478, in load_cachefile
progress(cachefile.tell() + previous_progress)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/cache.py", line 398, in prepare_cache
loaded = self.load_cachefile(progress)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/cache.py", line 780, in __init__

    loaded += c.prepare_cache(progress)

File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/cooker.py", line 2186, in __init__
self.bb_caches = bb.cache.MulticonfigCache(self.cfgbuilder, self.cfghash,
cooker.caches_array)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/cooker.py", line 1691, in updateCache
self.parser = CookerParser(self, mcfilelist, total_masked)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/command.py", line 123, in runAsyncCommand
self.cooker.updateCache()
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/cooker.py", line 562, in runCommands
return self.command.runAsyncCommand()
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 342, in idle_commands
retval = function(self, data, False)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 501, in main
if lines:
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 110, in run
ret = self.main()
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 814, in execServer
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/bin/bitbake-server", line 52, in <module>
bb.server.process.execServer(lockfd, readypipeinfd, lockname, sockname, timeout, xmlrpcinterface)9/asyncio/base_events.py", line 681, in __del__ _warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
Garbage-collecting
File "/usr/lib/python3.9/multiprocessing/connection.py", line 205, in send_bytes
self._send_bytes(m[offset:offset + size])
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 743, in _send
self.writer.send_bytes(obj)
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 761, in send

    self._send(obj)
  File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/event.py", line 199, in fire_ui_handlers
    _ui_handlers[h].event.send(event)
  File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/event.py", line 226, in fire
    fire_ui_handlers(event, d)
  File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/cache.py", line 1017, in progress
  File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/cache.py", line 478, in load_cachefile
    progress(cachefile.tell() + previous_progress)
  File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/cache.py", line 398, in prepare_cache
    loaded = self.load_cachefile(progress)
  File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/cache.py", line 780, in __init__
    loaded += c.prepare_cache(progress)

File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/cooker.py", line 2186, in __init__
self.bb_caches = bb.cache.MulticonfigCache(self.cfgbuilder, self.cfghash, cooker.caches_array)
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/cooker.py", line 1691, in updateCache
self.parser = CookerParser(self, mcfilelist, total_masked)
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/command.py", line 123, in runAsyncCommand
self.cooker.updateCache()
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/cooker.py", line 562, in runCommands
return self.command.runAsyncCommand()
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 342, in idle_commands
retval = function(self, data, False)
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 501, in main
if lines:
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 110, in run
ret = self.main()
File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 814, in execServer File "/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/bin/bitbake-server", line 52, in <module>
bb.server.process.execServer(lockfd, readypipeinfd, lockname, sockname, timeout, xmlrpcinterface)

#1 lore raw
Quoted 9 lines · Richard Purdie

I noticed yet another hung oe-selftest on the autobuilder with memres bitbake
enabled. I was able to log into the system and backtrace the hung bitbake process (gdb -p <pid>, then py-bt). The result was the trace below. Basically it
shows python doing garbage collection within our locked critical section in the
event handler.

Quoted 6 lines

The cause of the issue is a warning message being thrown up by gc for an unclosed asyncio event loop. I have patches in progress to try and fix that event loop issue but this does show that warnings triggered by gc are painful
for us and we need to address that.

Nice find. So IIRC, there are two issues: The first is that asyncio is creating a lot of warnings, and the second is that warnings from the garbage collector can deadlock bitbake?

Quoted 216 lines

Ahhrg :)

Cheers,

Richard

Traceback (most recent call first):
File "/usr/lib/python3.9/multiprocessing/synchronize.py", line 95, in
__enter__

    return self._semlock.__enter__()

File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 742, in _send
with self.wlock:
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 761, in send

    self._send(obj)

File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/event.py", line 199, in fire_ui_handlers
_ui_handlers[h].event.send(event)
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/event.py", line 226, in fire
fire_ui_handlers(event, d)
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/event.py", line 758, in emit
fire(record, None)
File "/usr/lib/python3.9/logging/__init__.py", line 948, in handle
self.emit(record)
File "/usr/lib/python3.9/logging/__init__.py", line 1657, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.9/logging/__init__.py", line 1595, in handle
self.callHandlers(record)
File "/usr/lib/python3.9/logging/__init__.py", line 1841, in _log

File "/usr/lib/python3.9/logging/__init__.py", line 1454, in warning
self._log(WARNING, msg, args, **kwargs)
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/main.py", line 112, in _showwarning
warnlog.warning(s)
File "/usr/lib/python3.9/warnings.py", line 365, in _showwarnmsg
# "file" is actually in a zipfile or something.
<built-in method warn of module object at remote 0x7f79d2762090> File "/usr/lib/python3.Traceback (most recent call first):
File "/usr/lib/python3.9/multiprocessing/synchronize.py", line 95, in
__enter__

    return self._semlock.__enter__()

File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 742, in _send
with self.wlock:
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 761, in send

    self._send(obj)

File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/event.py", line 199, in fire_ui_handlers
_ui_handlers[h].event.send(event)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/event.py", line 226, in fire
fire_ui_handlers(event, d)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/event.py", line 758, in emit
fire(record, None)
File "/usr/lib/python3.9/logging/__init__.py", line 948, in handle
self.emit(record)
File "/usr/lib/python3.9/logging/__init__.py", line 1657, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.9/logging/__init__.py", line 1595, in handle
self.callHandlers(record)
File "/usr/lib/python3.9/logging/__init__.py", line 1841, in _log

File "/usr/lib/python3.9/logging/__init__.py", line 1454, in warning
self._log(WARNING, msg, args, **kwargs)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/main.py", line 112, in _showwarning
warnlog.warning(s)
File "/usr/lib/python3.9/warnings.py", line 365, in _showwarnmsg
# "file" is actually in a zipfile or something.
<built-in method warn of module object at remote 0x7f79d2762090> File "/usr/lib/python3.9/asyncio/base_events.py", line 681, in __del__
_warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
Garbage-collecting
File "/usr/lib/python3.9/multiprocessing/connection.py", line 205, in
send_bytes
self._send_bytes(m[offset:offset + size])
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 743, in _send
self.writer.send_bytes(obj)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 761, in send

    self._send(obj)

File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/event.py", line 199, in fire_ui_handlers
_ui_handlers[h].event.send(event)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/event.py", line 226, in fire
fire_ui_handlers(event, d)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/cache.py", line 1017, in progress
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/cache.py", line 478, in load_cachefile
progress(cachefile.tell() + previous_progress)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/cache.py", line 398, in prepare_cache
loaded = self.load_cachefile(progress)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/cache.py", line 780, in __init__

    loaded += c.prepare_cache(progress)

File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/cooker.py", line 2186, in __init__
self.bb_caches = bb.cache.MulticonfigCache(self.cfgbuilder,
self.cfghash,
cooker.caches_array)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/cooker.py", line 1691, in updateCache
self.parser = CookerParser(self, mcfilelist, total_masked)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/command.py", line 123, in runAsyncCommand
self.cooker.updateCache()
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/cooker.py", line 562, in runCommands
return self.command.runAsyncCommand()
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 342, in idle_commands
retval = function(self, data, False)
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 501, in main
if lines:
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 110, in run
ret = self.main()
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/lib/bb/server/process.py", line 814, in execServer
File "/home/pokybuild/yocto-worker/oe-selftest-
debian/build/bitbake/bin/bitbake-server", line 52, in <module>
bb.server.process.execServer(lockfd, readypipeinfd, lockname,
sockname, timeout, xmlrpcinterface)9/asyncio/base_events.py", line 681, in __del__
_warn(f"unclosed event loop {self!r}", ResourceWarning, source=self)
Garbage-collecting
File "/usr/lib/python3.9/multiprocessing/connection.py", line 205, in
send_bytes
self._send_bytes(m[offset:offset + size])
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 743, in _send
self.writer.send_bytes(obj)
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 761, in send

    self._send(obj)

File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/event.py", line 199, in fire_ui_handlers
_ui_handlers[h].event.send(event)
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/event.py", line 226, in fire
fire_ui_handlers(event, d)
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/cache.py", line 1017, in progress
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/cache.py", line 478, in load_cachefile
progress(cachefile.tell() + previous_progress)
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/cache.py", line 398, in prepare_cache
loaded = self.load_cachefile(progress)
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/cache.py", line 780, in __init__

    loaded += c.prepare_cache(progress)

File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/cooker.py", line 2186, in __init__
self.bb_caches = bb.cache.MulticonfigCache(self.cfgbuilder,
self.cfghash, cooker.caches_array)
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/cooker.py", line 1691, in updateCache
self.parser = CookerParser(self, mcfilelist, total_masked)
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/command.py", line 123, in runAsyncCommand
self.cooker.updateCache()
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/cooker.py", line 562, in runCommands
return self.command.runAsyncCommand()
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 342, in idle_commands
retval = function(self, data, False)
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 501, in main
if lines:
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 110, in run
ret = self.main()
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/lib/bb/server/process.py", line 814, in execServer
File
"/home/pokybuild/yocto-worker/oe-selftest-debian/build/bitbake/bin/bitbake-server", line 52, in <module>
bb.server.process.execServer(lockfd, readypipeinfd, lockname,
sockname, timeout, xmlrpcinterface)

#2 lore raw
Quoted 20 lines · Joshua Watt
Quoted 10 lines · Richard Purdie

I noticed yet another hung oe-selftest on the autobuilder with memres bitbake
enabled. I was able to log into the system and backtrace the hung bitbake process (gdb -p <pid>, then py-bt). The result was the trace below. Basically
it
shows python doing garbage collection within our locked critical section in the
event handler.

Quoted 5 lines

The cause of the issue is a warning message being thrown up by gc for an unclosed asyncio event loop. I have patches in progress to try and fix that event loop issue but this does show that warnings triggered by gc are painful
for us and we need to address that.

Quoted 3 lines

Nice find. So IIRC, there are two issues: The first is that asyncio is creating a lot of warnings, and the second is that warnings from the garbage collector can deadlock bitbake?

Yes, exactly. I've added couple of patches to master-next to try and address this. One disables gc when we're taking the lock. The other tries to stop the asyncio event loop issue as I think I spotted where we leak it.

Unfortunately -next is showing an inotify issue now which doesn't make any sense :/

Cheers,

Richard