<table><tr><td style="">poboiko created this revision.<br />poboiko added reviewers: Baloo, bruns, ngraham.<br />Herald added projects: Frameworks, Baloo.<br />poboiko 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/D23008">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>When a new batch arrives at stdin (as notified by QSocketNotifier), extractor<br />
creates a new transaction. If code, which reacts to notification, gets executed<br />
multiple times, we end up having two write transaction, which is a bad idea.</p>
<p>Current implementation disables <tt style="background: #ebebeb; font-size: 13px;">QSocketNotifier</tt>, so that we won't receive new<br />
notifications. It blocks further notifications, but it does not eliminate the<br />
possibility when several notifications already appeared in the event queue<br />
(which can happen due to race condition).<br />
It shouldn't happen, normally, but the only guard for that case currently is a<br />
single <tt style="background: #ebebeb; font-size: 13px;">Q_ASSERT</tt>, which gets silently ignored in the non-debug build.</p>
<p>This patch replaces assert with proper check, which instead commits & deletes<br />
the transaction if there is any (just in case).<br />
It also removes attempts to open the database multiple times (for each batch),<br />
which is a bad idea, as LMDB documentation suggests. These attempts will be<br />
ignored anyway (because of the check inside Database::open), yet semantically<br />
it's better to move the code outside, to the main(), as it is in <tt style="background: #ebebeb; font-size: 13px;">baloo_file</tt>.</p></div></div><br /><div><strong>TEST PLAN</strong><div><p>I didn't manage to cause such race condition "in the laboratory environment", <br />
so I've only checked it does not break anything</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R293 Baloo</div></div></div><br /><div><strong>BRANCH</strong><div><div>extractor-transaction (branched from master)</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D23008">https://phabricator.kde.org/D23008</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/file/extractor/app.cpp<br />
src/file/extractor/app.h<br />
src/file/extractor/main.cpp</div></div></div><br /><div><strong>To: </strong>poboiko, Baloo, bruns, ngraham<br /><strong>Cc: </strong>kde-frameworks-devel, LeGast00n, fbampaloukas, domson, ashaposhnikov, michaelh, astippich, spoorun, ngraham, bruns, abrahams<br /></div>