2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-10-22 07:38:08 +00:00

fix(table): refresh the cache after a rollback

rollback did not mark the caches of the rolled-back tables as stale. A
cached read after a write and before the rollback kept the rejected
value. Cached readers then got it for up to 5 seconds after the
rollback. MySQL and PostgreSQL share one handle among tables, so a
rollback through one table also undoes the changes of the others.

rollback now refreshes the cache of every table on its handle.
This commit is contained in:
Vinícius Ferrão
2026-10-13 23:40:17 -03:00
parent fae54f7a07
commit 2b6fd9cd99
+7 -1
View File
@@ -65,7 +65,7 @@ use DBI;
$DBI::dbi_debug = 9; # increase the debug output
use strict;
use Scalar::Util qw/weaken/;
use Scalar::Util qw/blessed weaken/;
use xCAT::Utils;
require xCAT::Schema;
require xCAT::NodeRange;
@@ -1625,6 +1625,12 @@ sub rollback
return dbc_call($self, 'rollback', @_);
}
$self->{dbh}->rollback;
#the rollback undoes the changes of every table on this handle, so their caches are invalid
#new() registers a table before it opens it, so a table that failed to open stays unblessed
foreach my $table (@{ $dbobjsforhandle->{ $self->{dbh} } || [ \$self ] }) {
$$table->_refresh_cache() if blessed($$table);
}
if ($self->{intransaction} and not $self->{autocommit} and $self->{realautocommit}) {
#on rollback, if sharing a DB handle for autocommit and non-autocommit, put the handle back to autocommit