From 2b6fd9cd996a17dda279e274b34c456bd4f94a01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Tue, 13 Oct 2026 23:40:17 -0300 Subject: [PATCH] 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. --- perl-xCAT/xCAT/Table.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index 5517a0aea..4545b2971 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -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