<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>14784</bug_id>
          
          <creation_ts>2022-04-12 16:50:18 +0000</creation_ts>
          <short_desc>Unstable Task Re-use/Setscene logic on populate_lic tasks in a MultiConfig Build</short_desc>
          <delta_ts>2022-04-14 20:24:38 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>4.1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Gregory Lumen">gregorylumen</reporter>
          <assigned_to name="Gregory Lumen">gregorylumen</assigned_to>
          <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>randy.macleod</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>93011</commentid>
    <comment_count>0</comment_count>
    <who name="Gregory Lumen">gregorylumen</who>
    <bug_when>2022-04-12 16:50:18 +0000</bug_when>
    <thetext>I have been observing what appears to be some Unstable Logic related to Task Re-use and/or setscene around populate_lic tasks in a MultiConfig Build.

The build consists of a custom device image and an initramfs multiconfig (that gets pulled into the device image via INITRAMFS_IMAGE_BUNDLE). (Note, the device image and the initramfs configs have separate TMPDIRs)

Both the device image and initramfs have a number of common recipies, including zlib (which was chosen randomly for the purposes of this investigation). 

I initially noted our SSTATE miss rate was higher than expected, even when no changes had been made. After investigating, it became clear that we were unexpectedly re-running a number of populate_lic tasks. Below is a walk-though of a repro path that highlights the unstable behavior:

Step 1: Full clean build

Step 2: Check contents of Stamps Directory for zlib populate_lic entries (`find build -path &quot;*/zlib/*populate_lic*.sigdata.*&quot;`)
  .../build/tmp-initramfs/stamps/cortexa57-poky-linux-musl/zlib/1.2.11-r0.do_populate_lic.sigdata.107ba92d54cb4534ac666d60a9dcbac75ba3a30b20231a91b868091080bfb144
  .../build/tmp-qemuarm64-my-device/stamps/cortexa57-my-device-linux/zlib/1.2.11-r0.do_populate_lic.sigdata.107ba92d54cb4534ac666d60a9dcbac75ba3a30b20231a91b868091080bfb144

Step 3: Check contents of SSTATE for zlib populate_lic entries (`find build/sstate-cache -name *:zlib:*populate_lic*.siginfo*)
  .../build/sstate-cache/10/7b/sstate:zlib::1.2.11:r0::7:107ba92d54cb4534ac666d60a9dcbac75ba3a30b20231a91b868091080bfb144_populate_lic.tgz.siginfo
  
Step 4: Delete everything under the build directory _except_ for the sstate-cache, build

Step 5: Check contents of Stamps Directory for zlib populate_lic entries (`find build -path &quot;*/zlib/*populate_lic*.sigdata.*&quot;`)
  .../build/tmp-initramfs/stamps/cortexa57-poky-linux-musl/zlib/1.2.11-r0.do_populate_lic.sigdata.5bcce361bf9ca855dcecf5bf7c1c0c761f7931daf153a46c95bc148a89276a9f

Step 6: Check contents of SSTATE for zlib populate_lic entries (`find build/sstate-cache -name *:zlib:*populate_lic*.siginfo*)
  .../build/sstate-cache/10/7b/sstate:zlib::1.2.11:r0::7:107ba92d54cb4534ac666d60a9dcbac75ba3a30b20231a91b868091080bfb144_populate_lic.tgz.siginfo
  .../build/sstate-cache/5b/cc/sstate:zlib::1.2.11:r0::7:5bcce361bf9ca855dcecf5bf7c1c0c761f7931daf153a46c95bc148a89276a9f_populate_lic.tgz.siginfo
  
Step 7: Save-off sstate-cache, delete entire build directory (clean)

Step 8: Run only populate_lic tasks (`bitbake --runonly=populate_lic my-image`)

Step 9: Check contents of Stamps Directory for zlib populate_lic entries (`find build -path &quot;*/zlib/*populate_lic*.sigdata.*&quot;`)
  .../build/tmp-qemuarm64-my-device/stamps/cortexa57-my-device-linux/zlib/1.2.11-r0.do_populate_lic.sigdata.5bcce361bf9ca855dcecf5bf7c1c0c761f7931daf153a46c95bc148a89276a9f
  .../build/tmp-initramfs/stamps/cortexa57-poky-linux-musl/zlib/1.2.11-r0.do_populate_lic.sigdata.5bcce361bf9ca855dcecf5bf7c1c0c761f7931daf153a46c95bc148a89276a9f
  
Step 10: Check contents of SSTATE for zlib populate_lic entries (`find build/sstate-cache -name *:zlib:*populate_lic*.siginfo*)
  ../build/sstate-cache/5b/cc/sstate:zlib::1.2.11:r0::7:5bcce361bf9ca855dcecf5bf7c1c0c761f7931daf153a46c95bc148a89276a9f_populate_lic.tgz.siginfo
  
Step 11: Delete entire build directory, Restore sstate-cache

Step 12: Run only populate_lic tasks (`bitbake --runonly=populate_lic my-image`)

Step 13: Check contents of Stamps Directory for zlib populate_lic entries (`find build -path &quot;*/zlib/*populate_lic*.sigdata.*&quot;`)
  ../build/tmp-initramfs/stamps/cortexa57-poky-linux-musl/zlib/1.2.11-r0.do_populate_lic.sigdata.5bcce361bf9ca855dcecf5bf7c1c0c761f7931daf153a46c95bc148a89276a9f
  
Step 14: Check contents of SSTATE for zlib populate_lic entries (`find build/sstate-cache -name *:zlib:*populate_lic*.siginfo*)
  ../build/sstate-cache/10/7b/sstate:zlib::1.2.11:r0::7:107ba92d54cb4534ac666d60a9dcbac75ba3a30b20231a91b868091080bfb144_populate_lic.tgz.siginfo
  ../build/sstate-cache/5b/cc/sstate:zlib::1.2.11:r0::7:5bcce361bf9ca855dcecf5bf7c1c0c761f7931daf153a46c95bc148a89276a9f_populate_lic.tgz.siginfo

This appears to identify 4 different scenarios, (full build clean, full build w/ sstate-cache, runonly=populate_lic clean, runonly=populate_lic w/ sstate-cache) each with different behaviors.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93012</commentid>
    <comment_count>1</comment_count>
    <who name="Gregory Lumen">gregorylumen</who>
    <bug_when>2022-04-12 17:54:52 +0000</bug_when>
    <thetext>I should also add that there also appears to be a different 5th behavior when running `--dump-signatures=printdiff` (though I had to hack up a few changes to get around https://bugzilla.yoctoproject.org/show_bug.cgi?id=14774) where it generates the stampfiles for both hashes:

.../build/tmp-initramfs/stamps/cortexa57-poky-linux-musl/zlib/1.2.11-r0.do_populate_lic.sigdata.5bcce361bf9ca855dcecf5bf7c1c0c761f7931daf153a46c95bc148a89276a9f
.../build/tmp-qemuarm64-my-device/stamps/cortexa57-my-device-linux/zlib/1.2.11-r0.do_populate_lic.sigdata.107ba92d54cb4534ac666d60a9dcbac75ba3a30b20231a91b868091080bfb144</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93034</commentid>
    <comment_count>2</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2022-04-13 17:00:33 +0000</bug_when>
    <thetext>Do you have hash equivalence enabled or disabled?

Can you share the sigdata/siginfo files, or at least run bitbake-diffsigs on them and see why they differ (or if they don&apos;t)?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93035</commentid>
    <comment_count>3</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2022-04-13 17:00:57 +0000</bug_when>
    <thetext>Also, which release/branch/revision is this with?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93040</commentid>
    <comment_count>4</comment_count>
    <who name="Gregory Lumen">gregorylumen</who>
    <bug_when>2022-04-13 20:39:45 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; Do you have hash equivalence enabled or disabled?

&gt; Can you share the sigdata/siginfo files, or at least run bitbake-diffsigs on them and see why they differ (or if they don&apos;t)?

I do not currently have hash equivalence enabled (this is part of an enterprise project, and standing up a hash equivalence server hasn&apos;t been a priority yet).

As for the delta between the signatures, here is the relevant output from `dump-signatures=printdiff`

Task zlib:do_populate_lic couldn&apos;t be used from the cache because:
  We need hash 5bcce361bf9ca855dcecf5bf7c1c0c761f7931daf153a46c95bc148a89276a9f, closest matching task was 107ba92d54cb4534ac666d60a9dcbac75ba3a30b20231a91b868091080bfb144
  basehash changed from 5ee77ff415e5e09325ce18d1758473c74ca94043a6030f52beab4310d4e6b9ab to 38930dd057247bd17b0bd5f985ddd3ed43bcedf23c73940e9887898c5d608b03
  List of dependencies for variable LIBCEXTENSION changed from &apos;{&apos;ABIEXTENSION&apos;}&apos; to &apos;set()&apos;
  Variable LIBCEXTENSION value changed:
&quot;[-${@[&apos;&apos;, &apos;-gnu&apos;][(d.getVar(&apos;ABIEXTENSION&apos;) or &apos;&apos;) != &apos;&apos;]}-] {+-musl+}&quot;
  Variable TARGET_VENDOR value changed from &apos;-my-device&apos; to &apos;-poky&apos;

I also ran bitbake -e on the two recipes on question and diffed the output to confirm the source of the deltas. The INCLUDE HISTORY is identical, and aside from timestamps/pathing the root of all of the diffs appear to trace back (as expected) to my distro customization.

  bitbake -e zlib:do_populate_lic
    &lt;..snip..&gt;
    #
    # $TARGET_VENDOR [3 operations]
    #   set .../work/poky/meta/conf/bitbake.conf:132
    #     &quot;-oe&quot;
    #   set .../work/poky/meta-poky/conf/distro/poky.conf:11
    #     &quot;-poky&quot;
    #   set ./meta-my-device/conf/distro/my-device.conf:22
    #     &quot;-my-device&quot;
    # pre-expansion value:
    #   &quot;-my-device&quot;
    TARGET_VENDOR=&quot;-my-device&quot;
    &lt;..snip..&gt;

  bitbake -e mc:initramfs:zlib:do_populate_lic
    &lt;..snip..&gt;
    # $TARGET_VENDOR [2 operations]
    #   set /mnt/vss/_work/1/s/work/poky/meta/conf/bitbake.conf:132
    #     &quot;-oe&quot;
    #   set /mnt/vss/_work/1/s/work/poky/meta-poky/conf/distro/poky.conf:11
    #     &quot;-poky&quot;
    # pre-expansion value:
    #   &quot;-poky&quot;
    TARGET_VENDOR=&quot;-poky&quot;
    &lt;..snip..&gt;

(In reply to comment #3)
&gt; Also, which release/branch/revision is this with?

All of this is pulling from fairly-recent commits out of honister (Examples were pulled using https://git.yoctoproject.org/poky/commit/?h=honister&amp;id=630d754ea3d7206976b1e0f4489e054cdbc08fe8)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93043</commentid>
    <comment_count>5</comment_count>
    <who name="Gregory Lumen">gregorylumen</who>
    <bug_when>2022-04-13 20:50:32 +0000</bug_when>
    <thetext>Also, to clarify. I have not changed BB_SIGNATURE_HANDLER=&quot;OEEquivHash&quot;, so bitbake is still starting the local Hash Equivalence server, but I am clearing away hashserv.db between each build, so there is no persistent hash equivalence.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93046</commentid>
    <comment_count>6</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2022-04-14 11:07:53 +0000</bug_when>
    <thetext>Thanks, those details help a lot.

I think what is happening is that you have two populate_lic tasks which give identical output. This means that when the second one builds in a multiconfig setup, it notices and changes the hash of the second to have an equivalence with the first.

You then delete the equivalence data.

A subsequent build therefore can&apos;t know that sstate is valid any more as there is now no mapping to it.

The bottom line is the hash equivalence data and sstate need to be used together. Rather than delete the data, use a non equivalence siggen.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93062</commentid>
    <comment_count>7</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2022-04-14 14:39:43 +0000</bug_when>
    <thetext>We think this is not a bug as explained by Richard. If you agree please close it or provide additional info.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93076</commentid>
    <comment_count>8</comment_count>
    <who name="Gregory Lumen">gregorylumen</who>
    <bug_when>2022-04-14 15:56:13 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; Thanks, those details help a lot.
&gt; 
&gt; I think what is happening is that you have two populate_lic tasks which give
&gt; identical output. This means that when the second one builds in a
&gt; multiconfig setup, it notices and changes the hash of the second to have an
&gt; equivalence with the first.
&gt; 
&gt; You then delete the equivalence data.
&gt; 
&gt; A subsequent build therefore can&apos;t know that sstate is valid any more as
&gt; there is now no mapping to it.
&gt; 
&gt; The bottom line is the hash equivalence data and sstate need to be used
&gt; together. Rather than delete the data, use a non equivalence siggen.

Let me re-run some tests with a non-equivalence siggen and will report the results  back.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93083</commentid>
    <comment_count>9</comment_count>
    <who name="Gregory Lumen">gregorylumen</who>
    <bug_when>2022-04-14 20:24:38 +0000</bug_when>
    <thetext>(In reply to comment #8)
&gt; (In reply to comment #6)
&gt; &gt; Thanks, those details help a lot.
&gt; &gt; 
&gt; &gt; I think what is happening is that you have two populate_lic tasks which give
&gt; &gt; identical output. This means that when the second one builds in a
&gt; &gt; multiconfig setup, it notices and changes the hash of the second to have an
&gt; &gt; equivalence with the first.
&gt; &gt; 
&gt; &gt; You then delete the equivalence data.
&gt; &gt; 
&gt; &gt; A subsequent build therefore can&apos;t know that sstate is valid any more as
&gt; &gt; there is now no mapping to it.
&gt; &gt; 
&gt; &gt; The bottom line is the hash equivalence data and sstate need to be used
&gt; &gt; together. Rather than delete the data, use a non equivalence siggen.
&gt; 
&gt; Let me re-run some tests with a non-equivalence siggen and will report the
&gt; results  back.

The results of the testing are in.

When I switched to `BB_SIGNATURE_HANDLER = &quot;OEBasicHash&quot;` Under all scenarios the device config used one signature (107ba92d) and initramfs config used the other (5bcce361).

When I re-enabled &quot;OEEquivHash&quot; and persisted hashserv.db both configs converged  (and stayed converged) on one signature (107ba92d in this case, but I would take the bet that I could get it to converge the other way onto 5bcce361)

Looking back at the original behavior, I still believe that there is evidence of instability in the Task Re-use/Setscene logic, but given that any such instability is fully and easily mitigated by either using &quot;OEBasicHash&quot; or having a persistent hash-server (and assuming that the choice of hash to converge on is unimportant, which by definition it should be), I think we can safely close this bug, Thanks!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>