line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2015 - present MongoDB, Inc. |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
4
|
|
|
|
|
|
|
# you may not use this file except in compliance with the License. |
5
|
|
|
|
|
|
|
# You may obtain a copy of the License at |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software |
10
|
|
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
11
|
|
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12
|
|
|
|
|
|
|
# See the License for the specific language governing permissions and |
13
|
|
|
|
|
|
|
# limitations under the License. |
14
|
|
|
|
|
|
|
|
15
|
59
|
|
|
59
|
|
404
|
use strict; |
|
59
|
|
|
|
|
126
|
|
|
59
|
|
|
|
|
1796
|
|
16
|
59
|
|
|
59
|
|
304
|
use warnings; |
|
59
|
|
|
|
|
108
|
|
|
59
|
|
|
|
|
2302
|
|
17
|
|
|
|
|
|
|
package MongoDB::Op::_EndTxn; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Encapsulate code path for end transaction commands |
20
|
|
|
|
|
|
|
|
21
|
59
|
|
|
59
|
|
315
|
use version; |
|
59
|
|
|
|
|
124
|
|
|
59
|
|
|
|
|
354
|
|
22
|
|
|
|
|
|
|
our $VERSION = 'v2.2.1'; |
23
|
|
|
|
|
|
|
|
24
|
59
|
|
|
59
|
|
5004
|
use Moo; |
|
59
|
|
|
|
|
139
|
|
|
59
|
|
|
|
|
346
|
|
25
|
|
|
|
|
|
|
|
26
|
59
|
|
|
59
|
|
45069
|
use MongoDB::Op::_Command; |
|
59
|
|
|
|
|
226
|
|
|
59
|
|
|
|
|
2857
|
|
27
|
59
|
|
|
|
|
345
|
use MongoDB::_Types qw( |
28
|
|
|
|
|
|
|
Document |
29
|
|
|
|
|
|
|
to_IxHash |
30
|
59
|
|
|
59
|
|
463
|
); |
|
59
|
|
|
|
|
141
|
|
31
|
59
|
|
|
59
|
|
37827
|
use MongoDB::_Constants qw( TXN_WTIMEOUT_RETRY_DEFAULT ); |
|
59
|
|
|
|
|
162
|
|
|
59
|
|
|
|
|
4654
|
|
32
|
59
|
|
|
|
|
476
|
use Types::Standard qw( |
33
|
|
|
|
|
|
|
HashRef |
34
|
|
|
|
|
|
|
Maybe |
35
|
|
|
|
|
|
|
Int |
36
|
59
|
|
|
59
|
|
404
|
); |
|
59
|
|
|
|
|
134
|
|
37
|
|
|
|
|
|
|
|
38
|
59
|
|
|
59
|
|
59840
|
use namespace::clean; |
|
59
|
|
|
|
|
159
|
|
|
59
|
|
|
|
|
280
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
with $_ for qw( |
41
|
|
|
|
|
|
|
MongoDB::Role::_PrivateConstructor |
42
|
|
|
|
|
|
|
MongoDB::Role::_DatabaseOp |
43
|
|
|
|
|
|
|
MongoDB::Role::_SessionSupport |
44
|
|
|
|
|
|
|
MongoDB::Role::_CommandMonitoring |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has query => ( |
48
|
|
|
|
|
|
|
is => 'ro', |
49
|
|
|
|
|
|
|
required => 1, |
50
|
|
|
|
|
|
|
writer => '_set_query', |
51
|
|
|
|
|
|
|
isa => Document, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _get_query_maybe_with_write_concern { |
55
|
0
|
|
|
0
|
|
|
my ( $self, $topology ) = @_; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $query = to_IxHash( $self->query ); |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
if ( $self->session->_has_attempted_end_transaction ) { |
60
|
0
|
|
|
|
|
|
my $wc_existing = $self->session->_get_transaction_write_concern; |
61
|
0
|
|
|
|
|
|
my $wc = $wc_existing->as_args->[1]; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
$query->Push( writeConcern => { |
64
|
|
|
|
|
|
|
# allows for an override if set |
65
|
|
|
|
|
|
|
wtimeout => TXN_WTIMEOUT_RETRY_DEFAULT, |
66
|
|
|
|
|
|
|
( $wc ? %$wc : () ), |
67
|
|
|
|
|
|
|
# must be a majority on retrying |
68
|
|
|
|
|
|
|
w => 'majority', |
69
|
|
|
|
|
|
|
}); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# If we've gotten this far and a sharded topology doesnt support |
73
|
|
|
|
|
|
|
# transactions, something has gone seriously wrong |
74
|
0
|
0
|
0
|
|
|
|
if ( $topology eq 'Sharded' && defined $self->session->_recovery_token ) { |
75
|
0
|
|
|
|
|
|
$query->Push( recoveryToken => $self->session->_recovery_token ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
return $query; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub execute { |
82
|
0
|
|
|
0
|
0
|
|
my ( $self, $link, $topology ) = @_; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
my $query = $self->_get_query_maybe_with_write_concern( $topology ); |
85
|
|
|
|
|
|
|
# Set that an attempt to commit the transaction has been made after getting |
86
|
|
|
|
|
|
|
# query but before execute - stops error unwind losing it |
87
|
0
|
|
|
|
|
|
$self->session->_has_attempted_end_transaction( 1 ); |
88
|
|
|
|
|
|
|
my $op = MongoDB::Op::_Command->_new( |
89
|
|
|
|
|
|
|
query_flags => {}, |
90
|
|
|
|
|
|
|
query => $query, |
91
|
0
|
|
|
|
|
|
map { $_ => $self->$_ } qw(db_name bson_codec session monitoring_callback) |
|
0
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
); |
93
|
0
|
|
|
|
|
|
my $result = $op->execute( $link, $topology ); |
94
|
0
|
|
|
|
|
|
$result->assert_no_write_concern_error; |
95
|
0
|
|
|
|
|
|
return $result; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |