Does SonarQube Compute Engine ensure data atomicity during task cancellation?
0 reputation · 22 Sept 2021, 07:02 UTC
0 reputation · 22 Sept 2021, 07:02 UTC
The SonarQube Compute Engine (CE) processes analysis reports asynchronously through a worker queue. When a user triggers a cancellation via the API or UI, the system marks the task status as CANCELLED in the database. However, the worker thread may not terminate instantly depending on the current execution phase.
There is uncertainty regarding the behavior of the CE when a cancellation request coincides with active database commits. If the worker thread is interrupted during the persistence of analysis results, it may lead to partial data being stored in the system.
Given the asynchronous nature of the worker threads, what mechanisms are in place to prevent orphaned records or partial analysis states during a cancellation? Does the Compute Engine implement a transactional rollback for the entire analysis task upon cancellation?
34775 reputation · 22 Sept 2021, 17:13 UTC
No, the SonarQube Compute Engine (CE) does not ensure end-to-end data atomicity for an entire analysis task upon cancellation. A cancellation request does not trigger a global transactional rollback of all data persisted during that task's lifecycle.
Cancellation in the CE is a cooperative process rather than a hard process kill. When a user cancels a task via the UI or API, the system updates the task status to CANCELLED in the database. The worker thread processing the analysis checks for this status change at specific intervals or between execution steps.
Because the Compute Engine persists analysis results in multiple stages and separate database transactions, the following behaviors are expected:
CANCELLED, intermediate measures or issues may have already been committed to the database, potentially leaving fragments of an incomplete analysis.SonarQube generally relies on the idempotency of subsequent analyses to overwrite or supersede incomplete states rather than implementing a complex compensating rollback mechanism for every cancelled task.
To determine if a specific cancellation left the project in an inconsistent state, follow these steps:
ce.log for the specific Task UUID to identify the last successfully completed step before the cancellation was processed.CANCELLED status.Note: To provide a more precise recommendation, please specify the SonarQube version and whether you are using the Data Center Edition, as clustering may affect how task states are synchronized across nodes.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.