mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
PIT: fix checkpoint creation to do it in batches to avoid insert fails
This commit is contained in:
@@ -245,7 +245,7 @@ const envSchema = z
|
||||
DATADOG_HOSTNAME: zpStr(z.string().optional()),
|
||||
|
||||
// PIT
|
||||
PIT_CHECKPOINT_WINDOW: zpStr(z.string().optional().default("1")),
|
||||
PIT_CHECKPOINT_WINDOW: zpStr(z.string().optional().default("2")),
|
||||
PIT_TREE_CHECKPOINT_WINDOW: zpStr(z.string().optional().default("30")),
|
||||
|
||||
/* CORS ----------------------------------------------------------------------------- */
|
||||
|
||||
@@ -295,10 +295,19 @@ export const folderCommitServiceFactory = ({
|
||||
},
|
||||
tx
|
||||
);
|
||||
await folderCheckpointResourcesDAL.insertMany(
|
||||
checkpointResources.map((resource) => ({ folderCheckpointId: newCheckpoint.id, ...resource })),
|
||||
tx
|
||||
|
||||
const batchSize = 500;
|
||||
const chunks = chunkArray(checkpointResources, batchSize);
|
||||
|
||||
await Promise.all(
|
||||
chunks.map(async (chunk) => {
|
||||
await folderCheckpointResourcesDAL.insertMany(
|
||||
chunk.map((resource) => ({ folderCheckpointId: newCheckpoint.id, ...resource })),
|
||||
tx
|
||||
);
|
||||
})
|
||||
);
|
||||
|
||||
return latestCommitId;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user