Skip to contentSkip to conversation

server/process: Disable the flush() call in server logging

PATCH Richard Purdie 2 participants 8 messages Sep 15, 2023 – Sep 18, 2023 6 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 19 lines · Richard Purdie via lists.openembedded.org

We've been chasing bitbake timeouts for a while and it was unclear where things were blocking on IO. It appears the flush() call in server logging can cause pauses up to minutes long on systems with slow (spinning) disks that are heavily loaded with IO.

Since the flush() was added to aid debugging of other timing issues, we shouldn't need it now and it can be disabled. Leave a comment as a reminder of the pain this can cause.

---
 lib/bb/server/process.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/bb/server/process.py +0 -0
index 40cb99bc97..94e93bc3a6 100644

lib/bb/server/process.py def currenttime(): · line 50

Quoted 9 lines
lib/bb/server/process.py +2 -1
@@ -43,7 +43,8 @@ def currenttime():
 
 def serverlog(msg):
     print(str(os.getpid()) + " " +  currenttime() + " " + msg)
-    sys.stdout.flush()
+    #Seems a flush here triggers filesytem sync like behaviour and long hangs in the server
+    #sys.stdout.flush()
 
 #
 # When we have lockfile issues, try and find infomation about which process is

Whilst this patch looks simple, it has all the signs of turning into weeks of pain after looking at the results from testing. It looks like we have a race in the system which this flush is masking.

https://autobuilder.yoctoproject.org/typhoon/#/builders/127/builds/2082/steps/14/logs/stdio

Looking at just one of the failures there (of the 6), we see this test pass:

1: 20/57 355/537 (0.12s) (0 failed) (recipetool.RecipetoolTests.test_recipetool_split_pkg_licenses)

then the next test to run on that build directory is:

1: 21/57 359/537 (137.64s) (0 failed) (signing.Signing.test_signing_packages)

with an error which boils down to:

FileNotFoundError: [Errno 2] No such file or directory: '/tmp/recipetoolqaizvjzf8h'

from

run(cmd='git rev-parse --abbrev-ref HEAD', input=None, log=None, extrafiles=[], **options={'cwd': '/tmp/recipetoolqaizvjzf8h', 'shell': True})

i.e. it is trying to run a command in a directory which doesn't exist.

Without looking, I know "recipetoolqa" tmpfiles will come from RecipetoolTests so the previous build directory is being removed and yet still is cwd for the server.

I've not looked much into any of the other failures yet.

Looking at the 5 different selftest failures:

https://autobuilder.yoctoproject.org/typhoon/#/builders/127/builds/2082/steps/14/logs/stdio

2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS - archiver.Archiver.test_archiver_srpm_mode: FAILED (237.00s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS - overlayfs.OverlayFSEtcRunTimeTests.test_all_required_variables_set: FAILED (13.25s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS - prservice.BitbakePrTests.test_pr_service_deb_arch_dep: FAILED (126.30s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS - signing.Signing.test_signing_packages: FAILED (137.64s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS - sstatetests.SStateHashSameSigs.test_sstate_32_64_same_hash: FAILED (541.51s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS - sstatetests.SStateHashSameSigs3.test_sstate_multilib_or_not_native_samesigs: FAILED (224.05s)

https://autobuilder.yoctoproject.org/typhoon/#/builders/80/builds/5710/steps/14/logs/stdio

2023-09-14 16:00:20,642 - oe-selftest - INFO - RESULTS - archiver.Archiver.test_archiver_srpm_mode: FAILED (59.78s)
2023-09-14 16:00:20,642 - oe-selftest - INFO - RESULTS - bblogging.BitBakeLogging.test_shell_loggingA: FAILED (15.71s)
2023-09-14 16:00:20,642 - oe-selftest - INFO - RESULTS - multiconfig.MultiConfig.test_multiconfig_reparse: FAILED (6.39s)
2023-09-14 16:00:20,642 - oe-selftest - INFO - RESULTS - prservice.BitbakePrTests.test_pr_service_rpm_arch_indep: FAILED (0.84s)

https://autobuilder.yoctoproject.org/typhoon/#/builders/86/builds/5746/steps/14/logs/stdio

2023-09-14 23:33:02,720 - oe-selftest - INFO - RESULTS - package.VersionOrdering.test_dpkg: ERROR
2023-09-14 23:33:02,720 - oe-selftest - INFO - RESULTS - package.VersionOrdering.test_opkg: ERROR
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS - package.VersionOrdering.test_rpm: ERROR
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS - archiver.Archiver.test_archiver_srpm_mode: FAILED (129.04s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS - bbtests.BitbakeTests.test_postfile: FAILED (2.06s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS - bbtests.BitbakeTests.test_prefile: FAILED (1.73s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS - devtool.DevtoolModifyTests.test_devtool_buildclean: FAILED (265.26s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS - overlayfs.OverlayFSTests.test_mount_unit_not_set: FAILED (7.83s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS - prservice.BitbakePrTests.test_import_export_override_db: FAILED (289.85s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS - sstatetests.SStateHashSameSigs3.test_sstate_multilib_or_not_native_samesigs: FAILED (111.34s)

https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/5757/steps/15/logs/stdio

2023-09-14 22:55:12,332 - oe-selftest - INFO - RESULTS - bblogging.BitBakeLogging.test_python_exec_func_python_loggingB: FAILED (100.76s)

https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/5777/steps/14/logs/stdio

2023-09-14 23:00:48,622 - oe-selftest - INFO - RESULTS - archiver.Archiver.test_archiver_srpm_mode: FAILED (71.69s)
2023-09-14 23:00:48,622 - oe-selftest - INFO - RESULTS - prservice.BitbakePrTests.test_pr_service_deb_arch_dep: FAILED (27.14s)

so the failures are all over the place.

We also had a wic test failure that when re-ran, didn't reproduce:

https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/5777/steps/14/logs/stdio

and some toolchain test failures for qemuppc:

https://autobuilder.yoctoproject.org/typhoon/#/builders/153/builds/529

and qemuarm64:

https://autobuilder.yoctoproject.org/typhoon/#/builders/151/builds/530

The question at this point is what do people want me to do. We clearly have a really nasty bug in here. The patch is "right" and we do need to fix this. If I merge it, I suspect I'm going to end up having to chase this down before we can release and I am going to struggle to find the time to do it and I suspect my sanity will suffer. This does look to be a significant issue though.

Cheers,

Richard

#2 lore raw
Quoted 162 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Richard Purdie
Sent: den 15 september 2023 10:41
To: [email protected]; openembedded-architecture <[email protected]>
Cc: Philip Balister <[email protected]>
Subject: Re: [bitbake-devel] [PATCH] server/process: Disable the flush() call in server logging

Quoted 19 lines · Richard Purdie via lists.openembedded.org

We've been chasing bitbake timeouts for a while and it was unclear where things were blocking on IO. It appears the flush() call in server logging can cause pauses up to minutes long on systems with slow (spinning) disks that are heavily loaded with IO.

Since the flush() was added to aid debugging of other timing issues, we shouldn't need it now and it can be disabled. Leave a comment as a reminder of the pain this can cause.

---
 lib/bb/server/process.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/bb/server/process.py +0 -0
index 40cb99bc97..94e93bc3a6 100644

lib/bb/server/process.py def currenttime(): · line 50

Quoted 9 lines
lib/bb/server/process.py +2 -1
@@ -43,7 +43,8 @@ def currenttime():
 
 def serverlog(msg):
     print(str(os.getpid()) + " " +  currenttime() + " " + msg)
-    sys.stdout.flush()
+    #Seems a flush here triggers filesytem sync like behaviour and long hangs in the server
+    #sys.stdout.flush()
 
 #
 # When we have lockfile issues, try and find infomation about which process is

Whilst this patch looks simple, it has all the signs of turning into weeks of pain after looking at the results from testing. It looks like we have a race in the system which this flush is masking.

https://autobuilder.yoctoproject.org/typhoon/#/builders/127/builds/2082/steps/14/logs/stdio

Looking at just one of the failures there (of the 6), we see this test pass:

1: 20/57 355/537 (0.12s) (0 failed) (recipetool.RecipetoolTests.test_recipetool_split_pkg_licenses)

then the next test to run on that build directory is:

1: 21/57 359/537 (137.64s) (0 failed)
(signing.Signing.test_signing_packages)

with an error which boils down to:

FileNotFoundError: [Errno 2] No such file or directory:
'/tmp/recipetoolqaizvjzf8h'

from

run(cmd='git rev-parse --abbrev-ref HEAD', input=None, log=None, extrafiles=[], **options={'cwd': '/tmp/recipetoolqaizvjzf8h', 'shell':
True})

i.e. it is trying to run a command in a directory which doesn't exist.

Without looking, I know "recipetoolqa" tmpfiles will come from RecipetoolTests so the previous build directory is being removed and yet still is cwd for the server.

I've not looked much into any of the other failures yet.

Looking at the 5 different selftest failures:

https://autobuilder.yoctoproject.org/typhoon/#/builders/127/builds/2082/steps/14/logs/stdio

2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS -
archiver.Archiver.test_archiver_srpm_mode: FAILED (237.00s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS -
overlayfs.OverlayFSEtcRunTimeTests.test_all_required_variables_set: FAILED
(13.25s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS -
prservice.BitbakePrTests.test_pr_service_deb_arch_dep: FAILED (126.30s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS -
signing.Signing.test_signing_packages: FAILED (137.64s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS -
sstatetests.SStateHashSameSigs.test_sstate_32_64_same_hash: FAILED
(541.51s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS -

sstatetests.SStateHashSameSigs3.test_sstate_multilib_or_not_native_samesig
s: FAILED (224.05s)

https://autobuilder.yoctoproject.org/typhoon/#/builders/80/builds/5710/steps/14/logs/stdio

2023-09-14 16:00:20,642 - oe-selftest - INFO - RESULTS -
archiver.Archiver.test_archiver_srpm_mode: FAILED (59.78s)
2023-09-14 16:00:20,642 - oe-selftest - INFO - RESULTS -
bblogging.BitBakeLogging.test_shell_loggingA: FAILED (15.71s)
2023-09-14 16:00:20,642 - oe-selftest - INFO - RESULTS -
multiconfig.MultiConfig.test_multiconfig_reparse: FAILED (6.39s)
2023-09-14 16:00:20,642 - oe-selftest - INFO - RESULTS -

prservice.BitbakePrTests.test_pr_service_rpm_arch_indep: FAILED (0.84s)

https://autobuilder.yoctoproject.org/typhoon/#/builders/86/builds/5746/steps/14/logs/stdio

2023-09-14 23:33:02,720 - oe-selftest - INFO - RESULTS -
package.VersionOrdering.test_dpkg: ERROR
2023-09-14 23:33:02,720 - oe-selftest - INFO - RESULTS -
package.VersionOrdering.test_opkg: ERROR
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -
package.VersionOrdering.test_rpm: ERROR
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -
archiver.Archiver.test_archiver_srpm_mode: FAILED (129.04s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -
bbtests.BitbakeTests.test_postfile: FAILED (2.06s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -
bbtests.BitbakeTests.test_prefile: FAILED (1.73s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -
devtool.DevtoolModifyTests.test_devtool_buildclean: FAILED (265.26s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -
overlayfs.OverlayFSTests.test_mount_unit_not_set: FAILED (7.83s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -
prservice.BitbakePrTests.test_import_export_override_db: FAILED (289.85s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -

sstatetests.SStateHashSameSigs3.test_sstate_multilib_or_not_native_samesig
s: FAILED (111.34s)

https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/5757/steps/15/logs/stdio

2023-09-14 22:55:12,332 - oe-selftest - INFO - RESULTS -

bblogging.BitBakeLogging.test_python_exec_func_python_loggingB: FAILED (100.76s)

https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/5777/steps/14/logs/stdio

2023-09-14 23:00:48,622 - oe-selftest - INFO - RESULTS -
archiver.Archiver.test_archiver_srpm_mode: FAILED (71.69s)
2023-09-14 23:00:48,622 - oe-selftest - INFO - RESULTS -

prservice.BitbakePrTests.test_pr_service_deb_arch_dep: FAILED (27.14s)

so the failures are all over the place.

We also had a wic test failure that when re-ran, didn't reproduce:

https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/5777/steps/14/logs/stdio

and some toolchain test failures for qemuppc:

https://autobuilder.yoctoproject.org/typhoon/#/builders/153/builds/529

and qemuarm64:

https://autobuilder.yoctoproject.org/typhoon/#/builders/151/builds/530

The question at this point is what do people want me to do. We clearly have a really nasty bug in here. The patch is "right" and we do need to fix this. If I merge it, I suspect I'm going to end up having to chase this down before we can release and I am going to struggle to find the time to do it and I suspect my sanity will suffer. This does look to be a significant issue though.

Quoted 3 lines

Cheers,

Richard

While the problem the patch tried to fix is real, it seems a lot less problematic than the result of applying the patch. So from a release perspective, I would keep the current code and possibly add it as a known bug to the release notes. Then, after the release is out, start the work of solving the fallout from applying the patch, with the intention to have it solved for the first point release of Nanbield.

While not ideal, it sounds a lot less stressful than applying the patch at this stage.

//Peter

#3 lore raw
Quoted 10 lines · Peter Kjellerstedt

While the problem the patch tried to fix is real, it seems a lot less problematic than the result of applying the patch. So from a release perspective, I would keep the current code and possibly add it as a known bug to the release notes. Then, after the release is out, start the work of solving the fallout from applying the patch, with the intention to have it solved for the first point release of Nanbield.

While not ideal, it sounds a lot less stressful than applying the patch at this stage.

My concern is the cache coherency issues this exposes.

The 'easy' fix for release is explicit os.sync() calls in most command paths (everything except ping).

I'm not sure I should really allow such a patch through review though as it would raise a lot of serious questions and the underlying issues need to be addressed.

Cheers,

Richard

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 174 lines · Philip Balister
Quoted 173 lines · Peter Kjellerstedt
Quoted 162 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of Richard Purdie
Sent: den 15 september 2023 10:41
To: [email protected]; openembedded-architecture <[email protected]>
Cc: Philip Balister <[email protected]>
Subject: Re: [bitbake-devel] [PATCH] server/process: Disable the flush() call in server logging

Quoted 19 lines · Richard Purdie via lists.openembedded.org

We've been chasing bitbake timeouts for a while and it was unclear where things were blocking on IO. It appears the flush() call in server logging can cause pauses up to minutes long on systems with slow (spinning) disks that are heavily loaded with IO.

Since the flush() was added to aid debugging of other timing issues, we shouldn't need it now and it can be disabled. Leave a comment as a reminder of the pain this can cause.

---
  lib/bb/server/process.py | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
lib/bb/server/process.py +0 -0
index 40cb99bc97..94e93bc3a6 100644

lib/bb/server/process.py def currenttime(): · line 50

Quoted 9 lines
lib/bb/server/process.py +2 -1
@@ -43,7 +43,8 @@ def currenttime():
 
  def serverlog(msg):
      print(str(os.getpid()) + " " +  currenttime() + " " + msg)
-    sys.stdout.flush()
+    #Seems a flush here triggers filesytem sync like behaviour and long hangs in the server
+    #sys.stdout.flush()
 
  #
  # When we have lockfile issues, try and find infomation about which process is

Whilst this patch looks simple, it has all the signs of turning into weeks of pain after looking at the results from testing. It looks like we have a race in the system which this flush is masking.

https://autobuilder.yoctoproject.org/typhoon/#/builders/127/builds/2082/steps/14/logs/stdio

Looking at just one of the failures there (of the 6), we see this test pass:

1: 20/57 355/537 (0.12s) (0 failed) (recipetool.RecipetoolTests.test_recipetool_split_pkg_licenses)

then the next test to run on that build directory is:

1: 21/57 359/537 (137.64s) (0 failed)
(signing.Signing.test_signing_packages)

with an error which boils down to:

FileNotFoundError: [Errno 2] No such file or directory:
'/tmp/recipetoolqaizvjzf8h'

from

run(cmd='git rev-parse --abbrev-ref HEAD', input=None, log=None, extrafiles=[], **options={'cwd': '/tmp/recipetoolqaizvjzf8h', 'shell':
True})

i.e. it is trying to run a command in a directory which doesn't exist.

Without looking, I know "recipetoolqa" tmpfiles will come from RecipetoolTests so the previous build directory is being removed and yet still is cwd for the server.

I've not looked much into any of the other failures yet.

Looking at the 5 different selftest failures:

https://autobuilder.yoctoproject.org/typhoon/#/builders/127/builds/2082/steps/14/logs/stdio

2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS -
archiver.Archiver.test_archiver_srpm_mode: FAILED (237.00s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS -
overlayfs.OverlayFSEtcRunTimeTests.test_all_required_variables_set: FAILED
(13.25s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS -
prservice.BitbakePrTests.test_pr_service_deb_arch_dep: FAILED (126.30s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS -
signing.Signing.test_signing_packages: FAILED (137.64s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS -
sstatetests.SStateHashSameSigs.test_sstate_32_64_same_hash: FAILED
(541.51s)
2023-09-15 01:56:12,685 - oe-selftest - INFO - RESULTS -

sstatetests.SStateHashSameSigs3.test_sstate_multilib_or_not_native_samesig
s: FAILED (224.05s)

https://autobuilder.yoctoproject.org/typhoon/#/builders/80/builds/5710/steps/14/logs/stdio

2023-09-14 16:00:20,642 - oe-selftest - INFO - RESULTS -
archiver.Archiver.test_archiver_srpm_mode: FAILED (59.78s)
2023-09-14 16:00:20,642 - oe-selftest - INFO - RESULTS -
bblogging.BitBakeLogging.test_shell_loggingA: FAILED (15.71s)
2023-09-14 16:00:20,642 - oe-selftest - INFO - RESULTS -
multiconfig.MultiConfig.test_multiconfig_reparse: FAILED (6.39s)
2023-09-14 16:00:20,642 - oe-selftest - INFO - RESULTS -

prservice.BitbakePrTests.test_pr_service_rpm_arch_indep: FAILED (0.84s)

https://autobuilder.yoctoproject.org/typhoon/#/builders/86/builds/5746/steps/14/logs/stdio

2023-09-14 23:33:02,720 - oe-selftest - INFO - RESULTS -
package.VersionOrdering.test_dpkg: ERROR
2023-09-14 23:33:02,720 - oe-selftest - INFO - RESULTS -
package.VersionOrdering.test_opkg: ERROR
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -
package.VersionOrdering.test_rpm: ERROR
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -
archiver.Archiver.test_archiver_srpm_mode: FAILED (129.04s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -
bbtests.BitbakeTests.test_postfile: FAILED (2.06s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -
bbtests.BitbakeTests.test_prefile: FAILED (1.73s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -
devtool.DevtoolModifyTests.test_devtool_buildclean: FAILED (265.26s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -
overlayfs.OverlayFSTests.test_mount_unit_not_set: FAILED (7.83s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -
prservice.BitbakePrTests.test_import_export_override_db: FAILED (289.85s)
2023-09-14 23:33:02,721 - oe-selftest - INFO - RESULTS -

sstatetests.SStateHashSameSigs3.test_sstate_multilib_or_not_native_samesig
s: FAILED (111.34s)

https://autobuilder.yoctoproject.org/typhoon/#/builders/79/builds/5757/steps/15/logs/stdio

2023-09-14 22:55:12,332 - oe-selftest - INFO - RESULTS -

bblogging.BitBakeLogging.test_python_exec_func_python_loggingB: FAILED (100.76s)

https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/5777/steps/14/logs/stdio

2023-09-14 23:00:48,622 - oe-selftest - INFO - RESULTS -
archiver.Archiver.test_archiver_srpm_mode: FAILED (71.69s)
2023-09-14 23:00:48,622 - oe-selftest - INFO - RESULTS -

prservice.BitbakePrTests.test_pr_service_deb_arch_dep: FAILED (27.14s)

so the failures are all over the place.

We also had a wic test failure that when re-ran, didn't reproduce:

https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/5777/steps/14/logs/stdio

and some toolchain test failures for qemuppc:

https://autobuilder.yoctoproject.org/typhoon/#/builders/153/builds/529

and qemuarm64:

https://autobuilder.yoctoproject.org/typhoon/#/builders/151/builds/530

The question at this point is what do people want me to do. We clearly have a really nasty bug in here. The patch is "right" and we do need to fix this. If I merge it, I suspect I'm going to end up having to chase this down before we can release and I am going to struggle to find the time to do it and I suspect my sanity will suffer. This does look to be a significant issue though.

Quoted 3 lines

Cheers,

Richard

While the problem the patch tried to fix is real, it seems a lot less problematic than the result of applying the patch. So from a release perspective, I would keep the current code and possibly add it as a known bug to the release notes. Then, after the release is out, start the work of solving the fallout from applying the patch, with the intention to have it solved for the first point release of Nanbield.

Quoted 5 lines
Quoted 2 lines

While not ideal, it sounds a lot less stressful than applying the patch at this stage.

I understand this exposes some "interesting" issues, but I tend to agree with Peter here.

This is a 'bit' more than "interesting". If we ignore this, pretty much every bitbake failure will be blamed on "the cache problem" and we'll develop a reputation for reliability issues :(.

The damage this issue can do is scary even if I doubt most users would hit it.

Cheers,

Richard

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 12 lines · Richard Purdie via lists.openembedded.org
Quoted 10 lines · Peter Kjellerstedt

While the problem the patch tried to fix is real, it seems a lot less problematic than the result of applying the patch. So from a release perspective, I would keep the current code and possibly add it as a known bug to the release notes. Then, after the release is out, start the work of solving the fallout from applying the patch, with the intention to have it solved for the first point release of Nanbield.

While not ideal, it sounds a lot less stressful than applying the patch at this stage.

Quoted 8 lines

My concern is the cache coherency issues this exposes.

The 'easy' fix for release is explicit os.sync() calls in most command paths (everything except ping).

I'm not sure I should really allow such a patch through review though as it would raise a lot of serious questions and the underlying issues need to be addressed.

Just to follow up with where I got to with this.

The problem is that inotify isn't delivering change notifications in a timely fashion.

With the patch applied and BB_SERVER_TIMEOUT = "60", you can show an issue with something like:

rm bitbake-cookerdaemon.log
bitbake-layers add-layer ../meta-virtualization/ bitbake-layers add-layer ../meta-openembedded/meta-oe/ bitbake -m

where the second add-layer fails with the same error as the first with a message missing meta-virt dependencies. It doesn't notice bblayers.conf has changed and hence doesn't re-parse the base configuration. I've locally proven this is due to the inotify events not arriving until after the parsing commands.

os.sync() isn't enough to flush the inotify backlog. os.system("sync") does but that may be the fork overhead. sys.stdout.flush() does too, probably as side effects in the kernel IO workings.

This basically brings me to the conclusion that it is hard to know when the inotify events are in sync with the incoming command stream and the current approach is flawed.

I'm starting to think that we should drop inotify and go back to stat calls and maybe require that UIs send "re-scan cache" events so we can avoid the scanning when we don't need to. The client code does have a pretty good idea of when it changes metadata, it just doesn't share that at the moment. We can rescan at reconnection so it would just affect tinfoil usecases.

Cheers,

Richard

A message that is not in the archive (sent off-list or not yet received): [email protected]

#9 lore raw
Quoted 27 lines · Richard Purdie via lists.openembedded.org

Just to follow up with where I got to with this.

The problem is that inotify isn't delivering change notifications in a timely fashion.

With the patch applied and BB_SERVER_TIMEOUT = "60", you can show an issue with something like:

rm bitbake-cookerdaemon.log
bitbake-layers add-layer ../meta-virtualization/ bitbake-layers add-layer ../meta-openembedded/meta-oe/ bitbake -m

where the second add-layer fails with the same error as the first with a message missing meta-virt dependencies. It doesn't notice bblayers.conf has changed and hence doesn't re-parse the base configuration. I've locally proven this is due to the inotify events not arriving until after the parsing commands.

os.sync() isn't enough to flush the inotify backlog. os.system("sync") does but that may be the fork overhead. sys.stdout.flush() does too, probably as side effects in the kernel IO workings.

This basically brings me to the conclusion that it is hard to know when the inotify events are in sync with the incoming command stream and the current approach is flawed.

Quoted 6 lines

I'm starting to think that we should drop inotify and go back to stat calls and maybe require that UIs send "re-scan cache" events so we can avoid the scanning when we don't need to. The client code does have a pretty good idea of when it changes metadata, it just doesn't share that at the moment. We can rescan at reconnection so it would just affect tinfoil usecases.

There are patches in master-next which replace inotify usage with stat() calls and mtime comparisons.

For "bitbake" commands, I've made it revalidate the cache upon new commands so that part is relatively easy/safe.

The tricky part is that we'd now require tinfoil usage to explicitly say when the client has modified metadata (or run all the stat calls between every tinfoil command which would have crazy overhead).

This means we need to audit the tinfoil command usage to markup the places where it changes files and expects bitbake to notice.

In master-next, I did audit bitbake-layers and recipetool but not devtool. I've run an autobuilder build just to get an idea of how close this gets us to a solution. Unsurprisingly devtool is exploding there but other areas look more promising.

Ultimately we need to make a few more invasive changes to the way we control the server from the UI and be a bit more explicit about the command flow but that should wait until after release.

Cheers,

Richard

A message that is not in the archive (sent off-list or not yet received): [email protected]

#11 lore raw
Quoted 49 lines · Richard Purdie via lists.openembedded.org
Quoted 27 lines · Richard Purdie via lists.openembedded.org

Just to follow up with where I got to with this.

The problem is that inotify isn't delivering change notifications in a timely fashion.

With the patch applied and BB_SERVER_TIMEOUT = "60", you can show an issue with something like:

rm bitbake-cookerdaemon.log
bitbake-layers add-layer ../meta-virtualization/ bitbake-layers add-layer ../meta-openembedded/meta-oe/ bitbake -m

where the second add-layer fails with the same error as the first with a message missing meta-virt dependencies. It doesn't notice bblayers.conf has changed and hence doesn't re-parse the base configuration. I've locally proven this is due to the inotify events not arriving until after the parsing commands.

os.sync() isn't enough to flush the inotify backlog. os.system("sync") does but that may be the fork overhead. sys.stdout.flush() does too, probably as side effects in the kernel IO workings.

This basically brings me to the conclusion that it is hard to know when the inotify events are in sync with the incoming command stream and the current approach is flawed.

Quoted 6 lines

I'm starting to think that we should drop inotify and go back to stat calls and maybe require that UIs send "re-scan cache" events so we can avoid the scanning when we don't need to. The client code does have a pretty good idea of when it changes metadata, it just doesn't share that at the moment. We can rescan at reconnection so it would just affect tinfoil usecases.

There are patches in master-next which replace inotify usage with stat() calls and mtime comparisons.

For "bitbake" commands, I've made it revalidate the cache upon new commands so that part is relatively easy/safe.

The tricky part is that we'd now require tinfoil usage to explicitly say when the client has modified metadata (or run all the stat calls between every tinfoil command which would have crazy overhead).

This means we need to audit the tinfoil command usage to markup the places where it changes files and expects bitbake to notice.

Quoted 8 lines

In master-next, I did audit bitbake-layers and recipetool but not devtool. I've run an autobuilder build just to get an idea of how close this gets us to a solution. Unsurprisingly devtool is exploding there but other areas look more promising.

Ultimately we need to make a few more invasive changes to the way we control the server from the UI and be a bit more explicit about the command flow but that should wait until after release.

Final follow up to this. After some testing and sanity checking my change with others I've merged a patch removing inotify usage in bitbake. This then allowed the flush removal to merge too.

There are further things we should really fix but those are less urgent and this removes the problems identified. It should hopefully help some of the AB-INT bugs.

Anyone with custom tinfoil usage where they modify files will need to add a function call but I doubt there are too many people doing that (bitbake-layers, devtool and recipetool did).

Cheers,

Richard

A message that is not in the archive (sent off-list or not yet received): [email protected]

#13 lore raw

Bitbake server file coherency problems

Quoted 6 lines · Richard Purdie via lists.openembedded.org

The question at this point is what do people want me to do. We clearly have a really nasty bug in here. The patch is "right" and we do need to fix this. If I merge it, I suspect I'm going to end up having to chase this down before we can release and I am going to struggle to find the time to do it and I suspect my sanity will suffer. This does look to be a significant issue though.

I've spent some time digging into what is going on and I really don't like what I'm finding.

The existing .flush() call in the server logging path is basically injecting a "sync" equivalent in the main command loop within bitbake.

That "sync" is effectively by accident maintaining our cache coherence and it is also significantly damaging certain kinds of build performance.

If we remove it, bitbake fails to see file changes. In theory nothing should be changing files when builds are running however tinfoil users have already assumed bitbake manages it's cache correctly and with memory resident bitbake, there are signs of cache invalidation misses. Exactly what/where/why I still haven't quite worked out. Since we run oe-selftest with memory resident bitbake, it is particularly badly effected but back to back normal builds are also failing.

The challenge is that the sync flushes the inotify watches and without that, writes to files may have not triggered the inotify report which we rely on to invalidate the caches. Even adding os.sync() calls into bitbake isn't solving the problem as we only want to do this when needed for performance and it isn't clear when it is actually needed.

What is really needed is a step back and a re-design of the cache management within cooker, there is too many weird code paths that aren't actually that useful any more and we've tried to retrofit cache handling to something which never had it originally which isn't working out so well. Given the release I'm worried about undertaking something like this at such a time, equally, now I've seen the sheer amount of problems and the fact it is just luck things happen to work, I'm very very worried.

I've been asked who knows this area of code with a view to working out who we could lean on to help fix it. Sadly, I think I'm probably the only one who does.

Cheers,

Richard