Patch: Database errors when building Yocto-Yoe
Hi,
during a project build using Toaster and a MySQL database, there are some database errors due to insufficient size of the data fields. This patch includes the necessary changes in the ORM, including proper migration methods.
The implementation follows the lines of
https://www.yoctoproject.org/pipermail/toaster/2018-October/005718.html
The offensive SQL errors and queries are as follows:
* django.db.utils.DataError: (1264, "Out of range value for column 'disk_io' at row 1")
``` UPDATE `orm_task` SET `build_id` = 30, `order` = 1576, `task_executed` = 1, `outcome` = 0, `sstate_checksum` = 'e47a7bb240056b47b297eea760616408ab4daad32a05f3cf86973a4d3427f8e3', `path_to_sstate_obj` = '', `recipe_id` = 47597, `task_name` = 'do_unpack', `source_url` = '', `work_directory` = '', `script_type` = 2, `line_number` = 0, `started` = '2020-11-16 11:11:30.680000', `ended` = '2020-11-16 11:12:28.030000', `elapsed_time` = '57.35', `disk_io` = 2458021888, `disk_io_read` = 269443072, `disk_io_write` = 2188578816, `cpu_time_user` = '28.78', `cpu_time_system` = '12.24', `sstate_result` = 0, `message` = 'recipe mozjs-60.9.0-r0: task do_unpack: Succeeded', `logfile` = '/home/holger/data/Yocto/yocto-yoe-toaster/build/tmp/work/armv7at2hf-neon-ks-linux-gnueabi/mozjs/60.9.0-r0/temp/log.do_unpack.3422' WHERE `orm_task`.`id` = 78884 ```
* django.db.utils.DataError: (1406, "Data too long for column 'file_name' at row 1")
``` INSERT INTO `orm_targetkernelfile` (`target_id`, `file_name`, `file_size`) VALUES (18, '/home/holger/data/Yocto/yocto-yoe-toaster/build/tmp/deploy/images/am335x-diva/zImage--5.4.40+git0+7f8dc0f36a-0a.2-am335x-diva-20201109102412.bin', 4628992) ```
* django.db.utils.DataError: (1406, "Data too long for column 'license' at row 1")
```
UPDATE `orm_package`
SET `build_id` = 26,
`recipe_id` = 45765,
`name` = 'qtbase',
`installed_name` = 'qtbase',
`version` = '5.14.1+gitAUTOINC+0ab53fbdda',
`revision` = 'r0',
`summary` = 'qtbase version 5.14.1+gitAUTOINC+0ab53fbdda-r0',
`description` = 'qtbase version 5.14.1+gitAUTOINC+0ab53fbdda-r0.',
`size` = 17123154,
`installed_size` = 17123328,
`section` = 'base',
`license` = 'GFDL-1.3 & BSD & ( GPL-3.0 & The-Qt-Company-GPL-Exception-1.0 | The-Qt-Company-Commercial ) & ( GPL-2.0+ | LGPL-3.0 | The-Qt-Company-Commercial )'
WHERE `orm_package`.`id` = 18159"
```Could you please review the patch? If it's o.k., I would prepare a pull-request and try to bring it upstream.
Best,
Holger
lib/toaster/orm/migrations/0020_use_bigint_for_diskio.py new file +25 -0
@@ -0,0 +1,25 @@ +from django.db import migrations, models + +class Migration(migrations.Migration): + + dependencies = [ + ('orm', '0019_django_2_2'), + ] + + operations = [ + migrations.AlterField( + model_name='task', + name='disk_io', + field=models.BigIntegerField(null=True), + ), + migrations.AlterField( + model_name='task', + name='disk_io_read', + field=models.BigIntegerField(null=True), + ), + migrations.AlterField( + model_name='task', + name='disk_io_write', + field=models.BigIntegerField(null=True), + ), + ]
lib/toaster/orm/migrations/0021_target_kernel_file_file_name.py new file +15 -0
@@ -0,0 +1,15 @@ +from django.db import migrations, models + +class Migration(migrations.Migration): + + dependencies = [ + ('orm', '0020_use_bigint_for_diskio'), + ] + + operations = [ + migrations.AlterField( + model_name='targetkernelfile', + name='file_name', + field=models.FilePathField(max_length=255), + ), + ]
lib/toaster/orm/migrations/0022_package_license.py new file +15 -0
@@ -0,0 +1,15 @@ +from django.db import migrations, models + +class Migration(migrations.Migration): + + dependencies = [ + ('orm', '0021_target_kernel_file_file_name'), + ] + + operations = [ + migrations.AlterField( + model_name='package', + name='license', + field=models.CharField(max_length=255, blank=True), + ), + ]
lib/toaster/orm/models.py +5 -5
@@ -945,7 +945,7 @@ class Target(models.Model): # kernel artifacts for a target: bzImage and modules* class TargetKernelFile(models.Model): target = models.ForeignKey(Target, on_delete=models.CASCADE) - file_name = models.FilePathField() + file_name = models.FilePathField(max_length=255) file_size = models.IntegerField() @property
@@ -1123,9 +1123,9 @@ class Task(models.Model): elapsed_time = models.DecimalField(max_digits=8, decimal_places=2, null=True) # in bytes; note that disk_io is stored to enable sorting - disk_io = models.IntegerField(null=True) - disk_io_read = models.IntegerField(null=True) - disk_io_write = models.IntegerField(null=True) + disk_io = models.BigIntegerField(null=True) + disk_io_read = models.BigIntegerField(null=True) + disk_io_write = models.BigIntegerField(null=True) # in seconds cpu_time_user = models.DecimalField(max_digits=8, decimal_places=2, null=True)
@@ -1163,7 +1163,7 @@ class Package(models.Model): size = models.IntegerField(default=0) installed_size = models.IntegerField(default=0) section = models.CharField(max_length=80, blank=True) - license = models.CharField(max_length=80, blank=True) + license = models.CharField(max_length=255, blank=True) @property def is_locale_package(self):