Skip to content

Conversation

@philippwerner
Copy link
Contributor

This fixes a problem that led to random freezes because of the concurrent use of the reorgBuffer (aka scratchpad). So far, only the tick processor or the contract processor were allowed to use it (or the main processor if the tick and contract processors were not running). However, due to the use of the scratchpad in QPI::Collection and the use of Collection::add() -> Collection::_rebuild() in pendingTxsPool.add(), the reorgBuffer recently has also been used by the request processor without any locking. In consequence, concurrent execution of pendingTxsPool.add() and other functions using the reorgBuffer in the tick/contract processor led to undefined behaviour, usually freezing the request processor before leaving pendingTxsPool.add() and before unlocking pendingTxsPool.lock.

As a clean solution, reorgBuffer has been replaced by commonBuffers, a class that supports concurrent use of multiple buffers with proper locking.

In qubic.cpp, it is now configured to provide 2 buffers, in order to support concurrent execution of pendingTxsPool.add() and one other commonBuffers / scratchpad use case without blocking.

When other use cases of commonBuffers / scratchpad will be added in the future, the console log output "Common buffers: [...] max waiting processors" should be monitored in order to decide about adding more buffers by changing COMMON_BUFFERS_COUNT.

This fixes a problem that led to random freezes because of the
concurrent use of the reorgBuffer (aka scratchpad). So far, only the
tick processor or the contract processor were allowed to use it (or the
main processor if the tick and contract processors were not running).
However, due to the use of the scratchpad in QPI::Collection and the use
of Collection::add() -> Collection::_rebuild() in pendingTxsPool.add(),
the reorgBuffer recently has also been used by the request processor
without any locking. In consequence, concurrent execution of
pendingTxsPool.add() and other functions using the reorgBuffer in the
tick/contract processor led to undefined behaviour, usually freezing the
request processor before leaving pendingTxsPool.add() and before
unlocking pendingTxsPool.lock.

As a clean solution, reorgBuffer has been replaced by commonBuffers, a
class that supports concurrent use of multiple buffers with proper
locking.

In qubic.cpp, it is now configured to provide 2 buffers, in order to
support concurrent execution of pendingTxsPool.add() and one other
commonBuffers / scratchpad use case without blocking.

When other use cases of commonBuffers / scratchpad will be added in the
future, the console log output "Common buffers: [...] max waiting
processors" should be monitored in order to decide about adding more
buffers by changing COMMON_BUFFERS_COUNT.
@philippwerner philippwerner self-assigned this Jan 23, 2026
@philippwerner philippwerner moved this to 🧪 Testing in qubic Jan 23, 2026
@Franziska-Mueller Franziska-Mueller self-requested a review January 26, 2026 15:45
@Franziska-Mueller Franziska-Mueller merged commit 9b044a9 into develop Jan 27, 2026
1 check passed
@github-project-automation github-project-automation bot moved this from 🧪 Testing to ✅ Done in qubic Jan 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants