use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class MultiNodeDdlHandler method errorResponse.
@Override
public void errorResponse(byte[] data, BackendConnection conn) {
ErrorPacket errPacket = new ErrorPacket();
errPacket.read(data);
errPacket.setPacketId(1);
err = errPacket;
lock.lock();
try {
if (!isFail()) {
setFail(new String(errPacket.getMessage()));
}
if (!conn.syncAndExecute()) {
return;
}
if (--nodeCount > 0)
return;
handleEndPacket(err.toBytes(), AutoTxOperation.ROLLBACK, conn);
} finally {
lock.unlock();
}
}
use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class NormalRollbackNodesHandler method errorResponse.
@Override
public void errorResponse(byte[] err, BackendConnection conn) {
ErrorPacket errPacket = new ErrorPacket();
errPacket.read(err);
String errMsg = new String(errPacket.getMessage());
this.setFail(errMsg);
// quit to rollback
conn.quit();
if (decrementCountBy(1)) {
cleanAndFeedback();
}
}
use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class XARollbackNodesHandler method errorResponse.
@Override
public void errorResponse(byte[] err, BackendConnection conn) {
this.waitUntilSendFinish();
if (conn instanceof MySQLConnection) {
MySQLConnection mysqlCon = (MySQLConnection) conn;
if (mysqlCon.getXaStatus() == TxState.TX_STARTED_STATE) {
mysqlCon.quit();
mysqlCon.setXaStatus(TxState.TX_ROLLBACKED_STATE);
XAStateLog.saveXARecoveryLog(session.getSessionXaID(), mysqlCon);
if (decrementCountBy(1)) {
session.setXaState(TxState.TX_ENDED_STATE);
rollback();
}
// 'xa rollback' ok without prepared
} else if (mysqlCon.getXaStatus() == TxState.TX_ENDED_STATE) {
mysqlCon.quit();
mysqlCon.setXaStatus(TxState.TX_ROLLBACKED_STATE);
XAStateLog.saveXARecoveryLog(session.getSessionXaID(), mysqlCon);
if (decrementCountBy(1)) {
session.setXaState(TxState.TX_INITIALIZE_STATE);
cleanAndFeedback();
}
// 'xa rollback' err
} else if (mysqlCon.getXaStatus() == TxState.TX_ROLLBACK_FAILED_STATE || mysqlCon.getXaStatus() == TxState.TX_PREPARED_STATE) {
mysqlCon.setXaStatus(TxState.TX_ROLLBACK_FAILED_STATE);
mysqlCon.quit();
XAStateLog.saveXARecoveryLog(session.getSessionXaID(), mysqlCon);
session.setXaState(TxState.TX_ROLLBACK_FAILED_STATE);
if (decrementCountBy(1)) {
cleanAndFeedback();
}
// we don't know if the conn prepared or not
} else if (mysqlCon.getXaStatus() == TxState.TX_PREPARE_UNCONNECT_STATE) {
ErrorPacket errPacket = new ErrorPacket();
errPacket.read(err);
if (errPacket.getErrNo() == ErrorCode.ER_XAER_NOTA) {
// ERROR 1397 (XAE04): XAER_NOTA: Unknown XID, not prepared
mysqlCon.setXaStatus(TxState.TX_ROLLBACKED_STATE);
XAStateLog.saveXARecoveryLog(session.getSessionXaID(), mysqlCon);
mysqlCon.setXaStatus(TxState.TX_INITIALIZE_STATE);
if (decrementCountBy(1)) {
if (session.getXaState() == TxState.TX_PREPARED_STATE) {
session.setXaState(TxState.TX_INITIALIZE_STATE);
}
cleanAndFeedback();
}
} else {
session.setXaState(TxState.TX_ROLLBACK_FAILED_STATE);
XAStateLog.saveXARecoveryLog(session.getSessionXaID(), mysqlCon);
if (decrementCountBy(1)) {
cleanAndFeedback();
}
}
} else {
LOGGER.info("Wrong XA status flag!");
}
}
}
use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class UViewChildResponse method notifyProcess.
@Override
public void notifyProcess(UKvBean configValue) throws Exception {
LOGGER.debug("notify " + configValue.getKey() + " " + configValue.getValue() + " " + configValue.getChangeType());
if (configValue.getKey().split("/").length != UcorePathUtil.getViewChangePath().split("/").length + 1) {
// only with the type u.../d.../clu.../view/update(delete)/schema.table
return;
}
String schema = configValue.getKey().split("/")[5].split(Repository.SCHEMA_VIEW_SPLIT)[0];
String viewName = configValue.getKey().split(Repository.SCHEMA_VIEW_SPLIT)[1];
if ("".equals(configValue.getValue())) {
// the value of key is empty,just doing nothing
return;
}
String serverId = configValue.getValue().split(Repository.SCHEMA_VIEW_SPLIT)[0];
String optionType = configValue.getValue().split(Repository.SCHEMA_VIEW_SPLIT)[1];
String myId = UcoreConfig.getInstance().getValue(ClusterParamCfg.CLUSTER_CFG_MYID);
if (myId.equals(serverId) || configValue.getChangeType() == UKvBean.DELETE) {
// self node do noting
return;
} else {
try {
if (Repository.DELETE.equals(optionType)) {
LOGGER.debug("delete view " + configValue.getKey() + " " + configValue.getValue() + " " + configValue.getChangeType());
if (!DbleServer.getInstance().getTmManager().getCatalogs().get(schema).getViewMetas().containsKey(viewName)) {
return;
}
DbleServer.getInstance().getTmManager().getCatalogs().get(schema).getViewMetas().remove(viewName);
ClusterUcoreSender.sendDataToUcore(configValue.getKey() + SEPARATOR + myId, UcorePathUtil.SUCCESS);
} else if (Repository.UPDATE.equals(optionType)) {
LOGGER.debug("update view " + configValue.getKey() + " " + configValue.getValue() + " " + configValue.getChangeType());
String stmt = ClusterUcoreSender.getKey(UcorePathUtil.getViewPath() + SEPARATOR + schema + Repository.SCHEMA_VIEW_SPLIT + viewName).getValue();
if (DbleServer.getInstance().getTmManager().getCatalogs().get(schema).getViewMetas().get(viewName) != null && stmt.equals(DbleServer.getInstance().getTmManager().getCatalogs().get(schema).getViewMetas().get(viewName).getCreateSql())) {
return;
}
ViewMeta vm = new ViewMeta(stmt, schema, DbleServer.getInstance().getTmManager());
ErrorPacket error = vm.initAndSet(true);
Map<String, Map<String, String>> viewCreateSqlMap = DbleServer.getInstance().getTmManager().getRepository().getViewCreateSqlMap();
Map<String, String> schemaMap = viewCreateSqlMap.get(schema);
schemaMap.put(viewName, stmt);
LOGGER.debug("update view result == " + error);
if (error != null) {
ClusterUcoreSender.sendDataToUcore(configValue.getKey() + SEPARATOR + myId, new String(error.getMessage()));
return;
}
ClusterUcoreSender.sendDataToUcore(configValue.getKey() + SEPARATOR + myId, UcorePathUtil.SUCCESS);
}
} catch (Exception e) {
ClusterUcoreSender.sendDataToUcore(configValue.getKey() + "/" + myId, e.toString());
}
}
}
use of com.actiontech.dble.net.mysql.ErrorPacket in project dble by actiontech.
the class SQLJob method errorResponse.
@Override
public void errorResponse(byte[] err, BackendConnection conn) {
ErrorPacket errPg = new ErrorPacket();
errPg.read(err);
String errMsg = "error response errNo:" + errPg.getErrNo() + ", " + new String(errPg.getMessage()) + " from of sql :" + sql + " at con:" + conn;
if (errPg.getErrNo() == ErrorCode.ER_SPECIFIC_ACCESS_DENIED_ERROR) {
// @see https://dev.mysql.com/doc/refman/5.6/en/error-messages-server.html
LOGGER.info(errMsg);
} else if (errPg.getErrNo() == ErrorCode.ER_XAER_NOTA) {
// ERROR 1397 (XAE04): XAER_NOTA: Unknown XID, not prepared
conn.release();
doFinished(false);
return;
} else {
LOGGER.info(errMsg);
}
conn.release();
doFinished(true);
}
Aggregations