MantisBT - CDash
View Issue Details
0011125CDashpublic2010-08-13 04:152010-10-25 02:36
Chris Hillery 
Julien Jomier 
0011125: Test.Exists() uses incomplete key, resulting in bogus test associations in DB
The index for the "test" table comprises the crc32, name, and projectid fields, where the crc32 field is a CRC calculated over several other fields such as the command and output text.

However, Test.Exists() only checks the database for an entry matching the crc32 and projectid fields. Since a 32-bit CRC is definitely not guaranteed to be unique, this can result in Test incorrectly concluding that a match exists, with the result that a submitted build is associated with tests from other builds.

This isn't a theoretical problem; I tracked it down because it was occurring regularly with our nightly tests. I could see that the correct tests were run and were in the uploaded .xml files, but viewing the CDash webpage showed different tests for those builds.
I have attached a trivial patch which corrects the problem for us.
No tags attached.
txt fix-test-exists-patch.txt (827) 2010-08-13 04:15
Issue History
2010-08-13 04:15Chris HilleryNew Issue
2010-08-13 04:15Chris HilleryFile Added: fix-test-exists-patch.txt
2010-08-13 08:22Julien JomierNote Added: 0021741
2010-08-13 19:36Chris HilleryNote Added: 0021747
2010-08-26 11:08Julien JomierStatusnew => assigned
2010-08-26 11:08Julien JomierAssigned To => Julien Jomier
2010-08-26 12:37Julien JomierNote Added: 0021976
2010-08-26 12:37Julien JomierStatusassigned => resolved
2010-08-26 12:37Julien JomierFixed in Version => 1.8
2010-08-26 12:37Julien JomierResolutionopen => fixed
2010-10-25 02:36Julien JomierStatusresolved => closed

Julien Jomier   
2010-08-13 08:22   
This is interesting. We did see some crc32 collisions across projects on some servers running a lot of project, but never within a project (that's why we added the projectid check not so long ago). I guess we have to check with the name too as suggested (this is going to be much slower regretfully).
Chris Hillery   
2010-08-13 19:36   
For reference, our project has 25 nightly builds. There are 35,000 or so unique test names, and each build runs some subset (there are many overlaps). We discovered this problem because one build, which runs about 20,000 tests, was regularly showing about 10 tests from other builds.

Sorry to say, but a crc32 simply isn't a unique key! :) In fact, even with my patch, the possibility exists for collisions, although it would most likely require a fairly unusual set of circumstances (eg., different tests with the same name).

Since the test table has an index on the 'name' field, I do not think my change will be "much slower". I didn't do careful analysis, but I haven't noticed any significant change with our project.

Still, if this was a concern, the existing single-column indexes could be either replaced by or supplemented with a true multi-column index over the crc32,name,projectid fields. Since mysql (and I assume postgres) can use left subsets of multi-column indexes, probably the three separate indexes could be replaced entirely with the single multi-column index, which would therefore probably not take significantly more disk space.
Julien Jomier   
2010-08-26 12:37   
Patch committed. Thanks for the report.