Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Commit 054f48b

Browse files
committed
PERL-1123 Raise better error for retryable writes with mmapv1
1 parent 71de231 commit 054f48b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

‎lib/MongoDB/Error.pm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ BEGIN {
4949
HOST_NOT_FOUND => 7,
5050
UNKNOWN_ERROR => 8,
5151
USER_NOT_FOUND => 11,
52+
ILLEGAL_OPERATION => 20,
5253
NAMESPACE_NOT_FOUND => 26,
5354
INDEX_NOT_FOUND => 27,
5455
CURSOR_NOT_FOUND => 43,
@@ -239,6 +240,15 @@ sub _is_transient_transaction_error {
239240
return 0;
240241
}
241242

243+
# Look for error code ILLEGAL_OPERATION and starts with "Transaction numbers"
244+
sub _is_storage_engine_not_retryable {
245+
my $self = shift;
246+
if ( $self->$_can( 'code' ) ) {
247+
return 0 if $self->code != MongoDB::Error::ILLEGAL_OPERATION;
248+
}
249+
return index($self->message, "Transaction numbers", 0) == 0;
250+
}
251+
242252
#--------------------------------------------------------------------------#
243253
# Subclasses with attributes included inline below
244254
#--------------------------------------------------------------------------#

‎lib/MongoDB/_Dispatcher.pm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ sub send_retryable_write_op {
170170
eval { ($result) = $self->_try_op_for_link( $link, $op ); 1 } or do {
171171
my $err = length($@) ? $@ : "caught error, but it was lost in eval unwind";
172172

173+
if ( $err->$_call_if_can('_is_storage_engine_not_retryable') ) {
174+
# Break encapsulation to rewrite the message, then rethrow.
175+
$err->{message} = "This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.";
176+
die $err;
177+
}
178+
173179
# If the error is not retryable, then drop out
174180
unless ( $err->$_call_if_can('_is_retryable') ) {
175181
WITH_ASSERTS ? ( confess $err ) : ( die $err );

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /