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()),
|
DATADOG_HOSTNAME: zpStr(z.string().optional()),
|
||||||
|
|
||||||
// PIT
|
// 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")),
|
PIT_TREE_CHECKPOINT_WINDOW: zpStr(z.string().optional().default("30")),
|
||||||
|
|
||||||
/* CORS ----------------------------------------------------------------------------- */
|
/* CORS ----------------------------------------------------------------------------- */
|
||||||
|
|||||||
@@ -295,10 +295,19 @@ export const folderCommitServiceFactory = ({
|
|||||||
},
|
},
|
||||||
tx
|
tx
|
||||||
);
|
);
|
||||||
await folderCheckpointResourcesDAL.insertMany(
|
|
||||||
checkpointResources.map((resource) => ({ folderCheckpointId: newCheckpoint.id, ...resource })),
|
const batchSize = 500;
|
||||||
tx
|
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;
|
return latestCommitId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user