Skip to content

N°9940 - Setup cache reset races with read-only UI requests producing… - #1038

Open
eespie wants to merge 1 commit into
developfrom
issue/9940_-_Setup_cache_reset_races_with_read-only_UI_requests_producing_corrupt_expression-cache_PHP_files
Open

eespie wants to merge 1 commit into
developfrom
issue/9940_-_Setup_cache_reset_races_with_read-only_UI_requests_producing_corrupt_expression-cache_PHP_files

Conversation

@eespie

@eespie eespie commented Sep 3, 2026

Copy link
Copy Markdown
Member

Race condition during the cache cleanup and the other users during setup

Copilot AI balanced review requested due to automatic review settings September 3, 2026 12:41
@CombodoApplicationsAccount CombodoApplicationsAccount added the internal Work made by Combodo label Sep 3, 2026
@eespie
eespie requested review from Lenaick and bdalsass September 3, 2026 12:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The cache-reset race remains, while some live compilation paths may now skip required invalidation.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Reduces cache-reset races during setup compilation.

Changes:

  • Removes an early full cache reset.
  • Makes opcode/APC cache resets conditional.
File summaries
File Review
setup/sequencers/DataAuditSequencer.php Moderate: CopySetupFiles() still calls global ResetAllCaches(), leaving the concurrent-request race unresolved.
setup/compiler.class.inc.php Critical: Inferring invalidation policy from temporary-directory use can leave live backup restores and updates running stale generated models.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines 309 to +312
if ($sTempTargetDir != $sFinalTargetDir) {
// Move the results to the target directory
SetupUtils::movedir($sTempTargetDir, $sFinalTargetDir);
}

// Reset the opcache since otherwise the PHP "model" files may still be cached !!
// In case of bad luck (this happens **sometimes** - see N. 550), we may analyze the database structure
// with the previous datamodel still loaded (in opcode cache) and thus fail to create the new fields
// Finally the application crashes (because of the missing field) when the cache gets updated
if (function_exists('opcache_reset')) {
// Zend opcode cache
opcache_reset();
}
if (function_exists('apc_clear_cache')) {
// old style APC
apc_clear_cache();
} else {
@@ -67,7 +67,6 @@ public function ExecuteStep($sStep = '', $sInstallComment = null): array
$aRemovedExtensionCodes = $this->oParams->Get('removed_extensions', []);
$aSelectedExtensionCodes = $this->oParams->Get('selected_extensions', []);
$bUseSymbolicLinks = $this->oParams->Get('use_symbolic_links', null) === 'on';
@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR narrows opcode/APC invalidation during model compilation and removes a redundant cache reset before the data-audit compilation step, avoiding cache-reset races with concurrent read-only requests.

  • Opcode and APC caches are no longer reset when compilation uses a temporary directory before moving generated files.
  • Direct-to-target compilation retains the existing cache reset.
  • Data-audit compilation no longer resets all build-environment caches beforehand.

Confidence Score: 5/5

The PR appears safe to merge, with required cache invalidation preserved at model-loading and commit boundaries.

The changed compilation path avoids a global reset during temporary generation, while downstream model initialization resets caches before loading generated code and commit resets both build and final environments after publishing it; no concrete regression remains.

Important Files Changed

Filename Overview
setup/compiler.class.inc.php Restricts global opcode/APC invalidation to direct-target compilation; later model initialization and commit paths retain the required cache resets.
setup/sequencers/DataAuditSequencer.php Removes the pre-compilation build-cache reset; audit model reflection executes in a fresh process and compilation refreshes the build cache directory.

Sequence Diagram

sequenceDiagram
    participant Setup
    participant Compiler
    participant BuildEnv
    participant LiveEnv
    participant Cache
    Setup->>Compiler: Compile selected model
    alt Temporary build directory
        Compiler->>BuildEnv: Generate and move files
        Note over Compiler,Cache: Skip global opcode/APC reset
    else Direct target compilation
        Compiler->>LiveEnv: Generate files
        Compiler->>Cache: Reset opcode/APC cache
    end
    Setup->>BuildEnv: Initialize model for installation steps
    BuildEnv->>Cache: Reset caches before startup
    Setup->>LiveEnv: Commit build environment
    LiveEnv->>Cache: Reset build and final caches
Loading

Reviews (1): Last reviewed commit: "N°9940 - Setup cache reset races with re..." | Re-trigger Greptile

@jf-cbd

jf-cbd commented Oct 5, 2026

Copy link
Copy Markdown
Member

Hey, the problem also happens on iTop 3.2.x, maybe the PR should be merged in support/3.2 ?

@jf-cbd

jf-cbd commented Oct 23, 2026

Copy link
Copy Markdown
Member

Just linking the related issue to this PR:
#993

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

internal Work made by Combodo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

N°9940 - Setup cache reset races with read-only UI requests producing corrupt expression-cache PHP files

4 participants