Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: check if retryable
  • Loading branch information
durran committed Oct 8, 2024
commit 03de03111351577517d9d55bbf1d511cc4c29f21
4 changes: 4 additions & 0 deletions src/operations/client_bulk_write/client_bulk_write.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export class ClientBulkWriteOperation extends CommandOperation<ClientBulkWriteCu
return this.commandBuilder.resetBatch();
}

override get canRetryWrite(): boolean {
return this.commandBuilder.isRetryable && super.canRetryWrite;
}

/**
* Execute the command. Superclass will handle write concern, etc.
* @param server - The server.
Expand Down
5 changes: 5 additions & 0 deletions src/operations/client_bulk_write/command_builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class ClientBulkWriteCommandBuilder {
currentModelIndex: number;
previousModelIndex: number;
lastOperations: Document[];
isRetryable: boolean;

/**
* Create the command builder.
Expand All @@ -58,6 +59,10 @@ export class ClientBulkWriteCommandBuilder {
this.currentModelIndex = 0;
this.previousModelIndex = 0;
this.lastOperations = [];
// Multi updates are not retryable.
this.isRetryable = !models.some(model => {
return model.name === 'deleteMany' || model.name === 'updateMany';
});
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/operations/client_bulk_write/results_merger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export class ClientBulkWriteResultsMerger {
// record the error in writeErrors and immediately throw the exception. Otherwise, drivers
// MUST continue to iterate the results cursor and execute any further bulkWrite batches.
if (this.options.ordered) {
console.log(document);
const error = new MongoClientBulkWriteError({
message: 'Mongo client ordered bulk write encountered a write error.'
});
Expand Down