Skip to content

Commit

Permalink
Force synch read of lsn_location from other nodes
Browse files Browse the repository at this point in the history
The loop in _set_priv_attr() is just enough to make sure the private
attribute is available locally. But it doesn't mean the attribute has
been propagated to other nodes.

This should fix gh issue #131 where lsn_location from remote node
might not be available yet during the promote action.

Note that I haven't been able to reproduce the same behavior myself
despite multiple creatives way of making attrd lagging...
  • Loading branch information
ioguix committed Nov 27, 2019
1 parent 2c088cd commit 14a835d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions script/pgsqlms
Original file line number Diff line number Diff line change
Expand Up @@ -1894,16 +1894,20 @@ sub pgsql_promote {

# Get the "lsn_location" attribute value for the node, as set during
# the "pre-promote" action.
$ans = _get_priv_attr( 'lsn_location', $node );

if ( $ans eq '' ) {
# This should not happen as the "lsn_location" attribute should
# have been updated during the "pre-promote" action.
ocf_exit_reason( 'Can not get LSN location for "%s"', $node );
return $OCF_ERR_GENERIC;
# This is implemented as a loop as private attributes are asynchronously
# available from other nodes.
# see: https://github.com/ClusterLabs/PAF/issues/131
# NOTE: if a node did not set its lsn_location for some reason, this will end
# with a timeout and the whole promotion will start again.
WAIT_FOR_LSN: {
$ans = _get_priv_attr( 'lsn_location', $node );
if ( $ans eq '' ) {
ocf_log( 'info', 'pgsql_promote: waiting for LSN from %s', $node );
select( undef, undef, undef, 0.1 );
redo WAIT_FOR_LSN;
}
}

# convert location to decimal
chomp $ans;
( $node_tl, $node_lsn ) = split /#/, $ans;

Expand Down

0 comments on commit 14a835d

Please sign in to comment.