<table><tr><td style="">dfaure created this revision.<br />dfaure added a reviewer: dvratil.<br />dfaure requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D18888">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>If two threads (TA and TB) would call retrieveByNameOrCreate() with a<br />
*different* argument (say A and B), TA might acquire the lock to create A,<br />
and meanwhile TB will fail the tryLock() and never create B.</p>

<p>Also the final lock/unlock (with nothing in between) was useless.</p>

<p>Solution: lock around lookup+creation, don't use tryLock (which is<br />
almost always wrong IMHO...), simplify code by using QMutexLocker.</p>

<p>I found this by reading the code, but indirectly this seems to also<br />
fix akonadiserver locking up in mysql queries during akonaditest<br />
startup (sometimes), probably because it reduces concurrent querying a bit...</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>ctest, the "Resource synchronization timed out for akonadi_knut_resource_0"<br />
errors (that happened approx 30% of the time) are gone.</p></div></div><br /><div><strong>BRANCH</strong><div><div>Applications/18.12</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D18888">https://phabricator.kde.org/D18888</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/server/storage/entities-source.xsl</div></div></div><br /><div><strong>To: </strong>dfaure, dvratil<br /><strong>Cc: </strong>kde-pim<br /></div>