taosdata / TDengine

High-performance, scalable time-series database designed for Industrial IoT (IIoT) scenarios
https://tdengine.com
GNU Affero General Public License v3.0
23.24k stars 4.84k forks source link

create table crash in batch #17088

Closed lw-leo closed 4 months ago

lw-leo commented 1 year ago

描述 批量创建子表时taos闪退, double free or corruption (fasttop)

复现环境

一、测试环境

taosd -V
community version: 3.0.1.2 compatible_version: 3.0.0.0
gitinfo: 287796b014d77d4127132c5aeb88453005dcb092
buildInfo: Built at 2022-09-22 15:33:26

taos -V
version: 3.0.1.2

uname -a
Linux leo 5.4.0-125-generic #141-Ubuntu SMP Wed Aug 10 13:42:03 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

二、库和超级表

create database if not exists `remote_control_db`;
create database if not exists `joystick_db`;
create database if not exists `sby_db`;

create stable if not exists `remote_control_db`.`remote_control_st` (
            ts              timestamp       ,
            h_version       binary(64)      ,
            s_version       binary(64)      ,
            use_count       smallint unsigned   ,
            ltp             tinyint unsigned    ,
            rtp             tinyint unsigned    ,
            failure         bigint unsigned      
        ) tags (
            sn binary(64)
        );

create stable if not exists `joystick_db`.`joystick_st` (
            ts         timestamp        ,
            type        tinyint unsigned    ,
            h_version   binary(64)      ,
            s_version   binary(64)      ,
            use_count   int unsigned    ,
            x           float           ,
            y           float           ,
            z           float           ,
            failure     bigint unsigned  
        ) tags (
            sn binary(64)
        );

create stable if not exists `sby_db`.`sby_st` (
            ts          timestamp   ,
            version         binary(64)      ,
            voltage         float       ,
            output_power    float   ,
            failure         bigint unsigned  
        ) tags (
            sn binary(64)
        );

复现方式

快速的支持下面的创建子表操作(执行一遍后快速的按上键和回车很快就能复现)

create table 
    if not exists `sby_db`.`sby_00000` using `sby_db`.`sby_st` tags ('ID_00000')
    if not exists `sby_db`.`sby_00001` using `sby_db`.`sby_st` tags ('ID_000001')
    if not exists `joystick_db`.`joy_00000` using `joystick_db`.`joystick_st` tags ('ID_00000')
    if not exists `joystick_db`.`joy_00001` using `joystick_db`.`joystick_st` tags ('ID_00001')
    if not exists `remote_control_db`.`rc_00000` using `remote_control_db`.`remote_control_st` tags ('ID_00000')
    if not exists `remote_control_db`.`rc_00001` using `remote_control_db`.`remote_control_st` tags ('ID_00001');

原因分析 释放pJob->execRes.res没要加锁

source/libs/scheduler/src/schRemote.c

int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t execId, SDataBuf *pMsg, int32_t rspCode) {
    ...
    case TDMT_VND_CREATE_TABLE_RSP: {
        ...
        SCH_LOCK(SCH_WRITE, &pJob->resLock);
        ...
        SCH_UNLOCK(SCH_WRITE, &pJob->resLock);

        if (taosArrayGetSize((SArray*)pJob->execRes.res) <= 0) {        
            taosArrayDestroy((SArray*)pJob->execRes.res);
            pJob->execRes.res = NULL;
            }
        break;
    }
    ...
}
yu285 commented 1 year ago

we will check ,thanks

yu285 commented 4 months ago

3.0早期版本的bug 都已经都修复了,但是3.0.2.5 之前可能与现在的最新版(3.3.0.0)并不兼容,所以无法直接升级。因此建议重新部署一下最新的 3.3.0.0 ,后续升级都很方便,直接安装最新版软件即可。

开源版支持操作系统范围:https://docs.taosdata.com/reference/support-platform/

如果还有类似问题可以加微信 a15652223354