Cache flush after database reset (#14873)

When starting the app on a fresh database reset the cache would be
filled with empty flat field metadata maps
Because the reset command hack through the repository directly in order
to create views and stuff
implemented an iso flush as the one existing initially
added it to a workspace deletion tambien
```
{
   byId: {],
   universalIdById: {}
}
```
This commit is contained in:
Paul Rastoin
2025-10-03 17:51:24 +02:00
committed by GitHub
parent 81e9a02101
commit d3a7241b6f
23 changed files with 210 additions and 162 deletions
@@ -36,7 +36,7 @@ export class CronTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatCronTriggerMaps', 'flatServerlessFunctionMaps'],
flatMapsKeys: ['flatCronTriggerMaps', 'flatServerlessFunctionMaps'],
},
);
@@ -86,7 +86,7 @@ export class CronTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatCronTriggerMaps', 'flatServerlessFunctionMaps'],
flatMapsKeys: ['flatCronTriggerMaps', 'flatServerlessFunctionMaps'],
},
);
@@ -104,7 +104,7 @@ export class CronTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatCronTriggerMaps', 'flatServerlessFunctionMaps'],
flatMapsKeys: ['flatCronTriggerMaps', 'flatServerlessFunctionMaps'],
},
);
@@ -157,7 +157,7 @@ export class CronTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatCronTriggerMaps'],
flatMapsKeys: ['flatCronTriggerMaps'],
},
);
@@ -181,7 +181,7 @@ export class CronTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatCronTriggerMaps', 'flatServerlessFunctionMaps'],
flatMapsKeys: ['flatCronTriggerMaps', 'flatServerlessFunctionMaps'],
},
);
@@ -36,7 +36,7 @@ export class DatabaseEventTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: [
flatMapsKeys: [
'flatDatabaseEventTriggerMaps',
'flatServerlessFunctionMaps',
],
@@ -94,7 +94,7 @@ export class DatabaseEventTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatDatabaseEventTriggerMaps'],
flatMapsKeys: ['flatDatabaseEventTriggerMaps'],
},
);
@@ -112,7 +112,7 @@ export class DatabaseEventTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: [
flatMapsKeys: [
'flatDatabaseEventTriggerMaps',
'flatServerlessFunctionMaps',
],
@@ -175,7 +175,7 @@ export class DatabaseEventTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatDatabaseEventTriggerMaps'],
flatMapsKeys: ['flatDatabaseEventTriggerMaps'],
},
);
@@ -199,7 +199,7 @@ export class DatabaseEventTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: [
flatMapsKeys: [
'flatDatabaseEventTriggerMaps',
'flatServerlessFunctionMaps',
],
@@ -72,7 +72,7 @@ export class FieldMetadataServiceV2 {
} = await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: [
flatMapsKeys: [
'flatObjectMetadataMaps',
'flatIndexMaps',
'flatFieldMetadataMaps',
@@ -180,7 +180,7 @@ export class FieldMetadataServiceV2 {
} = await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: [
flatMapsKeys: [
'flatObjectMetadataMaps',
'flatIndexMaps',
'flatFieldMetadataMaps',
@@ -288,7 +288,7 @@ export class FieldMetadataServiceV2 {
} = await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: [
flatMapsKeys: [
'flatObjectMetadataMaps',
'flatIndexMaps',
'flatFieldMetadataMaps',
@@ -402,7 +402,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
await this.flatEntityMapsCacheService.invalidateFlatEntityMaps({
workspaceId,
flatEntities: ['flatFieldMetadataMaps'],
flatMapsKeys: ['flatFieldMetadataMaps'],
});
return updatedFieldMetadata;
@@ -590,7 +590,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
await this.flatEntityMapsCacheService.invalidateFlatEntityMaps({
workspaceId,
flatEntities: ['flatObjectMetadataMaps', 'flatFieldMetadataMaps'],
flatMapsKeys: ['flatObjectMetadataMaps', 'flatFieldMetadataMaps'],
});
return fieldMetadata;
@@ -786,7 +786,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
await this.flatEntityMapsCacheService.invalidateFlatEntityMaps({
workspaceId,
flatEntities: ['flatObjectMetadataMaps', 'flatFieldMetadataMaps'],
flatMapsKeys: ['flatObjectMetadataMaps', 'flatFieldMetadataMaps'],
});
return createdFieldMetadatas;
@@ -58,7 +58,7 @@ export class ObjectMetadataServiceV2 {
} = await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: [
flatMapsKeys: [
'flatObjectMetadataMaps',
'flatIndexMaps',
'flatFieldMetadataMaps',
@@ -142,7 +142,7 @@ export class ObjectMetadataServiceV2 {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatObjectMetadataMaps'],
flatMapsKeys: ['flatObjectMetadataMaps'],
},
);
@@ -185,7 +185,7 @@ export class ObjectMetadataServiceV2 {
} = await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: [
flatMapsKeys: [
'flatObjectMetadataMaps',
'flatIndexMaps',
'flatFieldMetadataMaps',
@@ -305,7 +305,7 @@ export class ObjectMetadataServiceV2 {
} = await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: [
flatMapsKeys: [
'flatObjectMetadataMaps',
'flatViewMaps',
'flatViewFieldMaps',
@@ -427,7 +427,7 @@ export class ObjectMetadataServiceV2 {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatObjectMetadataMaps'],
flatMapsKeys: ['flatObjectMetadataMaps'],
},
);
@@ -14,6 +14,7 @@ import {
type QueryRunner,
} from 'typeorm';
import { WorkspaceManyOrAllFlatEntityMapsCacheService } from 'src/engine/core-modules/common/services/workspace-many-or-all-flat-entity-maps-cache.service';
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
@@ -52,7 +53,6 @@ import { isFieldMetadataEntityOfType } from 'src/engine/utils/is-field-metadata-
import { WorkspaceMigrationRunnerService } from 'src/engine/workspace-manager/workspace-migration-runner/workspace-migration-runner.service';
import { CUSTOM_OBJECT_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
import { isSearchableFieldType } from 'src/engine/workspace-manager/workspace-sync-metadata/utils/is-searchable-field.util';
import { WorkspaceManyOrAllFlatEntityMapsCacheService } from 'src/engine/core-modules/common/services/workspace-many-or-all-flat-entity-maps-cache.service';
import { ObjectMetadataEntity } from './object-metadata.entity';
@@ -288,7 +288,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
await this.flatEntityMapsCacheService.invalidateFlatEntityMaps({
workspaceId,
flatEntities: ['flatFieldMetadataMaps', 'flatObjectMetadataMaps'],
flatMapsKeys: ['flatFieldMetadataMaps', 'flatObjectMetadataMaps'],
});
return createdObjectMetadata;
@@ -475,7 +475,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
await this.flatEntityMapsCacheService.invalidateFlatEntityMaps({
workspaceId,
flatEntities: ['flatObjectMetadataMaps'],
flatMapsKeys: ['flatObjectMetadataMaps'],
});
const formattedUpdatedObject = {
@@ -592,7 +592,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
await this.flatEntityMapsCacheService.invalidateFlatEntityMaps({
workspaceId,
flatEntities: ['flatObjectMetadataMaps', 'flatFieldMetadataMaps'],
flatMapsKeys: ['flatObjectMetadataMaps', 'flatFieldMetadataMaps'],
});
await this.workspacePermissionsCacheService.recomputeRolesPermissionsCache(
@@ -36,7 +36,7 @@ export class RouteTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatRouteTriggerMaps', 'flatServerlessFunctionMaps'],
flatMapsKeys: ['flatRouteTriggerMaps', 'flatServerlessFunctionMaps'],
},
);
@@ -85,7 +85,7 @@ export class RouteTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatRouteTriggerMaps'],
flatMapsKeys: ['flatRouteTriggerMaps'],
},
);
@@ -103,7 +103,7 @@ export class RouteTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatRouteTriggerMaps', 'flatServerlessFunctionMaps'],
flatMapsKeys: ['flatRouteTriggerMaps', 'flatServerlessFunctionMaps'],
},
);
@@ -156,7 +156,7 @@ export class RouteTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatRouteTriggerMaps'],
flatMapsKeys: ['flatRouteTriggerMaps'],
},
);
@@ -180,7 +180,7 @@ export class RouteTriggerV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatRouteTriggerMaps', 'flatServerlessFunctionMaps'],
flatMapsKeys: ['flatRouteTriggerMaps', 'flatServerlessFunctionMaps'],
},
);
@@ -36,7 +36,7 @@ export class ServerlessFunctionV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatServerlessFunctionMaps'],
flatMapsKeys: ['flatServerlessFunctionMaps'],
},
);
@@ -84,7 +84,7 @@ export class ServerlessFunctionV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatServerlessFunctionMaps'],
flatMapsKeys: ['flatServerlessFunctionMaps'],
},
);
@@ -102,7 +102,7 @@ export class ServerlessFunctionV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatServerlessFunctionMaps'],
flatMapsKeys: ['flatServerlessFunctionMaps'],
},
);
@@ -155,7 +155,7 @@ export class ServerlessFunctionV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatServerlessFunctionMaps'],
flatMapsKeys: ['flatServerlessFunctionMaps'],
},
);
@@ -178,7 +178,7 @@ export class ServerlessFunctionV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatServerlessFunctionMaps'],
flatMapsKeys: ['flatServerlessFunctionMaps'],
},
);
@@ -233,7 +233,7 @@ export class ServerlessFunctionV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatServerlessFunctionMaps'],
flatMapsKeys: ['flatServerlessFunctionMaps'],
},
);
@@ -256,7 +256,7 @@ export class ServerlessFunctionV2Service {
await this.flatEntityMapsCacheService.getOrRecomputeManyOrAllFlatEntityMaps(
{
workspaceId,
flatEntities: ['flatServerlessFunctionMaps'],
flatMapsKeys: ['flatServerlessFunctionMaps'],
},
);