[Bucardo-general] Two-Phase Commit

David E. Wheeler david at justatheory.com
Wed Oct 31 19:11:44 UTC 2012


Fellow Bucardoans,

At a quick glance, I see no support for two-phase commit in the 5.0 code base. Given its support for a multi-master replication factor greater than 2, it seems to me that it would be useful to have. I'm thinking that this is the key bit of code:

            $self->glog(q{Issuing final commit for all databases}, LOG_VERBOSE);
            ## This is a tricky bit: all writeable databases *must* go first
            ## If we only have a single source, this ensures we don't mark rows as done
            ## in the track tables before everyone has reported back
            for my $dbname (@dbs_dbi) {
                next if ! $x->{writtento};
                $sync->{db}{$dbname}{dbh}->commit();
            }
            ## Now we can commit anyone else
            for my $dbname (@dbs_dbi) {
                next if $x->{writtento};
                $sync->{db}{$dbname}{dbh}->commit();
            }

So good that it commits the databases written to, first. But what happens if there are three being written to, the first two commit, but the last one fails? Shouldn't the first two really be rolled back, then? Two-phase commit on databases that support it would allow that.

Thanks,

David



More information about the Bucardo-general mailing list