<?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>11717</bug_id>
          
          <creation_ts>2017-06-24 05:21:04 +0000</creation_ts>
          <short_desc>large package set causes &apos;too many SQL variables&apos; error</short_desc>
          <delta_ts>2017-07-12 15:28:10 +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>2.4</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>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.4 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="David Reyna">david.reyna</reporter>
          <assigned_to name="David Reyna">david.reyna</assigned_to>
          <cc>jessica.zhang</cc>
    
    <cc>stanciux.mihail</cc>
          
          <qa_contact name="Libertad">libertad.gonzalez.de.la.cruz</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>74534</commentid>
    <comment_count>0</comment_count>
    <who name="David Reyna">david.reyna</who>
    <bug_when>2017-06-24 05:21:04 +0000</bug_when>
    <thetext>If you build a project with a large package set, you will get a crash in &quot;views.py&quot; when the dashboard attempts to fetch the package set to calculate the package count and size.

This is a sqlite limitation, and it fails with as few as 1220 packages.

To reproduce, build the &quot;intelx86-64&quot; machine using the intel-x86 layer, and then try to bring up the build&apos;s dashboard page.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74535</commentid>
    <comment_count>1</comment_count>
    <who name="David Reyna">david.reyna</who>
    <bug_when>2017-06-24 05:22:17 +0000</bug_when>
    <thetext>The solution is to break the query into parts.

diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py
index 2efb0fd5..39014379 100755
--- a/lib/toaster/toastergui/views.py
+++ b/lib/toaster/toastergui/views.py
@@ -483,10 +483,15 @@ def builddashboard( request, build_id ):
         npkg = 0
         pkgsz = 0
         package = None
-        for package in Package.objects.filter(id__in = [x.package_id for x in t.target_installed_package_set.all()]):
-            pkgsz = pkgsz + package.size
-            if package.installed_name:
-                npkg = npkg + 1
+        # Chunk the query to avoid &quot;too many SQL variables&quot; error
+        package_set = t.target_installed_package_set.all()
+        package_set_len = len(package_set)
+        for ps_start in range(0,package_set_len,500):
+            ps_stop = min(ps_start+500,package_set_len)
+            for package in Package.objects.filter(id__in = [x.package_id for x in package_set[ps_start:ps_stop]]):
+                pkgsz = pkgsz + package.size
+                if package.installed_name:
+                    npkg = npkg + 1
         elem[&apos;npkg&apos;] = npkg
         elem[&apos;pkgsz&apos;] = pkgsz</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>74960</commentid>
    <comment_count>2</comment_count>
    <who name="David Reyna">david.reyna</who>
    <bug_when>2017-07-12 15:28:10 +0000</bug_when>
    <thetext>commit eea5cb317137d71ad0cab954d2c9ad2069580b6f</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>