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
|
58
|
|
|
58
|
|
456
|
use strict; |
|
58
|
|
|
|
|
124
|
|
|
58
|
|
|
|
|
1715
|
|
16
|
58
|
|
|
58
|
|
302
|
use warnings; |
|
58
|
|
|
|
|
116
|
|
|
58
|
|
|
|
|
2225
|
|
17
|
|
|
|
|
|
|
package MongoDB::Op::_EndTxn; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Encapsulate code path for end transaction commands |
20
|
|
|
|
|
|
|
|
21
|
58
|
|
|
58
|
|
372
|
use version; |
|
58
|
|
|
|
|
130
|
|
|
58
|
|
|
|
|
389
|
|
22
|
|
|
|
|
|
|
our $VERSION = 'v2.2.0'; |
23
|
|
|
|
|
|
|
|
24
|
58
|
|
|
58
|
|
4870
|
use Moo; |
|
58
|
|
|
|
|
139
|
|
|
58
|
|
|
|
|
427
|
|
25
|
|
|
|
|
|
|
|
26
|
58
|
|
|
58
|
|
43216
|
use MongoDB::Op::_Command; |
|
58
|
|
|
|
|
213
|
|
|
58
|
|
|
|
|
2823
|
|
27
|
58
|
|
|
|
|
327
|
use MongoDB::_Types qw( |
28
|
|
|
|
|
|
|
Document |
29
|
|
|
|
|
|
|
to_IxHash |
30
|
58
|
|
|
58
|
|
548
|
); |
|
58
|
|
|
|
|
136
|
|
31
|
58
|
|
|
58
|
|
37230
|
use MongoDB::_Constants qw( TXN_WTIMEOUT_RETRY_DEFAULT ); |
|
58
|
|
|
|
|
144
|
|
|
58
|
|
|
|
|
4790
|
|
32
|
58
|
|
|
|
|
541
|
use Types::Standard qw( |
33
|
|
|
|
|
|
|
HashRef |
34
|
|
|
|
|
|
|
Maybe |
35
|
|
|
|
|
|
|
Int |
36
|
58
|
|
|
58
|
|
436
|
); |
|
58
|
|
|
|
|
185
|
|
37
|
|
|
|
|
|
|
|
38
|
58
|
|
|
58
|
|
58283
|
use namespace::clean; |
|
58
|
|
|
|
|
146
|
|
|
58
|
|
|
|
|
283
|
|
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; |