Mysql 超过锁定等待超时;尝试重新启动事务-插入语句

Mysql 超过锁定等待超时;尝试重新启动事务-插入语句,mysql,sql,Mysql,Sql,这是我的用户表方案: -- auto-generated definition CREATE TABLE Tb_Users ( user_id bigint UNSIGNED AUTO_INCREMENT PRIMARY KEY, username varchar(30) NULL, mobile varchar(11)

这是我的用户表方案:

-- auto-generated definition
CREATE TABLE Tb_Users (
    user_id             bigint UNSIGNED AUTO_INCREMENT
        PRIMARY KEY,
    username            varchar(30)                           NULL,
    mobile              varchar(11)                           NULL,
    password            varchar(100)                          NULL,
    name                varchar(100)                          NULL,
    family              varchar(150)                          NULL,
    email               varchar(100)                          NULL,
    national_id         varchar(10)                           NULL,
    company_national_id varchar(11)                           NULL,
    company_eco_code    varchar(12)                           NULL,
    company             varchar(250)                          NULL,
    sex                 tinyint                DEFAULT 1      NULL,
    tel                 varchar(20)                           NULL,
    marital_status      tinyint(1)             DEFAULT 0      NOT NULL,
    picture             varchar(255)                          NULL,
    birthday            datetime                              NULL,
    wedding_date        datetime                              NULL,
    wife_birthday       datetime                              NULL,
    description         varchar(255)                          NULL,
    is_active           tinyint(1)             DEFAULT 0      NULL,
    two_factor_enabled  tinyint(1)             DEFAULT 0      NULL,
    address             text                                  NULL,
    lang                varchar(5)                            NULL,
    type                enum ('real', 'legal') DEFAULT 'real' NULL,
    remember_token      varchar(100)                          NULL,
    country_id          int                                   NULL,
    province_id         int                                   NULL,
    city_id             int                                   NULL,
    level_id            int UNSIGNED           DEFAULT 1      NOT NULL,
    supervisor_id       bigint UNSIGNED                       NULL,
    activator_id        bigint UNSIGNED                       NULL,
    creator_id          bigint UNSIGNED                       NULL,
    updator_id          bigint UNSIGNED                       NULL,
    last_logined_at     datetime                              NULL,
    latitude            decimal(10, 8)                        NULL,
    longitude           decimal(10, 8)                        NULL,
    activated_at        datetime                              NULL,
    referral_user_id    bigint UNSIGNED                       NULL,
    created_at          datetime                              NULL,
    updated_at          datetime                              NULL,
    deleted_at          datetime                              NULL,
    personal_code       bigint UNSIGNED                       NULL,
    CONSTRAINT Tb_Users_personal_code_uindex
        UNIQUE (personal_code),
    CONSTRAINT users_company_eco_code_uindex
        UNIQUE (company_eco_code),
    CONSTRAINT users_company_national_id_uindex
        UNIQUE (company_national_id),
    CONSTRAINT users_email_uindex
        UNIQUE (email),
    CONSTRAINT users_mobile_uindex
        UNIQUE (mobile),
    CONSTRAINT users_national_id_uindex
        UNIQUE (national_id),
    CONSTRAINT users_username_uindex
        UNIQUE (username),
    CONSTRAINT Tb_Users_Tb_Users_activator_fk
        FOREIGN KEY (activator_id) REFERENCES Tb_Users (user_id)
            ON UPDATE SET NULL ON DELETE SET NULL,
    CONSTRAINT Tb_Users_Tb_Users_creator_fk
        FOREIGN KEY (creator_id) REFERENCES Tb_Users (user_id)
            ON UPDATE CASCADE ON DELETE CASCADE,
    CONSTRAINT Tb_Users_Tb_Users_refferal_user_id_fk
        FOREIGN KEY (referral_user_id) REFERENCES Tb_Users (user_id)
            ON UPDATE SET NULL ON DELETE SET NULL,
    CONSTRAINT Tb_Users_Tb_Users_supervisor_fk
        FOREIGN KEY (supervisor_id) REFERENCES Tb_Users (user_id)
            ON UPDATE SET NULL ON DELETE SET NULL
)
    ENGINE = InnoDB
    COLLATE = utf8mb4_unicode_ci;

CREATE INDEX Tb_Users_is_active_index
    ON Tb_Users (is_active);

CREATE INDEX users_club_levels_level_id_fk
    ON Tb_Users (level_id);
但当我想插入新记录时,我在查询50秒后收到了以下错误消息:

超过锁定等待超时;尝试重新启动事务

我的插入查询:

INSERT
INTO
    Tb_Users (user_id, username, mobile, password, name, family, email, national_id, company_national_id, company_eco_code, company, sex, tel, marital_status, picture, birthday, wedding_date, wife_birthday, description, is_active, two_factor_enabled, address, lang, type, remember_token, country_id, province_id, city_id, level_id, supervisor_id, activator_id, creator_id, updator_id, last_logined_at, latitude, longitude, activated_at, referral_user_id, created_at, updated_at, deleted_at, personal_code)
VALUES
(8473, '9120882602', '09120882602', null, 'ali', 'ghodrati', null, null, null, null, null, 0, null, 0, null, '1993-02-28 00:00:00', '1970-01-01 03:30:00', '1970-01-01 03:30:00', null, 1, 0, null, 'fa', 'real', null, 102, null, null, 1, 8402, 8402, 8402, null, null, null, null, '2019-12-29 08:59:20', null, '2019-12-14 21:38:59', null, null, 123)
它没有显示任何错误,我可以找到问题

已解决


我重新启动了服务器。成功了

表被另一个事务阻止(insert/update/index rebuild/…)否,因为我可以通过另一个web服务读写。问题是我的查询,但我找不到问题。因此,您可能有未显式关闭的打开事务<代码>开始传输。。。插入到。。。提交或应用程序代码Java/C#/PHP的等效代码