Fixes #29831 and #29863. Thanks to Marko for the detailed description of the issue.
The race occurs because a block could be connected and its event signaled in-between reading the ’next block’ and setting m_synced
during the index initial synchronization. This is because cs_main
is not locked through the process of determining the final index sync state.
To address the issue, the m_synced
flag set has been moved under cs_main
guard.