[run-instance-commands] Preserve fast slow sequentiality (#19757)

# Introduction
The command was wrongly running all fast and then all slow ignoring
instance commands segment
Leading to 
```ts
1.23.0_AddGlobalObjectContextToCommandMenuItemAvailabilityTypeFastInstanceCommand_1776090711153 executed successfully
[Nest] 32679  - 04/16/2026, 1:21:07 PM     LOG [InstanceCommandRunnerService] 1.23.0_DropWorkspaceVersionColumnFastInstanceCommand_1785000000000 executed successfully
[Nest] 32679  - 04/16/2026, 1:21:07 PM     LOG [InstanceCommandRunnerService] 1.22.0_BackfillWorkspaceIdOnIndirectEntitiesSlowInstanceCommand_1775758621018 executed successfully
[Nest] 32679  - 04/16/2026, 1:21:07 PM     LOG [RunInstanceCommandsCommand] Instance commands completed
```

No prod/self host impact as 1.23 hasn't been released yet
This commit is contained in:
Paul Rastoin
2026-04-16 14:14:47 +02:00
committed by GitHub
parent 2b5b8a8b13
commit 2413af0ba9
2 changed files with 33 additions and 23 deletions
@@ -9,6 +9,7 @@ import { TWENTY_PREVIOUS_VERSIONS } from 'src/engine/core-modules/upgrade/consta
import { InstanceCommandRunnerService } from 'src/engine/core-modules/upgrade/services/instance-command-runner.service';
import { UpgradeCommandRegistryService } from 'src/engine/core-modules/upgrade/services/upgrade-command-registry.service';
import { UpgradeMigrationService } from 'src/engine/core-modules/upgrade/services/upgrade-migration.service';
import { UpgradeSequenceReaderService } from 'src/engine/core-modules/upgrade/services/upgrade-sequence-reader.service';
import { WorkspaceVersionService } from 'src/engine/workspace-manager/workspace-version/services/workspace-version.service';
type RunInstanceCommandsOptions = {
@@ -30,6 +31,7 @@ export class RunInstanceCommandsCommand extends CommandRunner {
private readonly dataSource: DataSource,
private readonly workspaceVersionService: WorkspaceVersionService,
private readonly upgradeCommandRegistryService: UpgradeCommandRegistryService,
private readonly upgradeSequenceReaderService: UpgradeSequenceReaderService,
private readonly instanceUpgradeService: InstanceCommandRunnerService,
private readonly upgradeMigrationService: UpgradeMigrationService,
) {
@@ -65,31 +67,26 @@ export class RunInstanceCommandsCommand extends CommandRunner {
const activeOrSuspendedWorkspaceIds =
await this.workspaceVersionService.getActiveOrSuspendedWorkspaceIds();
for (const {
command,
name,
} of this.upgradeCommandRegistryService.getCrossUpgradeSupportedFastInstanceCommands()) {
const result = await this.instanceUpgradeService.runFastInstanceCommand(
{
command,
name,
},
);
const sequence = this.upgradeSequenceReaderService.getUpgradeSequence();
if (result.status === 'failed') {
throw result.error;
for (const step of sequence) {
if (step.kind === 'fast-instance') {
const result =
await this.instanceUpgradeService.runFastInstanceCommand({
command: step.command,
name: step.name,
});
if (result.status === 'failed') {
throw result.error;
}
}
}
if (options.includeSlow) {
for (const {
command,
name,
} of this.upgradeCommandRegistryService.getCrossUpgradeSupportedSlowInstanceCommands()) {
if (step.kind === 'slow-instance' && options.includeSlow) {
const result =
await this.instanceUpgradeService.runSlowInstanceCommand({
command,
name,
command: step.command,
name: step.name,
skipDataMigration: activeOrSuspendedWorkspaceIds.length === 0,
});