Codebase list libdbix-class-perl / b58ec61
Revert incorrectly backported fix for RT#102166 ( e8f23a77 ) I dropped the ball on testing this one change, and of course it came back to bite :/ Onwards to 0.082840 Peter Rabbitson 7 years ago
4 changed file(s) with 10 addition(s) and 60 deletion(s). Raw diff Collapse all Expand all
2222 - Fix spurious ROLLBACK statements when a TxnScopeGuard fails a commit
2323 of a transaction with deferred FK checks: a guard is now inactivated
2424 immediately before the commit is attempted (RT#107159)
25 - Fix spurious warning on MSSQL cursor invalidation retries (RT#102166)
2625 - Fix the Sybase ASE storage incorrectly attempting to retrieve an
2726 autoinc value when inserting rows containing blobs (GH#82)
2827 - Remove spurious exception warping in ::Replicated::execute_reliably
187187 # FIXME - we assume that $storage->{_dbh_autocommit} is there if
188188 # txn_init_depth is there, but this is a DBI-ism
189189 $txn_init_depth > ( $storage->{_dbh_autocommit} ? 0 : 1 )
190 )
191 or
192 ! do {
193 local $self->storage->{_in_do_block_retry_handler} = 1;
194 $self->retry_handler->($self)
195 }
190 ) or ! $self->retry_handler->($self)
196191 );
197192
198193 # we got that far - let's retry
99 use mro 'c3';
1010
1111 use Try::Tiny;
12 use DBIx::Class::_Util qw( sigwarn_silencer );
1312 use List::Util 'first';
1413 use namespace::clean;
1514
175174
176175 my $dbh = $self->_dbh or return 0;
177176
178 try {
179 local $dbh->{RaiseError} = 1;
180 local $dbh->{PrintError} = 0;
177 local $dbh->{RaiseError} = 1;
178 local $dbh->{PrintError} = 0;
179
180 return try {
181181 $dbh->do('select 1');
182182 1;
183 }
184 catch {
185 # MSSQL is *really* annoying wrt multiple active resultsets,
186 # and this may very well be the reason why the _ping failed
187 #
188 # Proactively disconnect, while hiding annoying warnings if the case
189 #
190 # The callchain is:
191 # < check basic retryability prerequisites (e.g. no txn) >
192 # ->retry_handler
193 # ->storage->connected()
194 # ->ping
195 # So if we got here with the in_handler bit set - we won't break
196 # anything by a disconnect
197 if( $self->{_in_do_block_retry_handler} ) {
198 local $SIG{__WARN__} = sigwarn_silencer qr/disconnect invalidates .+? active statement/;
199 $self->disconnect;
200 }
201
202 # RV of _ping itself
183 } catch {
203184 0;
204185 };
205186 }
22
33 use Test::More;
44 use Test::Exception;
5 use Test::Warn;
65 use Try::Tiny;
76
87 use DBIx::Class::Optional::Dependencies ();
102101
103102 ok(($new->artistid||0) > 0, "Auto-PK worked for $opts_name");
104103
105 # Test graceful error handling if not supporting multiple active statements
106 if( $opts_name eq 'plain' ) {
107
108 # keep the first cursor alive (as long as $rs is alive)
109 my $rs = $schema->resultset("Artist");
110
111 my $a1 = $rs->next;
112
113 my $a2;
114
115 warnings_are {
116 # second cursor, invalidates $rs, but it doesn't
117 # matter as long as we do not try to use it
118 $a2 = $schema->resultset("Artist")->next;
119 } [], 'No warning on retry due to previous cursor invalidation';
120
121 is_deeply(
122 { $a1->get_columns },
123 { $a2->get_columns },
124 'Same data',
125 );
126
127 dies_ok {
128 $rs->next;
129 } 'Invalid cursor did not silently return garbage';
130 }
131
132104 # Test multiple active statements
133 else {
105 SKIP: {
106 skip 'not a multiple active statements configuration', 1
107 if $opts_name eq 'plain';
108
134109 $schema->storage->ensure_connected;
135110
136111 lives_ok {