开发者社区> 问答> 正文

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

这是我的用户表方案:

-- 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)

它没有显示任何错误,我可以找出问题所在!

展开
收起
几许相思几点泪 2019-12-29 19:45:01 874 0
0 条回答
写回答
取消 提交回答
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载