Skip to content

Commit bd026e0

Browse files
committed
fix sync issues once more
1 parent b8daf93 commit bd026e0

File tree

3 files changed

+34
-32
lines changed

3 files changed

+34
-32
lines changed

packages/core/src/repo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export const Repo = {
211211
}));
212212

213213
return await db.transaction(async (tx) => {
214+
await tx.execute(sql`SET LOCAL statement_timeout = '5min'`);
214215
const insertedIssueIds = await tx
215216
.insert(issueTable)
216217
.values(sanitizedIssuesToInsert)

packages/wrangler/src/workflows/sync/repo-init/init.workflow.ts

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -184,41 +184,42 @@ export class RepoInitWorkflow extends WorkflowEntrypoint<Env, RepoInitParams> {
184184
);
185185
await Promise.all(
186186
issueIdsArray.map(async (issueIds) => {
187-
const embeddingWorkflowId = await step.do(
187+
await step.do(
188188
"call worker to create and insert embeddings",
189189
async () => {
190-
return await this.env.SYNC_EMBEDDING_WORKFLOW.create({
191-
id: generateSyncWorkflowId(
192-
`embedding-${repoOwner}-${repoName}`,
193-
),
194-
params: {
195-
mode: "init",
196-
issueIds,
197-
repoName,
198-
repoId,
199-
},
200-
});
190+
const embeddingWorkflowId =
191+
await this.env.SYNC_EMBEDDING_WORKFLOW.create({
192+
id: generateSyncWorkflowId(
193+
`embedding-${repoOwner}-${repoName}`,
194+
),
195+
params: {
196+
mode: "init",
197+
issueIds,
198+
repoName,
199+
repoId,
200+
},
201+
});
202+
while (true) {
203+
await step.sleep(
204+
"wait for worker to finish",
205+
PARENT_WORKER_SLEEP_DURATION,
206+
);
207+
const { status } =
208+
await this.env.SYNC_EMBEDDING_WORKFLOW.getInstanceStatus(
209+
embeddingWorkflowId,
210+
);
211+
if (status === "complete") {
212+
return;
213+
}
214+
// if the children workflow has errored out, it should be a terminal state and we should throw an error here
215+
// that would force a retry
216+
// however, I have observed that an errored out workflow can still continue to run (wtf)
217+
if (status === "errored" || status === "terminated") {
218+
throw new Error("Embedding worker failed, retrying now");
219+
}
220+
}
201221
},
202222
);
203-
while (true) {
204-
await step.sleep(
205-
"wait for worker to finish",
206-
PARENT_WORKER_SLEEP_DURATION,
207-
);
208-
const { status } =
209-
await this.env.SYNC_EMBEDDING_WORKFLOW.getInstanceStatus(
210-
embeddingWorkflowId,
211-
);
212-
if (status === "complete") {
213-
return;
214-
}
215-
// if the children workflow has errored out, it should be a terminal state and we should throw an error here
216-
// that would force a retry
217-
// however, I have observed that an errored out workflow can still continue to run (wtf)
218-
if (status === "errored" || status === "terminated") {
219-
throw new Error("Embedding worker failed, retrying now");
220-
}
221-
}
222223
}),
223224
);
224225
await step.do(

packages/wrangler/src/workflows/sync/sync.param.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const getNumIssues = (attempt: number, name?: string) => {
4242
// arbitrarily larger than the response size limit set here (pending Cloudflare support response)
4343
// the problem with a limit that is too high is the return values will be too large to return
4444
// a limit that is too low will (1) result in lower throughput (2) if a single issue is too large, it will fail
45-
const DEFAULT_RESPONSE_SIZE_LIMIT_IN_BYTES = 800000;
45+
const DEFAULT_RESPONSE_SIZE_LIMIT_IN_BYTES = 750000;
4646
const SIZE_LIMITS_MAP: Record<string, number> = {
4747
// special handling for golang, source of many errors
4848
// will figure out how to properly size return value

0 commit comments

Comments
 (0)