D18888: Akonadi: fix racy code in (MimeType|Resource)::retrieveByNameOrCreate
David Faure
noreply at phabricator.kde.org
Sat Feb 9 21:58:57 GMT 2019
dfaure created this revision.
dfaure added a reviewer: dvratil.
dfaure requested review of this revision.
REVISION SUMMARY
If two threads (TA and TB) would call retrieveByNameOrCreate() with a
*different* argument (say A and B), TA might acquire the lock to create A,
and meanwhile TB will fail the tryLock() and never create B.
Also the final lock/unlock (with nothing in between) was useless.
Solution: lock around lookup+creation, don't use tryLock (which is
almost always wrong IMHO...), simplify code by using QMutexLocker.
I found this by reading the code, but indirectly this seems to also
fix akonadiserver locking up in mysql queries during akonaditest
startup (sometimes), probably because it reduces concurrent querying a bit...
TEST PLAN
ctest, the "Resource synchronization timed out for akonadi_knut_resource_0"
errors (that happened approx 30% of the time) are gone.
BRANCH
Applications/18.12
REVISION DETAIL
https://phabricator.kde.org/D18888
AFFECTED FILES
src/server/storage/entities-source.xsl
To: dfaure, dvratil
Cc: kde-pim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20190209/ac94cfb6/attachment.html>
More information about the kde-pim
mailing list