MySQL Cluster ERROR失败,出现错误'收到错误240'未知错误代码'来自NDBCLUSTER'在查询

时间:2016-05-12 02:41:50

标签: java mysql jpa database-replication mysql-cluster

在我们的一个环境中,mysql复制间歇性地失败。以下是相关的mysql服务器日志。

    mysql> show slave status \G;
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000421
          Read_Master_Log_Pos: 997653853
               Relay_Log_File: mysql-relay-bin.000058
                Relay_Log_Pos: 498026393
        Relay_Master_Log_File: mysql-bin.000421
             Slave_IO_Running: Yes
            Slave_SQL_Running: No
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table: mysql.servers,mysql.proc,mysql.user,mysql.columns_priv,mysql.ndb_binlog_index,mysql.slow_log,mysql.event,mysql.tables_priv,mysql.procs_priv,mysql.func,mysql.general_log,mysql.db,mysql.plugin
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table: mysql.help%,ndbinfo.%,mysql.time_zone%,information_schema.%
                   Last_Errno: 1296
                   Last_Error: Error 'Got error 240 'Unknown error code' from NDBCLUSTER' on query. Default database: ''. Query: 'COMMIT'
        Seconds_Behind_Master: NULL
Master_SSL_Verify_Server_Cert: No
                Last_IO_Errno: 0
                Last_IO_Error:
               Last_SQL_Errno: 1296
               Last_SQL_Error: Error 'Got error 240 'Unknown error code' from NDBCLUSTER' on query. Default database: ''. Query: 'COMMIT'
  Replicate_Ignore_Server_Ids:
             Master_Server_Id: 22
                  Master_UUID: 
             Master_Info_File: /opt/mysql/cluster/server/database/master.info

1 row in set (0.00 sec)

Oracle支持建议与Forgein Key相关的此错误代码,以便我们能够隔离在特定失败时间发生的一些查询。

下面是最后一个sql sucessfuly插入主节点并且无法复制到slave。

### INSERT INTO `app_db`.`child_batch`
### SET
###   @1=2080
###   @4='000062'
### INSERT INTO `app_db`.`main_batch`
### SET
###   @1=648518346341351432
###   @6='NPROCESS\x02\x00\x00\x00\x00A\x00\x00\x00\x00\x00\x00\x00some_status\x00_app_event\x00ent\x00\x01\x0f\x11\x0f\x11\x0f\x08\x03@\x00\x00\x00'
###   @7=0

与child_batch和main_batch表相关的Intersting事件,都有ID作为主键,一个是另一个的FK(InheritanceType.JOINED)。

在JPA中,它被设计为InheritanceType.JOINED。

@Table(name = "main_batch")
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
public class MainBatch {

    protected Long id;
    protected Integer version;
    private String transactionId;

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    @Version
    public Integer getVersion() {
        return version;
    }

    @Column(name = "transaction_id")
    public String getTransactionId() {
        return transactionId;
    }

    public void setTransactionId(String transactionId) {
        this.transactionId = transactionId;
    }

}

@Table(name = "child_batch", uniqueConstraints = {
    @UniqueConstraint(columnNames = {
                "received_file_name"
        })
})
@Entity
public class ChildBatch extends MainBatch {

    private String receivedFileName;

    @Column(name = "received_file_name")
    public String getReceivedFileName() {
        return receivedFileName;
    }

    public void setReceivedFileName(String receivedFileName) {
        this.receivedFileName = receivedFileName;
    }

}
  • Mysql版本:NDB 7.3.3集群
  • OpenJPA:2.2.2
  • Java:1.7.0_79

由于Mysql支持说这与外键有关,我怀疑在main_batch和child_batch中的插入顺序在这里很重要。因为child_batch.id是main_batch.id的FK。因此,在插入child_batch记录之前,应首先提供main_batch记录。

如果有人有任何建议或想法,我们将不胜感激。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

尝试为memory增加cluster

如果cluster is low in memory发生此类错误。

请查看下面的帖子。

https://bugs.mysql.com/bug.php?id=73645