@@ -798,7 +798,7 @@ MtmEndTransaction(MtmCurrentTrans* x, bool commit)
798
798
* Send notification only if ABORT happens during transaction processing at replicas,
799
799
* do not send notification if ABORT is receiver from master
800
800
*/
801
- MTM_TRACE ("%d: send ABORT notification to coordinator %d\n" , MyProcPid , x -> gtid .node );
801
+ MTM_INFO ("%d: send ABORT notification abort transaction %d to coordinator %d\n" , MyProcPid , x -> gtid . xid , x -> gtid .node );
802
802
if (ts == NULL ) {
803
803
Assert (TransactionIdIsValid (x -> xid ));
804
804
ts = hash_search (MtmXid2State , & x -> xid , HASH_ENTER , NULL );
@@ -1602,6 +1602,11 @@ MtmSlotMode MtmReceiverSlotMode(int nodeId)
1602
1602
return Mtm -> recoverySlot ? SLOT_CREATE_NEW : SLOT_OPEN_ALWAYS ;
1603
1603
}
1604
1604
1605
+ static bool MtmIsBroadcast ()
1606
+ {
1607
+ return application_name != NULL && strcmp (application_name , MULTIMASTER_BROADCAST_SERVICE ) == 0 ;
1608
+ }
1609
+
1605
1610
void MtmRecoverNode (int nodeId )
1606
1611
{
1607
1612
if (nodeId <= 0 || nodeId > Mtm -> nNodes )
@@ -1611,7 +1616,7 @@ void MtmRecoverNode(int nodeId)
1611
1616
if (!BIT_CHECK (Mtm -> disabledNodeMask , nodeId - 1 )) {
1612
1617
elog (ERROR , "Node %d was not disabled" , nodeId );
1613
1618
}
1614
- if (!IsTransactionBlock ())
1619
+ if (!MtmIsBroadcast ())
1615
1620
{
1616
1621
MtmBroadcastUtilityStmt (psprintf ("select pg_create_logical_replication_slot('" MULTIMASTER_SLOT_PATTERN "', '" MULTIMASTER_NAME "')" , nodeId ), true);
1617
1622
}
@@ -1628,7 +1633,7 @@ void MtmDropNode(int nodeId, bool dropSlot)
1628
1633
}
1629
1634
BIT_SET (Mtm -> disabledNodeMask , nodeId - 1 );
1630
1635
Mtm -> nNodes -= 1 ;
1631
- if (!IsTransactionBlock ())
1636
+ if (!MtmIsBroadcast ())
1632
1637
{
1633
1638
MtmBroadcastUtilityStmt (psprintf ("select mtm.drop_node(%d,%s)" , nodeId , dropSlot ? "true" : "false" ), true);
1634
1639
}
@@ -1648,7 +1653,6 @@ MtmReplicationShutdownHook(struct PGLogicalShutdownHookArgs* args)
1648
1653
static bool
1649
1654
MtmReplicationTxnFilterHook (struct PGLogicalTxnFilterArgs * args )
1650
1655
{
1651
- elog (WARNING , "MtmReplicationTxnFilterHook: args->origin_id=%d, MtmReplicationNodeId=%d" , args -> origin_id , MtmReplicationNodeId );
1652
1656
return args -> origin_id == InvalidRepOriginId || MtmIsRecoveredNode (MtmReplicationNodeId );
1653
1657
}
1654
1658
@@ -1795,7 +1799,6 @@ static bool MtmRunUtilityStmt(PGconn* conn, char const* sql, char **errmsg)
1795
1799
{
1796
1800
PGresult * result = PQexec (conn , sql );
1797
1801
int status = PQresultStatus (result );
1798
- char * errstr ;
1799
1802
1800
1803
bool ret = status == PGRES_COMMAND_OK || status == PGRES_TUPLES_OK ;
1801
1804
@@ -1815,25 +1818,18 @@ static bool MtmRunUtilityStmt(PGconn* conn, char const* sql, char **errmsg)
1815
1818
1816
1819
static void MtmBroadcastUtilityStmt (char const * sql , bool ignoreError )
1817
1820
{
1818
- char * conn_str = pstrdup (MtmConnStrs );
1819
- char * conn_str_end = conn_str + strlen (conn_str );
1820
1821
int i = 0 ;
1821
1822
nodemask_t disabledNodeMask = Mtm -> disabledNodeMask ;
1822
1823
int failedNode = -1 ;
1823
1824
char const * errorMsg = NULL ;
1824
1825
PGconn * * conns = palloc0 (sizeof (PGconn * )* MtmNodes );
1825
1826
char * utility_errmsg ;
1826
1827
1827
- while ( conn_str < conn_str_end )
1828
+ for ( i = 0 ; i < MtmNodes ; i ++ )
1828
1829
{
1829
- char * p = strchr (conn_str , ',' );
1830
- if (p == NULL ) {
1831
- p = conn_str_end ;
1832
- }
1833
- * p = '\0' ;
1834
1830
if (!BIT_CHECK (disabledNodeMask , i ))
1835
1831
{
1836
- conns [i ] = PQconnectdb (conn_str );
1832
+ conns [i ] = PQconnectdb (psprintf ( "%s application_name=%s" , Mtm -> nodes [ i ]. con . connStr , MULTIMASTER_BROADCAST_SERVICE ) );
1837
1833
if (PQstatus (conns [i ]) != CONNECTION_OK )
1838
1834
{
1839
1835
if (ignoreError )
@@ -1845,12 +1841,10 @@ static void MtmBroadcastUtilityStmt(char const* sql, bool ignoreError)
1845
1841
do {
1846
1842
PQfinish (conns [i ]);
1847
1843
} while (-- i >= 0 );
1848
- elog (ERROR , "Failed to establish connection '%s' to node %d" , conn_str , failedNode );
1844
+ elog (ERROR , "Failed to establish connection '%s' to node %d" , Mtm -> nodes [ i ]. con . connStr , failedNode );
1849
1845
}
1850
1846
}
1851
1847
}
1852
- conn_str = p + 1 ;
1853
- i += 1 ;
1854
1848
}
1855
1849
Assert (i == MtmNodes );
1856
1850
0 commit comments