<?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>14765</bug_id>
          
          <creation_ts>2022-03-19 02:48:55 +0000</creation_ts>
          <short_desc>toaster: race condition for end-of-build</short_desc>
          <delta_ts>2022-03-21 20:55:30 +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>Toaster</product>
          <component>toaster</component>
          <version>3.4.3</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>High</priority>
          <bug_severity>critical</bug_severity>
          <target_milestone>4.0 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Reyna">david.reyna</reporter>
          <assigned_to name="David Reyna">david.reyna</assigned_to>
          
          
          <qa_contact name="Toaster default assignee">toaster</qa_contact>
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>92818</commentid>
    <comment_count>0</comment_count>
    <who name="David Reyna">david.reyna</who>
    <bug_when>2022-03-19 02:48:55 +0000</bug_when>
    <thetext>With the introduction of Django-3, there is a new database commit race condition.

At the end of short builds (quilt-native, re-build of a previous build), the behavior is the same as before.

However for long builds, the event handler for &quot;bb.event.BuildCompleted&quot; sets the build record&apos;s status to &apos;success&apos;, but that change does not make it to the actual database, resulting in a &apos;finished&apos; build visually stuck at 100%.

The solution is to introduce this code:

    def update_build_stats_and_outcome(self, build, errors, warnings, taskfailures):
        ...

        # We force a sync point here to force the outcome status commit,
        # which resolves a race condition with the build completion takedown
        transaction.set_autocommit(True)
        transaction.set_autocommit(False)

The problem is set up by the fact that Toaster has SQLite has autocommit normally turned off so that Toaster can wait to catch up with the flood of events and avoid a database lock. But in this case, if the commit queue is too long as per a full build, the build worker threads could be killed before the queue is finish and lose late commits like this one.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>92826</commentid>
    <comment_count>1</comment_count>
    <who name="David Reyna">david.reyna</who>
    <bug_when>2022-03-21 20:55:30 +0000</bug_when>
    <thetext>Resolved.

Commit: c71a9c89e3c23ba1f1eec06c0183ee1d7148041d</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>