summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Reyna <David.Reyna@windriver.com>2017-06-27 13:44:31 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-27 22:17:53 +0100
commit02cb2b7f7ff594de75a404396f39a2428750c798 (patch)
treeeaf8c97c822cdca95180c725b41d1cfc9da74ec1
parenta156a4eff67cdc3943494f5be72b96e3db656250 (diff)
downloadbitbake-contrib-02cb2b7f7ff594de75a404396f39a2428750c798.tar.gz
toaster: large package set breaks sqlite query
If you build a project with a large package set, you will get a crash in "views.py" 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. [YOCTO #11717] Signed-off-by: David Reyna <David.Reyna@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xlib/toaster/toastergui/views.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/toaster/toastergui/views.py b/lib/toaster/toastergui/views.py
index 75c591103..5720b9d5e 100755
--- a/lib/toaster/toastergui/views.py
+++ b/lib/toaster/toastergui/views.py
@@ -457,10 +457,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 "too many SQL variables" 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['npkg'] = npkg
elem['pkgsz'] = pkgsz
ti = Target_Image_File.objects.filter(target_id = t.id)