change the xid construction method of dblink
This commit is contained in:
@ -39,18 +39,40 @@ int ObXAService::generate_xid(const ObTransID &tx_id, ObXATransID &new_xid)
|
|||||||
int64_t txid_value = tx_id.get_id();
|
int64_t txid_value = tx_id.get_id();
|
||||||
static const char *DBLINK_STR = "DBLINK.";
|
static const char *DBLINK_STR = "DBLINK.";
|
||||||
static const int DBLINK_STR_LENGTH = 7;
|
static const int DBLINK_STR_LENGTH = 7;
|
||||||
char txid_str[ObXATransID::MAX_GTRID_LENGTH] = {0};
|
char txid_str[ObXATransID::MAX_GTRID_LENGTH];
|
||||||
|
memset(txid_str, 0, ObXATransID::MAX_GTRID_LENGTH);
|
||||||
int txid_str_length = sprintf(txid_str, "%ld", txid_value);
|
int txid_str_length = sprintf(txid_str, "%ld", txid_value);
|
||||||
if (ObXATransID::MAX_GTRID_LENGTH < txid_str_length + DBLINK_STR_LENGTH) {
|
if (ObXATransID::MAX_GTRID_LENGTH < txid_str_length + DBLINK_STR_LENGTH) {
|
||||||
ret = OB_ERR_UNEXPECTED;
|
ret = OB_ERR_UNEXPECTED;
|
||||||
TRANS_LOG(WARN, "unexpected gtrid length", K(ret), K(txid_str_length));
|
TRANS_LOG(WARN, "unexpected gtrid length", K(ret), K(txid_str_length));
|
||||||
} else {
|
} else {
|
||||||
char gtrid_str[ObXATransID::MAX_GTRID_LENGTH] = {0};
|
char gtrid_str[ObXATransID::MAX_GTRID_LENGTH];
|
||||||
|
memset(gtrid_str, 0, ObXATransID::MAX_GTRID_LENGTH);
|
||||||
strncpy(gtrid_str, DBLINK_STR, DBLINK_STR_LENGTH);
|
strncpy(gtrid_str, DBLINK_STR, DBLINK_STR_LENGTH);
|
||||||
strncpy(gtrid_str + DBLINK_STR_LENGTH, txid_str, txid_str_length);
|
strncpy(gtrid_str + DBLINK_STR_LENGTH, txid_str, txid_str_length);
|
||||||
ObString gtrid_string = ObString(DBLINK_STR_LENGTH + txid_str_length, gtrid_str);
|
ObString gtrid_string;
|
||||||
|
if (GCONF.self_addr_.using_ipv4()) {
|
||||||
|
char ip_port[MAX_IP_PORT_LENGTH];
|
||||||
|
int ip_str_length = 0;
|
||||||
|
memset(ip_port, 0, MAX_IP_PORT_LENGTH);
|
||||||
|
if (OB_FAIL(GCONF.self_addr_.addr_to_buffer(ip_port, MAX_IP_PORT_LENGTH, ip_str_length))) {
|
||||||
|
TRANS_LOG(WARN, "convert server to string failed", K(ret), K(tx_id));
|
||||||
|
} else if (ObXATransID::MAX_GTRID_LENGTH < 1 + ip_str_length + txid_str_length + DBLINK_STR_LENGTH) {
|
||||||
|
ret = OB_ERR_UNEXPECTED;
|
||||||
|
TRANS_LOG(WARN, "unexpected gtrid length", K(ret), K(tx_id), K(txid_str_length), K(ip_port), K(ip_str_length));
|
||||||
|
} else {
|
||||||
|
const char *comma = ",";
|
||||||
|
strncpy(gtrid_str + DBLINK_STR_LENGTH + txid_str_length, comma, 1);
|
||||||
|
strncpy(gtrid_str + DBLINK_STR_LENGTH + txid_str_length + 1, ip_port, ip_str_length);
|
||||||
|
gtrid_string = ObString(DBLINK_STR_LENGTH + txid_str_length + 1 + ip_str_length, gtrid_str);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
gtrid_string = ObString(DBLINK_STR_LENGTH + txid_str_length, gtrid_str);
|
||||||
|
}
|
||||||
|
if (OB_SUCC(ret)) {
|
||||||
ret = new_xid.set(gtrid_string, BQUAL_STRING, DBLINK_FORMAT_ID);
|
ret = new_xid.set(gtrid_string, BQUAL_STRING, DBLINK_FORMAT_ID);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -269,7 +269,7 @@ private:
|
|||||||
|
|
||||||
// format id of dblink trans
|
// format id of dblink trans
|
||||||
// from Oracle
|
// from Oracle
|
||||||
static const int32_t DBLINK_FORMAT_ID = 306206;
|
static const int32_t DBLINK_FORMAT_ID = 830487;
|
||||||
class ObXADefault
|
class ObXADefault
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user