Concurrency and the Qodana Cache
Qodana does not implement a distributed locking mechanism to synchronize incremental cache access across multiple concurrent processes. When two or more scans run in parallel on the same repository and attempt to read from or write to the same cache directory, they operate independently. This lack of synchronization means the cache is not thread-safe or process-safe across parallel CI jobs.
Likely Impact of Concurrent Access
Because Qodana relies on standard file system operations for its incremental analysis, overlapping writes can lead to the following behaviors:
- Cache Corruption: Simultaneous writes to the same cache entries may result in interleaved data or truncated files, rendering specific cache segments unreadable.
- Stale Analysis: One process may overwrite the updates of another, causing the final state of the cache to reflect only the last process to finish, effectively discarding the incremental progress of parallel peers.
- Inconsistent Results: If a scan reads a partially written cache file, it may fail to identify issues that a sequential scan would have caught, leading to divergent issue reports between identical parallel jobs.
Verification and Observable Signs
To determine if parallel execution is compromising your analysis, monitor for these indicators:
- Divergent Issue Sets: Run two identical jobs in parallel. If the resulting issue reports differ despite identical codebases, cache interference is likely.
- Log Anomalies: Search Qodana logs for warnings such as
Unable to read cache entry or unexpected spikes in Cache miss events.
- Performance Regression: A significant increase in analysis time across parallel jobs (compared to a single sequential run) often indicates that corrupted caches are being discarded, forcing full re-scans.
Recommended Mitigation
To ensure cache consistency, avoid sharing a single cache directory across concurrent jobs. Use one of the following strategies:
- Job Isolation: Assign a unique cache path to each parallel job (e.g., by appending the CI job ID to the cache directory name).
- Sequential Finalization: Run parallel scans for fast feedback, but execute one final sequential scan to commit a clean, consistent state to the primary cache.
- Read-Only Caches: Configure parallel jobs to use a read-only version of the cache, disabling writes for all but one designated "master" job.
Diagnostic Note: To refine this recommendation, please specify if your CI environment uses a local SSD or a shared network file system (NFS/SMB), as network latency can exacerbate cache corruption during concurrent writes.