DIRACGrid / DIRAC

DIRAC Grid
http://diracgrid.org
GNU General Public License v3.0
113 stars 176 forks source link

Accounting/ReportGenerator : Error while generating the plots due to MySQL Error #7595

Closed cserf closed 5 months ago

cserf commented 6 months ago

A wrong SQL query can be generated if one condition value for filtering is an empty list (e.g. AND ( ) AND in the query generated below) :

SELECT `ac_key_Belle-BNL-Certification_Job_FinalMinorStatus`.`value`, `ac_bucket_Belle-BNL-Certification_Job`.`startTime`, `ac_bucket_Belle-BNL-Certification_Job`.`bucketLength`, SUM(`ac_bucket_Belle-BNL-Certification_Job`.`ExecTime`) FROM `ac_bucket_Belle-BNL-Certification_Job`, `ac_key_Belle-BNL-Certification_Job_JobGroup`, `ac_key_Belle-BNL-Certification_Job_JobType`, `ac_key_Belle-BNL-Certification_Job_FinalMinorStatus` WHERE `ac_bucket_Belle-BNL-Certification_Job`.`startTime` >= 1713340800 AND `ac_bucket_Belle-BNL-Certification_Job`.`startTime` <= 1713945600 AND (  ) AND ( `ac_key_Belle-BNL-Certification_Job_JobType`.`value` = "RawProcessing" ) AND `ac_bucket_Belle-BNL-Certification_Job`.`FinalMinorStatus` = `ac_key_Belle-BNL-Certification_Job_FinalMinorStatus`.`id` AND `ac_bucket_Belle-BNL-Certification_Job`.`JobGroup` = `ac_key_Belle-BNL-Certification_Job_JobGroup`.`id` AND `ac_bucket_Belle-BNL-Certification_Job`.`JobType` = `ac_key_Belle-BNL-Certification_Job_JobType`.`id` GROUP BY startTime, `ac_key_Belle-BNL-Certification_Job_FinalMinorStatus`.Value, bucketlength ORDER BY startTime

The problem is due to this : https://github.com/DIRACGrid/DIRAC/blob/integration/src/DIRAC/AccountingSystem/DB/AccountingDB.py#L1024-L1033

sqlCondList should only be generated if sqlORList is not an empty list