[TD-225]
This commit is contained in:
commit
cb5bc95969
|
@ -27,6 +27,7 @@ pipeline {
|
||||||
cd debug
|
cd debug
|
||||||
cmake .. > /dev/null
|
cmake .. > /dev/null
|
||||||
make > /dev/null
|
make > /dev/null
|
||||||
|
make install > /dev/null
|
||||||
cd ${WKC}/tests
|
cd ${WKC}/tests
|
||||||
#./test-all.sh smoke
|
#./test-all.sh smoke
|
||||||
./test-all.sh pytest
|
./test-all.sh pytest
|
||||||
|
@ -89,7 +90,6 @@ pipeline {
|
||||||
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
|
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
|
||||||
sh '''
|
sh '''
|
||||||
cd ${WKC}/tests/pytest
|
cd ${WKC}/tests/pytest
|
||||||
./crash_gen.sh --valgrind -p -t 10 -s 100 -b 4
|
|
||||||
./handle_crash_gen_val_log.sh
|
./handle_crash_gen_val_log.sh
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ ELSEIF (TD_WINDOWS)
|
||||||
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/go DESTINATION connector)
|
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/go DESTINATION connector)
|
||||||
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/nodejs DESTINATION connector)
|
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/nodejs DESTINATION connector)
|
||||||
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/python DESTINATION connector)
|
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/python DESTINATION connector)
|
||||||
|
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/src/connector/C\# DESTINATION connector)
|
||||||
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/tests/examples DESTINATION .)
|
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/tests/examples DESTINATION .)
|
||||||
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/packaging/cfg DESTINATION .)
|
INSTALL(DIRECTORY ${TD_COMMUNITY_DIR}/packaging/cfg DESTINATION .)
|
||||||
INSTALL(FILES ${TD_COMMUNITY_DIR}/src/inc/taos.h DESTINATION include)
|
INSTALL(FILES ${TD_COMMUNITY_DIR}/src/inc/taos.h DESTINATION include)
|
||||||
|
|
|
@ -34,7 +34,8 @@ TDengine是一个高效的存储、查询、分析时序大数据的平台,专
|
||||||
- [SQL写入](https://www.taosdata.com/cn/documentation20/insert/#SQL写入):使用SQL insert命令向一张或多张表写入单条或多条记录
|
- [SQL写入](https://www.taosdata.com/cn/documentation20/insert/#SQL写入):使用SQL insert命令向一张或多张表写入单条或多条记录
|
||||||
- [Telegraf写入](https://www.taosdata.com/cn/documentation20/insert/#Telegraf直接写入):配置Telegraf, 不用任何代码,将采集数据直接写入
|
- [Telegraf写入](https://www.taosdata.com/cn/documentation20/insert/#Telegraf直接写入):配置Telegraf, 不用任何代码,将采集数据直接写入
|
||||||
- [Prometheus写入](https://www.taosdata.com/cn/documentation20/insert/#Prometheus直接写入):配置Prometheus, 不用任何代码,将数据直接写入
|
- [Prometheus写入](https://www.taosdata.com/cn/documentation20/insert/#Prometheus直接写入):配置Prometheus, 不用任何代码,将数据直接写入
|
||||||
- [EMQ X Broker](https://www.taosdata.com/cn/documentation20/insert/#EMQ-X-Broker直接写入):配置EMQ X,不用任何代码,就可将MQTT数据直接写入
|
- [EMQ X Broker](https://www.taosdata.com/cn/documentation20/insert/#EMQ-X-Broker直接写入):配置EMQ X,不用任何代码,就可将 MQTT 数据直接写入
|
||||||
|
- [HiveMQ Broker](https://www.taosdata.com/cn/documentation20/insert/#HiveMQ-Broker直接写入):通过 HiveMQ Extension,不用任何代码,就可将 MQTT 数据直接写入
|
||||||
|
|
||||||
## [高效查询数据](https://www.taosdata.com/cn/documentation20/queries)
|
## [高效查询数据](https://www.taosdata.com/cn/documentation20/queries)
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ TDengine的模块之一是时序数据库。但除此之外,为减少研发的
|
||||||
* __硬件或云服务成本降至1/5__:由于超强性能,计算资源不到通用大数据方案的1/5;通过列式存储和先进的压缩算法,存储空间不到通用数据库的1/10。
|
* __硬件或云服务成本降至1/5__:由于超强性能,计算资源不到通用大数据方案的1/5;通过列式存储和先进的压缩算法,存储空间不到通用数据库的1/10。
|
||||||
* __全栈时序数据处理引擎__:将数据库、消息队列、缓存、流式计算等功能融为一体,应用无需再集成Kafka/Redis/HBase/Spark/HDFS等软件,大幅降低应用开发和维护的复杂度成本。
|
* __全栈时序数据处理引擎__:将数据库、消息队列、缓存、流式计算等功能融为一体,应用无需再集成Kafka/Redis/HBase/Spark/HDFS等软件,大幅降低应用开发和维护的复杂度成本。
|
||||||
* __强大的分析功能__:无论是十年前还是一秒钟前的数据,指定时间范围即可查询。数据可在时间轴上或多个设备上进行聚合。即席查询可通过Shell, Python, R, Matlab随时进行。
|
* __强大的分析功能__:无论是十年前还是一秒钟前的数据,指定时间范围即可查询。数据可在时间轴上或多个设备上进行聚合。即席查询可通过Shell, Python, R, Matlab随时进行。
|
||||||
* __与第三方工具无缝连接__:不用一行代码,即可与Telegraf, Grafana, EMQ, Prometheus, Matlab, R等集成。后续将支持OPC, Hadoop, Spark等, BI工具也将无缝连接。
|
* __与第三方工具无缝连接__:不用一行代码,即可与Telegraf, Grafana, EMQ, HiveMQ, Prometheus, Matlab, R等集成。后续将支持OPC, Hadoop, Spark等, BI工具也将无缝连接。
|
||||||
* __零运维成本、零学习成本__:安装集群简单快捷,无需分库分表,实时备份。类似标准SQL,支持RESTful, 支持Python/Java/C/C++/C#/Go/Node.js, 与MySQL相似,零学习成本。
|
* __零运维成本、零学习成本__:安装集群简单快捷,无需分库分表,实时备份。类似标准SQL,支持RESTful, 支持Python/Java/C/C++/C#/Go/Node.js, 与MySQL相似,零学习成本。
|
||||||
|
|
||||||
采用TDengine,可将典型的物联网、车联网、工业互联网大数据平台的总拥有成本大幅降低。但需要指出的是,因充分利用了物联网时序数据的特点,它无法用来处理网络爬虫、微博、微信、电商、ERP、CRM等通用型数据。
|
采用TDengine,可将典型的物联网、车联网、工业互联网大数据平台的总拥有成本大幅降低。但需要指出的是,因充分利用了物联网时序数据的特点,它无法用来处理网络爬虫、微博、微信、电商、ERP、CRM等通用型数据。
|
||||||
|
|
|
@ -253,7 +253,7 @@ ALTER USER <user_name> PASS <'password'>;
|
||||||
修改用户密码, 为避免被转换为小写,密码需要用单引号引用,单引号为英文半角
|
修改用户密码, 为避免被转换为小写,密码需要用单引号引用,单引号为英文半角
|
||||||
|
|
||||||
```
|
```
|
||||||
ALTER USER <user_name> PRIVILEDGE <super|write|read>;
|
ALTER USER <user_name> PRIVILEGE <super|write|read>;
|
||||||
```
|
```
|
||||||
|
|
||||||
修改用户权限为:super/write/read,不需要添加单引号
|
修改用户权限为:super/write/read,不需要添加单引号
|
||||||
|
|
|
@ -221,7 +221,7 @@ TDengine采用时间驱动缓存管理策略(First-In-First-Out,FIFO),
|
||||||
|
|
||||||
TDengine通过查询函数向用户提供毫秒级的数据获取能力。直接将最近到达的数据保存在缓存中,可以更加快速地响应用户针对最近一条或一批数据的查询分析,整体上提供更快的数据库查询响应能力。从这个意义上来说,**可通过设置合适的配置参数将TDengine作为数据缓存来使用,而不需要再部署Redis或其他额外的缓存系统**,可有效地简化系统架构,降低运维的成本。需要注意的是,TDengine重启以后系统的缓存将被清空,之前缓存的数据均会被批量写入磁盘,缓存的数据将不会像专门的Key-value缓存系统再将之前缓存的数据重新加载到缓存中。
|
TDengine通过查询函数向用户提供毫秒级的数据获取能力。直接将最近到达的数据保存在缓存中,可以更加快速地响应用户针对最近一条或一批数据的查询分析,整体上提供更快的数据库查询响应能力。从这个意义上来说,**可通过设置合适的配置参数将TDengine作为数据缓存来使用,而不需要再部署Redis或其他额外的缓存系统**,可有效地简化系统架构,降低运维的成本。需要注意的是,TDengine重启以后系统的缓存将被清空,之前缓存的数据均会被批量写入磁盘,缓存的数据将不会像专门的Key-value缓存系统再将之前缓存的数据重新加载到缓存中。
|
||||||
|
|
||||||
每个vnode有自己独立的内存,而且由多个固定大小的内存块组成,不同vnode之间完全隔离。数据写入时,类似于日志的写法,数据被顺序追加写入内存,但每个vnode维护有自己的skip list,便于迅速查找。当一半以上的内存块写满时,启动落盘操作,而且后续写的操作在新的内存块进行。这样,一个vnode里有一半内存块是保留有最近的数据的,以达到缓存、快速查找的目的。一个vnode的内存块的个数由配置参数blocks决定,内存块的大小由配置参数cache决定。
|
每个vnode有自己独立的内存,而且由多个固定大小的内存块组成,不同vnode之间完全隔离。数据写入时,类似于日志的写法,数据被顺序追加写入内存,但每个vnode维护有自己的skip list,便于迅速查找。当三分之一以上的内存块写满时,启动落盘操作,而且后续写的操作在新的内存块进行。这样,一个vnode里有三分之一内存块是保留有最近的数据的,以达到缓存、快速查找的目的。一个vnode的内存块的个数由配置参数blocks决定,内存块的大小由配置参数cache决定。
|
||||||
|
|
||||||
### 持久化存储
|
### 持久化存储
|
||||||
TDengine采用数据驱动的方式让缓存中的数据写入硬盘进行持久化存储。当vnode中缓存的数据达到一定规模时,为了不阻塞后续数据的写入,TDengine也会拉起落盘线程将缓存的数据写入持久化存储。TDengine在数据落盘时会打开新的数据库日志文件,在落盘成功后则会删除老的数据库日志文件,避免日志文件无限制的增长。
|
TDengine采用数据驱动的方式让缓存中的数据写入硬盘进行持久化存储。当vnode中缓存的数据达到一定规模时,为了不阻塞后续数据的写入,TDengine也会拉起落盘线程将缓存的数据写入持久化存储。TDengine在数据落盘时会打开新的数据库日志文件,在落盘成功后则会删除老的数据库日志文件,避免日志文件无限制的增长。
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# 高效写入数据
|
# 高效写入数据
|
||||||
|
|
||||||
TDengine支持多种接口写入数据,包括SQL, Prometheus, Telegraf, EMQ MQTT Broker, CSV文件等,后续还将提供Kafka, OPC等接口。数据可以单条插入,也可以批量插入,可以插入一个数据采集点的数据,也可以同时插入多个数据采集点的数据。支持多线程插入,支持时间乱序数据插入,也支持历史数据插入。
|
TDengine支持多种接口写入数据,包括SQL, Prometheus, Telegraf, EMQ MQTT Broker, HiveMQ Broker, CSV文件等,后续还将提供Kafka, OPC等接口。数据可以单条插入,也可以批量插入,可以插入一个数据采集点的数据,也可以同时插入多个数据采集点的数据。支持多线程插入,支持时间乱序数据插入,也支持历史数据插入。
|
||||||
|
|
||||||
## SQL写入
|
## SQL写入
|
||||||
|
|
||||||
|
@ -218,7 +218,15 @@ use telegraf;
|
||||||
select * from cpu;
|
select * from cpu;
|
||||||
```
|
```
|
||||||
|
|
||||||
## EMQ X Broker直接写入
|
|
||||||
|
|
||||||
MQTT是一流行的物联网数据传输协议,[EMQ](https://github.com/emqx/emqx)是一开源的MQTT Broker软件,无需任何代码,只需要在EMQ Dashboard里使用“规则”做简单配置,即可将MQTT的数据直接写入TDengine。EMQ X 支持通过 发送到 Web 服务 的方式保存数据到 TDEngine,也在企业版上提供原生的 TDEngine 驱动实现直接保存。详细使用方法请参考 [EMQ 官方文档](https://docs.emqx.io/broker/latest/cn/rule/rule-example.html#%E4%BF%9D%E5%AD%98%E6%95%B0%E6%8D%AE%E5%88%B0-tdengine)。
|
|
||||||
|
MQTT是一流行的物联网数据传输协议,TDengine 可以很方便的接入 MQTT Broker 接受的数据并写入到 TDengine。
|
||||||
|
|
||||||
|
## EMQ Broker 直接写入
|
||||||
|
|
||||||
|
[EMQ](https://github.com/emqx/emqx)是一开源的MQTT Broker软件,无需任何代码,只需要在EMQ Dashboard里使用“规则”做简单配置,即可将MQTT的数据直接写入TDengine。EMQ X 支持通过 发送到 Web 服务 的方式保存数据到 TDengine,也在企业版上提供原生的 TDEngine 驱动实现直接保存。详细使用方法请参考 [EMQ 官方文档](https://docs.emqx.io/broker/latest/cn/rule/rule-example.html#%E4%BF%9D%E5%AD%98%E6%95%B0%E6%8D%AE%E5%88%B0-tdengine)。
|
||||||
|
|
||||||
|
## HiveMQ Broker 直接写入
|
||||||
|
|
||||||
|
[HiveMQ](https://www.hivemq.com/) 是一个提供免费个人版和企业版的 MQTT 代理,主要用于企业和新兴的机器到机器M2M通讯和内部传输,满足可伸缩性、易管理和安全特性。HiveMQ 提供了开源的插件开发包。可以通过 HiveMQ extension - TDengine 保存数据到 TDengine。详细使用方法请参考 [HiveMQ extension - TDengine 说明文档](https://github.com/huskar-t/hivemq-tdengine-extension/blob/b62a26ecc164a310104df57691691b237e091c89/README.md)。
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ cp ${compile_dir}/../packaging/deb/taosd ${pkg_dir}${install_home_pat
|
||||||
cp ${compile_dir}/../packaging/tools/post.sh ${pkg_dir}${install_home_path}/script
|
cp ${compile_dir}/../packaging/tools/post.sh ${pkg_dir}${install_home_path}/script
|
||||||
cp ${compile_dir}/../packaging/tools/preun.sh ${pkg_dir}${install_home_path}/script
|
cp ${compile_dir}/../packaging/tools/preun.sh ${pkg_dir}${install_home_path}/script
|
||||||
cp ${compile_dir}/build/bin/taosdemo ${pkg_dir}${install_home_path}/bin
|
cp ${compile_dir}/build/bin/taosdemo ${pkg_dir}${install_home_path}/bin
|
||||||
|
#cp ${compile_dir}/build/bin/taosdump ${pkg_dir}${install_home_path}/bin
|
||||||
cp ${compile_dir}/build/bin/taosd ${pkg_dir}${install_home_path}/bin
|
cp ${compile_dir}/build/bin/taosd ${pkg_dir}${install_home_path}/bin
|
||||||
cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin
|
cp ${compile_dir}/build/bin/taos ${pkg_dir}${install_home_path}/bin
|
||||||
cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_path}/driver
|
cp ${compile_dir}/build/lib/${libfile} ${pkg_dir}${install_home_path}/driver
|
||||||
|
|
|
@ -58,6 +58,7 @@ cp %{_compiledir}/../packaging/tools/preun.sh %{buildroot}%{homepath}/scri
|
||||||
cp %{_compiledir}/build/bin/taos %{buildroot}%{homepath}/bin
|
cp %{_compiledir}/build/bin/taos %{buildroot}%{homepath}/bin
|
||||||
cp %{_compiledir}/build/bin/taosd %{buildroot}%{homepath}/bin
|
cp %{_compiledir}/build/bin/taosd %{buildroot}%{homepath}/bin
|
||||||
cp %{_compiledir}/build/bin/taosdemo %{buildroot}%{homepath}/bin
|
cp %{_compiledir}/build/bin/taosdemo %{buildroot}%{homepath}/bin
|
||||||
|
#cp %{_compiledir}/build/bin/taosdump %{buildroot}%{homepath}/bin
|
||||||
cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver
|
cp %{_compiledir}/build/lib/${libfile} %{buildroot}%{homepath}/driver
|
||||||
cp %{_compiledir}/../src/inc/taos.h %{buildroot}%{homepath}/include
|
cp %{_compiledir}/../src/inc/taos.h %{buildroot}%{homepath}/include
|
||||||
cp %{_compiledir}/../src/inc/taoserror.h %{buildroot}%{homepath}/include
|
cp %{_compiledir}/../src/inc/taoserror.h %{buildroot}%{homepath}/include
|
||||||
|
@ -134,6 +135,7 @@ if [ $1 -eq 0 ];then
|
||||||
${csudo} rm -f ${bin_link_dir}/taos || :
|
${csudo} rm -f ${bin_link_dir}/taos || :
|
||||||
${csudo} rm -f ${bin_link_dir}/taosd || :
|
${csudo} rm -f ${bin_link_dir}/taosd || :
|
||||||
${csudo} rm -f ${bin_link_dir}/taosdemo || :
|
${csudo} rm -f ${bin_link_dir}/taosdemo || :
|
||||||
|
#${csudo} rm -f ${bin_link_dir}/taosdump || :
|
||||||
${csudo} rm -f ${cfg_link_dir}/* || :
|
${csudo} rm -f ${cfg_link_dir}/* || :
|
||||||
${csudo} rm -f ${inc_link_dir}/taos.h || :
|
${csudo} rm -f ${inc_link_dir}/taos.h || :
|
||||||
${csudo} rm -f ${inc_link_dir}/taoserror.h || :
|
${csudo} rm -f ${inc_link_dir}/taoserror.h || :
|
||||||
|
|
|
@ -45,6 +45,7 @@ if [ "$osType" != "Darwin" ]; then
|
||||||
strip ${build_dir}/bin/taos
|
strip ${build_dir}/bin/taos
|
||||||
bin_files="${build_dir}/bin/taos ${script_dir}/remove_client.sh"
|
bin_files="${build_dir}/bin/taos ${script_dir}/remove_client.sh"
|
||||||
else
|
else
|
||||||
|
#bin_files="${build_dir}/bin/taos ${build_dir}/bin/taosdump ${build_dir}/bin/taosdemo ${script_dir}/remove_client.sh ${script_dir}/set_core.sh"
|
||||||
bin_files="${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${script_dir}/remove_client.sh ${script_dir}/set_core.sh"
|
bin_files="${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${script_dir}/remove_client.sh ${script_dir}/set_core.sh"
|
||||||
fi
|
fi
|
||||||
lib_files="${build_dir}/lib/libtaos.so.${version}"
|
lib_files="${build_dir}/lib/libtaos.so.${version}"
|
||||||
|
|
|
@ -36,6 +36,7 @@ if [ "$pagMode" == "lite" ]; then
|
||||||
strip ${build_dir}/bin/taos
|
strip ${build_dir}/bin/taos
|
||||||
bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${script_dir}/remove.sh"
|
bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${script_dir}/remove.sh"
|
||||||
else
|
else
|
||||||
|
#bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdump ${build_dir}/bin/taosdemo ${build_dir}/bin/tarbitrator ${script_dir}/remove.sh ${script_dir}/set_core.sh"
|
||||||
bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${build_dir}/bin/tarbitrator ${script_dir}/remove.sh ${script_dir}/set_core.sh"
|
bin_files="${build_dir}/bin/taosd ${build_dir}/bin/taos ${build_dir}/bin/taosdemo ${build_dir}/bin/tarbitrator ${script_dir}/remove.sh ${script_dir}/set_core.sh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -330,6 +330,7 @@ typedef struct STscObj {
|
||||||
char writeAuth : 1;
|
char writeAuth : 1;
|
||||||
char superAuth : 1;
|
char superAuth : 1;
|
||||||
uint32_t connId;
|
uint32_t connId;
|
||||||
|
uint64_t rid; // ref ID returned by taosAddRef
|
||||||
struct SSqlObj * pHb;
|
struct SSqlObj * pHb;
|
||||||
struct SSqlObj * sqlList;
|
struct SSqlObj * sqlList;
|
||||||
struct SSqlStream *streamList;
|
struct SSqlStream *streamList;
|
||||||
|
@ -348,7 +349,7 @@ typedef struct SSqlObj {
|
||||||
void *signature;
|
void *signature;
|
||||||
pthread_t owner; // owner of sql object, by which it is executed
|
pthread_t owner; // owner of sql object, by which it is executed
|
||||||
STscObj *pTscObj;
|
STscObj *pTscObj;
|
||||||
void *pRpcCtx;
|
int64_t rpcRid;
|
||||||
void (*fp)();
|
void (*fp)();
|
||||||
void (*fetchFp)();
|
void (*fetchFp)();
|
||||||
void *param;
|
void *param;
|
||||||
|
|
|
@ -2118,7 +2118,7 @@ static void copyTopBotRes(SQLFunctionCtx *pCtx, int32_t type) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pData);
|
tfree(pData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -97,6 +97,9 @@ static void tscInitSqlContext(SSqlCmd *pCmd, SLocalReducer *pReducer, tOrderDesc
|
||||||
pCtx->param[2].i64Key = pQueryInfo->order.order;
|
pCtx->param[2].i64Key = pQueryInfo->order.order;
|
||||||
pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
|
pCtx->param[2].nType = TSDB_DATA_TYPE_BIGINT;
|
||||||
pCtx->param[1].i64Key = pQueryInfo->order.orderColId;
|
pCtx->param[1].i64Key = pQueryInfo->order.orderColId;
|
||||||
|
} else if (functionId == TSDB_FUNC_APERCT) {
|
||||||
|
pCtx->param[0].i64Key = pExpr->param[0].i64Key;
|
||||||
|
pCtx->param[0].nType = pExpr->param[0].nType;
|
||||||
}
|
}
|
||||||
|
|
||||||
pCtx->interBufBytes = pExpr->interBytes;
|
pCtx->interBufBytes = pExpr->interBytes;
|
||||||
|
@ -224,7 +227,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
||||||
if (ds == NULL) {
|
if (ds == NULL) {
|
||||||
tscError("%p failed to create merge structure", pSql);
|
tscError("%p failed to create merge structure", pSql);
|
||||||
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
taosTFree(pReducer);
|
tfree(pReducer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,7 +254,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
||||||
|
|
||||||
if (ds->filePage.num == 0) { // no data in this flush, the index does not increase
|
if (ds->filePage.num == 0) { // no data in this flush, the index does not increase
|
||||||
tscDebug("%p flush data is empty, ignore %d flush record", pSql, idx);
|
tscDebug("%p flush data is empty, ignore %d flush record", pSql, idx);
|
||||||
taosTFree(ds);
|
tfree(ds);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +264,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
||||||
|
|
||||||
// no data actually, no need to merge result.
|
// no data actually, no need to merge result.
|
||||||
if (idx == 0) {
|
if (idx == 0) {
|
||||||
taosTFree(pReducer);
|
tfree(pReducer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +272,7 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
||||||
|
|
||||||
SCompareParam *param = malloc(sizeof(SCompareParam));
|
SCompareParam *param = malloc(sizeof(SCompareParam));
|
||||||
if (param == NULL) {
|
if (param == NULL) {
|
||||||
taosTFree(pReducer);
|
tfree(pReducer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,8 +286,8 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
||||||
|
|
||||||
pRes->code = tLoserTreeCreate(&pReducer->pLoserTree, pReducer->numOfBuffer, param, treeComparator);
|
pRes->code = tLoserTreeCreate(&pReducer->pLoserTree, pReducer->numOfBuffer, param, treeComparator);
|
||||||
if (pReducer->pLoserTree == NULL || pRes->code != 0) {
|
if (pReducer->pLoserTree == NULL || pRes->code != 0) {
|
||||||
taosTFree(param);
|
tfree(param);
|
||||||
taosTFree(pReducer);
|
tfree(pReducer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -327,14 +330,14 @@ void tscCreateLocalReducer(tExtMemBuffer **pMemBuffer, int32_t numOfBuffer, tOrd
|
||||||
|
|
||||||
if (pReducer->pTempBuffer == NULL || pReducer->discardData == NULL || pReducer->pResultBuf == NULL ||
|
if (pReducer->pTempBuffer == NULL || pReducer->discardData == NULL || pReducer->pResultBuf == NULL ||
|
||||||
/*pReducer->pBufForInterpo == NULL || */pReducer->pFinalRes == NULL || pReducer->prevRowOfInput == NULL) {
|
/*pReducer->pBufForInterpo == NULL || */pReducer->pFinalRes == NULL || pReducer->prevRowOfInput == NULL) {
|
||||||
taosTFree(pReducer->pTempBuffer);
|
tfree(pReducer->pTempBuffer);
|
||||||
taosTFree(pReducer->discardData);
|
tfree(pReducer->discardData);
|
||||||
taosTFree(pReducer->pResultBuf);
|
tfree(pReducer->pResultBuf);
|
||||||
taosTFree(pReducer->pFinalRes);
|
tfree(pReducer->pFinalRes);
|
||||||
taosTFree(pReducer->prevRowOfInput);
|
tfree(pReducer->prevRowOfInput);
|
||||||
taosTFree(pReducer->pLoserTree);
|
tfree(pReducer->pLoserTree);
|
||||||
taosTFree(param);
|
tfree(param);
|
||||||
taosTFree(pReducer);
|
tfree(pReducer);
|
||||||
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -492,33 +495,33 @@ void tscDestroyLocalReducer(SSqlObj *pSql) {
|
||||||
SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[i];
|
SQLFunctionCtx *pCtx = &pLocalReducer->pCtx[i];
|
||||||
|
|
||||||
tVariantDestroy(&pCtx->tag);
|
tVariantDestroy(&pCtx->tag);
|
||||||
taosTFree(pCtx->resultInfo);
|
tfree(pCtx->resultInfo);
|
||||||
|
|
||||||
if (pCtx->tagInfo.pTagCtxList != NULL) {
|
if (pCtx->tagInfo.pTagCtxList != NULL) {
|
||||||
taosTFree(pCtx->tagInfo.pTagCtxList);
|
tfree(pCtx->tagInfo.pTagCtxList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pLocalReducer->pCtx);
|
tfree(pLocalReducer->pCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pLocalReducer->prevRowOfInput);
|
tfree(pLocalReducer->prevRowOfInput);
|
||||||
|
|
||||||
taosTFree(pLocalReducer->pTempBuffer);
|
tfree(pLocalReducer->pTempBuffer);
|
||||||
taosTFree(pLocalReducer->pResultBuf);
|
tfree(pLocalReducer->pResultBuf);
|
||||||
|
|
||||||
if (pLocalReducer->pLoserTree) {
|
if (pLocalReducer->pLoserTree) {
|
||||||
taosTFree(pLocalReducer->pLoserTree->param);
|
tfree(pLocalReducer->pLoserTree->param);
|
||||||
taosTFree(pLocalReducer->pLoserTree);
|
tfree(pLocalReducer->pLoserTree);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pLocalReducer->pFinalRes);
|
tfree(pLocalReducer->pFinalRes);
|
||||||
taosTFree(pLocalReducer->discardData);
|
tfree(pLocalReducer->discardData);
|
||||||
|
|
||||||
tscLocalReducerEnvDestroy(pLocalReducer->pExtMemBuffer, pLocalReducer->pDesc, pLocalReducer->resColModel,
|
tscLocalReducerEnvDestroy(pLocalReducer->pExtMemBuffer, pLocalReducer->pDesc, pLocalReducer->resColModel,
|
||||||
pLocalReducer->numOfVnode);
|
pLocalReducer->numOfVnode);
|
||||||
for (int32_t i = 0; i < pLocalReducer->numOfBuffer; ++i) {
|
for (int32_t i = 0; i < pLocalReducer->numOfBuffer; ++i) {
|
||||||
taosTFree(pLocalReducer->pLocalDataSrc[i]);
|
tfree(pLocalReducer->pLocalDataSrc[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pLocalReducer->numOfBuffer = 0;
|
pLocalReducer->numOfBuffer = 0;
|
||||||
|
@ -585,7 +588,7 @@ static int32_t createOrderDescriptor(tOrderDescriptor **pOrderDesc, SSqlCmd *pCm
|
||||||
}
|
}
|
||||||
|
|
||||||
*pOrderDesc = tOrderDesCreate(orderColIndexList, numOfGroupByCols, pModel, pQueryInfo->order.order);
|
*pOrderDesc = tOrderDesCreate(orderColIndexList, numOfGroupByCols, pModel, pQueryInfo->order.order);
|
||||||
taosTFree(orderColIndexList);
|
tfree(orderColIndexList);
|
||||||
|
|
||||||
if (*pOrderDesc == NULL) {
|
if (*pOrderDesc == NULL) {
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
|
@ -696,7 +699,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
||||||
|
|
||||||
if (createOrderDescriptor(pOrderDesc, pCmd, pModel) != TSDB_CODE_SUCCESS) {
|
if (createOrderDescriptor(pOrderDesc, pCmd, pModel) != TSDB_CODE_SUCCESS) {
|
||||||
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
taosTFree(pSchema);
|
tfree(pSchema);
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,7 +736,7 @@ int32_t tscLocalReducerEnvCreate(SSqlObj *pSql, tExtMemBuffer ***pMemBuffer, tOr
|
||||||
}
|
}
|
||||||
|
|
||||||
*pFinalModel = createColumnModel(pSchema, (int32_t)size, capacity);
|
*pFinalModel = createColumnModel(pSchema, (int32_t)size, capacity);
|
||||||
taosTFree(pSchema);
|
tfree(pSchema);
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -753,7 +756,7 @@ void tscLocalReducerEnvDestroy(tExtMemBuffer **pMemBuffer, tOrderDescriptor *pDe
|
||||||
pMemBuffer[i] = destoryExtMemBuffer(pMemBuffer[i]);
|
pMemBuffer[i] = destoryExtMemBuffer(pMemBuffer[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pMemBuffer);
|
tfree(pMemBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -975,10 +978,10 @@ static void doFillResult(SSqlObj *pSql, SLocalReducer *pLocalReducer, bool doneO
|
||||||
|
|
||||||
pBeforeFillData->num = 0;
|
pBeforeFillData->num = 0;
|
||||||
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
for (int32_t i = 0; i < pQueryInfo->fieldsInfo.numOfOutput; ++i) {
|
||||||
taosTFree(pResPages[i]);
|
tfree(pResPages[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pResPages);
|
tfree(pResPages);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer) {
|
static void savePreviousRow(SLocalReducer *pLocalReducer, tFilePage *tmpBuffer) {
|
||||||
|
|
|
@ -1406,7 +1406,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
|
||||||
assert(taos_errno(pSql) == code);
|
assert(taos_errno(pSql) == code);
|
||||||
|
|
||||||
taos_free_result(pSql);
|
taos_free_result(pSql);
|
||||||
taosTFree(pSupporter);
|
tfree(pSupporter);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
pParentSql->res.code = code;
|
pParentSql->res.code = code;
|
||||||
|
@ -1445,7 +1445,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
|
||||||
|
|
||||||
char *tokenBuf = calloc(1, 4096);
|
char *tokenBuf = calloc(1, 4096);
|
||||||
|
|
||||||
while ((readLen = taosGetline(&line, &n, fp)) != -1) {
|
while ((readLen = tgetline(&line, &n, fp)) != -1) {
|
||||||
if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) {
|
if (('\r' == line[readLen - 1]) || ('\n' == line[readLen - 1])) {
|
||||||
line[--readLen] = 0;
|
line[--readLen] = 0;
|
||||||
}
|
}
|
||||||
|
@ -1470,7 +1470,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(tokenBuf);
|
tfree(tokenBuf);
|
||||||
free(line);
|
free(line);
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
|
@ -1483,7 +1483,7 @@ static void parseFileSendDataBlock(void *param, TAOS_RES *tres, int code) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
taos_free_result(pSql);
|
taos_free_result(pSql);
|
||||||
taosTFree(pSupporter);
|
tfree(pSupporter);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
pParentSql->fp = pParentSql->fetchFp;
|
pParentSql->fp = pParentSql->fetchFp;
|
||||||
|
@ -1513,7 +1513,7 @@ void tscProcessMultiVnodesImportFromFile(SSqlObj *pSql) {
|
||||||
pSql->res.code = TAOS_SYSTEM_ERROR(errno);
|
pSql->res.code = TAOS_SYSTEM_ERROR(errno);
|
||||||
tscError("%p failed to open file %s to load data from file, code:%s", pSql, pCmd->payload, tstrerror(pSql->res.code));
|
tscError("%p failed to open file %s to load data from file, code:%s", pSql, pCmd->payload, tstrerror(pSql->res.code));
|
||||||
|
|
||||||
taosTFree(pSupporter)
|
tfree(pSupporter)
|
||||||
tscQueueAsyncRes(pSql);
|
tscQueueAsyncRes(pSql);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#define _BSD_SOURCE
|
#define _BSD_SOURCE
|
||||||
#define _XOPEN_SOURCE 500
|
#define _XOPEN_SOURCE 500
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "qAst.h"
|
#include "qAst.h"
|
||||||
|
@ -2089,7 +2090,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col
|
||||||
SColumnIndex index = {.tableIndex = j, .columnIndex = i};
|
SColumnIndex index = {.tableIndex = j, .columnIndex = i};
|
||||||
|
|
||||||
char name[TSDB_COL_NAME_LEN] = {0};
|
char name[TSDB_COL_NAME_LEN] = {0};
|
||||||
SStrToken t = {.z = pSchema->name, .n = (uint32_t)strnlen(pSchema->name, TSDB_COL_NAME_LEN)};
|
SStrToken t = {.z = pSchema[i].name, .n = (uint32_t)strnlen(pSchema[i].name, TSDB_COL_NAME_LEN)};
|
||||||
setResultColName(name, pItem, cvtFunc.originFuncId, &t);
|
setResultColName(name, pItem, cvtFunc.originFuncId, &t);
|
||||||
|
|
||||||
if (setExprInfoForFunctions(pCmd, pQueryInfo, &pSchema[index.columnIndex], cvtFunc, name, colIndex, &index, finalResult) != 0) {
|
if (setExprInfoForFunctions(pCmd, pQueryInfo, &pSchema[index.columnIndex], cvtFunc, name, colIndex, &index, finalResult) != 0) {
|
||||||
|
@ -4014,7 +4015,7 @@ static int32_t setTableCondForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
|
||||||
int32_t ret = setObjFullName(idBuf, account, &dbToken, &t, &xlen);
|
int32_t ret = setObjFullName(idBuf, account, &dbToken, &t, &xlen);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
if (ret != TSDB_CODE_SUCCESS) {
|
||||||
taosStringBuilderDestroy(&sb1);
|
taosStringBuilderDestroy(&sb1);
|
||||||
taosTFree(segments);
|
tfree(segments);
|
||||||
|
|
||||||
invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
|
invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -4027,7 +4028,7 @@ static int32_t setTableCondForSTableQuery(SSqlCmd* pCmd, SQueryInfo* pQueryInfo,
|
||||||
pQueryInfo->tagCond.tbnameCond.cond = strdup(str);
|
pQueryInfo->tagCond.tbnameCond.cond = strdup(str);
|
||||||
|
|
||||||
taosStringBuilderDestroy(&sb1);
|
taosStringBuilderDestroy(&sb1);
|
||||||
taosTFree(segments);
|
tfree(segments);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5399,6 +5400,7 @@ static void setCreateDBOption(SCreateDbMsg* pMsg, SCreateDBInfo* pCreateDb) {
|
||||||
pMsg->replications = pCreateDb->replica;
|
pMsg->replications = pCreateDb->replica;
|
||||||
pMsg->quorum = pCreateDb->quorum;
|
pMsg->quorum = pCreateDb->quorum;
|
||||||
pMsg->ignoreExist = pCreateDb->ignoreExists;
|
pMsg->ignoreExist = pCreateDb->ignoreExists;
|
||||||
|
pMsg->update = pCreateDb->update;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDBInfo* pCreateDbSql) {
|
int32_t parseCreateDBOptions(SSqlCmd* pCmd, SCreateDBInfo* pCreateDbSql) {
|
||||||
|
|
|
@ -124,7 +124,7 @@ static void tscUpdateVgroupInfo(SSqlObj *pObj, SRpcEpSet *pEpSet) {
|
||||||
pVgroupInfo->inUse = pEpSet->inUse;
|
pVgroupInfo->inUse = pEpSet->inUse;
|
||||||
pVgroupInfo->numOfEps = pEpSet->numOfEps;
|
pVgroupInfo->numOfEps = pEpSet->numOfEps;
|
||||||
for (int32_t i = 0; i < pVgroupInfo->numOfEps; i++) {
|
for (int32_t i = 0; i < pVgroupInfo->numOfEps; i++) {
|
||||||
taosTFree(pVgroupInfo->epAddr[i].fqdn);
|
tfree(pVgroupInfo->epAddr[i].fqdn);
|
||||||
pVgroupInfo->epAddr[i].fqdn = strndup(pEpSet->fqdn[i], tListLen(pEpSet->fqdn[i]));
|
pVgroupInfo->epAddr[i].fqdn = strndup(pEpSet->fqdn[i], tListLen(pEpSet->fqdn[i]));
|
||||||
pVgroupInfo->epAddr[i].port = pEpSet->port[i];
|
pVgroupInfo->epAddr[i].port = pEpSet->port[i];
|
||||||
}
|
}
|
||||||
|
@ -182,27 +182,23 @@ void tscProcessHeartBeatRsp(void *param, TAOS_RES *tres, int code) {
|
||||||
int32_t waitingDuring = tsShellActivityTimer * 500;
|
int32_t waitingDuring = tsShellActivityTimer * 500;
|
||||||
tscDebug("%p send heartbeat in %dms", pSql, waitingDuring);
|
tscDebug("%p send heartbeat in %dms", pSql, waitingDuring);
|
||||||
|
|
||||||
taosTmrReset(tscProcessActivityTimer, waitingDuring, pObj, tscTmr, &pObj->pTimer);
|
taosTmrReset(tscProcessActivityTimer, waitingDuring, (void *)pObj->rid, tscTmr, &pObj->pTimer);
|
||||||
} else {
|
} else {
|
||||||
tscDebug("%p start to close tscObj:%p, not send heartbeat again", pSql, pObj);
|
tscDebug("%p start to close tscObj:%p, not send heartbeat again", pSql, pObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscProcessActivityTimer(void *handle, void *tmrId) {
|
void tscProcessActivityTimer(void *handle, void *tmrId) {
|
||||||
STscObj *pObj = (STscObj *)handle;
|
int64_t rid = (int64_t) handle;
|
||||||
|
STscObj *pObj = taosAcquireRef(tscRefId, rid);
|
||||||
int ret = taosAcquireRef(tscRefId, pObj);
|
if (pObj == NULL) return;
|
||||||
if (ret < 0) {
|
|
||||||
tscTrace("%p failed to acquire TSC obj, reason:%s", pObj, tstrerror(ret));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSqlObj* pHB = pObj->pHb;
|
SSqlObj* pHB = pObj->pHb;
|
||||||
|
|
||||||
void** p = taosCacheAcquireByKey(tscObjCache, &pHB, sizeof(TSDB_CACHE_PTR_TYPE));
|
void** p = taosCacheAcquireByKey(tscObjCache, &pHB, sizeof(TSDB_CACHE_PTR_TYPE));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
tscWarn("%p HB object has been released already", pHB);
|
tscWarn("%p HB object has been released already", pHB);
|
||||||
taosReleaseRef(tscRefId, pObj);
|
taosReleaseRef(tscRefId, pObj->rid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +212,7 @@ void tscProcessActivityTimer(void *handle, void *tmrId) {
|
||||||
tscError("%p failed to sent HB to server, reason:%s", pHB, tstrerror(code));
|
tscError("%p failed to sent HB to server, reason:%s", pHB, tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
taosReleaseRef(tscRefId, pObj);
|
taosReleaseRef(tscRefId, rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tscSendMsgToServer(SSqlObj *pSql) {
|
int tscSendMsgToServer(SSqlObj *pSql) {
|
||||||
|
@ -241,7 +237,7 @@ int tscSendMsgToServer(SSqlObj *pSql) {
|
||||||
.pCont = pMsg,
|
.pCont = pMsg,
|
||||||
.contLen = pSql->cmd.payloadLen,
|
.contLen = pSql->cmd.payloadLen,
|
||||||
.ahandle = pSql,
|
.ahandle = pSql,
|
||||||
.handle = &pSql->pRpcCtx,
|
.handle = NULL,
|
||||||
.code = 0
|
.code = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -249,7 +245,7 @@ int tscSendMsgToServer(SSqlObj *pSql) {
|
||||||
// Otherwise, the pSql object may have been released already during the response function, which is
|
// Otherwise, the pSql object may have been released already during the response function, which is
|
||||||
// processMsgFromServer function. In the meanwhile, the assignment of the rpc context to sql object will absolutely
|
// processMsgFromServer function. In the meanwhile, the assignment of the rpc context to sql object will absolutely
|
||||||
// cause crash.
|
// cause crash.
|
||||||
rpcSendRequest(pObj->pDnodeConn, &pSql->epSet, &rpcMsg);
|
pSql->rpcRid = rpcSendRequest(pObj->pDnodeConn, &pSql->epSet, &rpcMsg);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +265,7 @@ void tscProcessMsgFromServer(SRpcMsg *rpcMsg, SRpcEpSet *pEpSet) {
|
||||||
SSqlCmd *pCmd = &pSql->cmd;
|
SSqlCmd *pCmd = &pSql->cmd;
|
||||||
|
|
||||||
assert(*pSql->self == pSql);
|
assert(*pSql->self == pSql);
|
||||||
pSql->pRpcCtx = NULL;
|
pSql->rpcRid = -1;
|
||||||
|
|
||||||
if (pObj->signature != pObj) {
|
if (pObj->signature != pObj) {
|
||||||
tscDebug("%p DB connection is closed, cmd:%d pObj:%p signature:%p", pSql, pCmd->command, pObj, pObj->signature);
|
tscDebug("%p DB connection is closed, cmd:%d pObj:%p signature:%p", pSql, pCmd->command, pObj, pObj->signature);
|
||||||
|
@ -1553,7 +1549,7 @@ int tscBuildMultiMeterMetaMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
memcpy(pInfoMsg->tableIds, tmpData, pCmd->payloadLen);
|
memcpy(pInfoMsg->tableIds, tmpData, pCmd->payloadLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(tmpData);
|
tfree(tmpData);
|
||||||
|
|
||||||
pCmd->payloadLen += sizeof(SMgmtHead) + sizeof(SMultiTableInfoMsg);
|
pCmd->payloadLen += sizeof(SMgmtHead) + sizeof(SMultiTableInfoMsg);
|
||||||
pCmd->msgType = TSDB_MSG_TYPE_CM_TABLES_META;
|
pCmd->msgType = TSDB_MSG_TYPE_CM_TABLES_META;
|
||||||
|
@ -1960,7 +1956,7 @@ int tscProcessShowRsp(SSqlObj *pSql) {
|
||||||
pCmd->numOfCols = pQueryInfo->fieldsInfo.numOfOutput;
|
pCmd->numOfCols = pQueryInfo->fieldsInfo.numOfOutput;
|
||||||
tscFieldInfoUpdateOffset(pQueryInfo);
|
tscFieldInfoUpdateOffset(pQueryInfo);
|
||||||
|
|
||||||
taosTFree(pTableMeta);
|
tfree(pTableMeta);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1985,7 +1981,7 @@ static void createHBObj(STscObj* pObj) {
|
||||||
|
|
||||||
pSql->cmd.command = pQueryInfo->command;
|
pSql->cmd.command = pQueryInfo->command;
|
||||||
if (TSDB_CODE_SUCCESS != tscAllocPayload(&(pSql->cmd), TSDB_DEFAULT_PAYLOAD_SIZE)) {
|
if (TSDB_CODE_SUCCESS != tscAllocPayload(&(pSql->cmd), TSDB_DEFAULT_PAYLOAD_SIZE)) {
|
||||||
taosTFree(pSql);
|
tfree(pSql);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2025,7 +2021,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) {
|
||||||
createHBObj(pObj);
|
createHBObj(pObj);
|
||||||
|
|
||||||
//launch a timer to send heartbeat to maintain the connection and send status to mnode
|
//launch a timer to send heartbeat to maintain the connection and send status to mnode
|
||||||
taosTmrReset(tscProcessActivityTimer, tsShellActivityTimer * 500, pObj, tscTmr, &pObj->pTimer);
|
taosTmrReset(tscProcessActivityTimer, tsShellActivityTimer * 500, (void *)pObj->rid, tscTmr, &pObj->pTimer);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pa
|
||||||
registerSqlObj(pSql);
|
registerSqlObj(pSql);
|
||||||
tsInsertHeadSize = sizeof(SMsgDesc) + sizeof(SSubmitMsg);
|
tsInsertHeadSize = sizeof(SMsgDesc) + sizeof(SSubmitMsg);
|
||||||
|
|
||||||
taosAddRef(tscRefId, pObj);
|
pObj->rid = taosAddRef(tscRefId, pObj);
|
||||||
return pSql;
|
return pSql;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,9 +279,9 @@ void taos_close(TAOS *taos) {
|
||||||
|
|
||||||
SSqlObj* pHb = pObj->pHb;
|
SSqlObj* pHb = pObj->pHb;
|
||||||
if (pHb != NULL && atomic_val_compare_exchange_ptr(&pObj->pHb, pHb, 0) == pHb) {
|
if (pHb != NULL && atomic_val_compare_exchange_ptr(&pObj->pHb, pHb, 0) == pHb) {
|
||||||
if (pHb->pRpcCtx != NULL) { // wait for rsp from dnode
|
if (pHb->rpcRid > 0) { // wait for rsp from dnode
|
||||||
rpcCancelRequest(pHb->pRpcCtx);
|
rpcCancelRequest(pHb->rpcRid);
|
||||||
pHb->pRpcCtx = NULL;
|
pHb->rpcRid = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscDebug("%p HB is freed", pHb);
|
tscDebug("%p HB is freed", pHb);
|
||||||
|
@ -298,7 +298,7 @@ void taos_close(TAOS *taos) {
|
||||||
|
|
||||||
tscDebug("%p all sqlObj are freed, free tscObj and close dnodeConn:%p", pObj, pObj->pDnodeConn);
|
tscDebug("%p all sqlObj are freed, free tscObj and close dnodeConn:%p", pObj, pObj->pDnodeConn);
|
||||||
|
|
||||||
taosRemoveRef(tscRefId, pObj);
|
taosRemoveRef(tscRefId, pObj->rid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void waitForQueryRsp(void *param, TAOS_RES *tres, int code) {
|
void waitForQueryRsp(void *param, TAOS_RES *tres, int code) {
|
||||||
|
@ -566,7 +566,7 @@ int taos_fetch_block(TAOS_RES *res, TAOS_ROW *rows) {
|
||||||
pRes->rspType = 0;
|
pRes->rspType = 0;
|
||||||
|
|
||||||
pSql->subState.numOfSub = 0;
|
pSql->subState.numOfSub = 0;
|
||||||
taosTFree(pSql->pSubs);
|
tfree(pSql->pSubs);
|
||||||
|
|
||||||
assert(pSql->fp == NULL);
|
assert(pSql->fp == NULL);
|
||||||
|
|
||||||
|
@ -748,9 +748,9 @@ static void tscKillSTableQuery(SSqlObj *pSql) {
|
||||||
assert(pSubObj->self == (SSqlObj**) p);
|
assert(pSubObj->self == (SSqlObj**) p);
|
||||||
|
|
||||||
pSubObj->res.code = TSDB_CODE_TSC_QUERY_CANCELLED;
|
pSubObj->res.code = TSDB_CODE_TSC_QUERY_CANCELLED;
|
||||||
if (pSubObj->pRpcCtx != NULL) {
|
if (pSubObj->rpcRid > 0) {
|
||||||
rpcCancelRequest(pSubObj->pRpcCtx);
|
rpcCancelRequest(pSubObj->rpcRid);
|
||||||
pSubObj->pRpcCtx = NULL;
|
pSubObj->rpcRid = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscQueueAsyncRes(pSubObj);
|
tscQueueAsyncRes(pSubObj);
|
||||||
|
@ -775,7 +775,7 @@ void taos_stop_query(TAOS_RES *res) {
|
||||||
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
SQueryInfo *pQueryInfo = tscGetQueryInfoDetail(pCmd, pCmd->clauseIndex);
|
||||||
|
|
||||||
if (tscIsTwoStageSTableQuery(pQueryInfo, 0)) {
|
if (tscIsTwoStageSTableQuery(pQueryInfo, 0)) {
|
||||||
assert(pSql->pRpcCtx == NULL);
|
assert(pSql->rpcRid <= 0);
|
||||||
tscKillSTableQuery(pSql);
|
tscKillSTableQuery(pSql);
|
||||||
} else {
|
} else {
|
||||||
if (pSql->cmd.command < TSDB_SQL_LOCAL) {
|
if (pSql->cmd.command < TSDB_SQL_LOCAL) {
|
||||||
|
@ -784,9 +784,9 @@ void taos_stop_query(TAOS_RES *res) {
|
||||||
* reset and freed in the processMsgFromServer function, and causes the invalid
|
* reset and freed in the processMsgFromServer function, and causes the invalid
|
||||||
* write problem for rpcCancelRequest.
|
* write problem for rpcCancelRequest.
|
||||||
*/
|
*/
|
||||||
if (pSql->pRpcCtx != NULL) {
|
if (pSql->rpcRid > 0) {
|
||||||
rpcCancelRequest(pSql->pRpcCtx);
|
rpcCancelRequest(pSql->rpcRid);
|
||||||
pSql->pRpcCtx = NULL;
|
pSql->rpcRid = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tscQueueAsyncRes(pSql);
|
tscQueueAsyncRes(pSql);
|
||||||
|
@ -894,7 +894,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
|
||||||
if (sqlLen > tsMaxSQLStringLen) {
|
if (sqlLen > tsMaxSQLStringLen) {
|
||||||
tscError("%p sql too long", pSql);
|
tscError("%p sql too long", pSql);
|
||||||
pRes->code = TSDB_CODE_TSC_INVALID_SQL;
|
pRes->code = TSDB_CODE_TSC_INVALID_SQL;
|
||||||
taosTFree(pSql);
|
tfree(pSql);
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -903,7 +903,7 @@ int taos_validate_sql(TAOS *taos, const char *sql) {
|
||||||
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
tscError("%p failed to malloc sql string buffer", pSql);
|
tscError("%p failed to malloc sql string buffer", pSql);
|
||||||
tscDebug("%p Valid SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(pSql), pObj);
|
tscDebug("%p Valid SQL result:%d, %s pObj:%p", pSql, pRes->code, taos_errstr(pSql), pObj);
|
||||||
taosTFree(pSql);
|
tfree(pSql);
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -273,7 +273,7 @@ static void tscProcessStreamRetrieveResult(void *param, TAOS_RES *res, int numOf
|
||||||
|
|
||||||
taosCacheRelease(tscMetaCache, (void**)&(pTableMetaInfo->pTableMeta), false);
|
taosCacheRelease(tscMetaCache, (void**)&(pTableMetaInfo->pTableMeta), false);
|
||||||
tscFreeSqlResult(pSql);
|
tscFreeSqlResult(pSql);
|
||||||
taosTFree(pSql->pSubs);
|
tfree(pSql->pSubs);
|
||||||
pSql->subState.numOfSub = 0;
|
pSql->subState.numOfSub = 0;
|
||||||
pTableMetaInfo->vgroupList = tscVgroupInfoClear(pTableMetaInfo->vgroupList);
|
pTableMetaInfo->vgroupList = tscVgroupInfoClear(pTableMetaInfo->vgroupList);
|
||||||
tscSetNextLaunchTimer(pStream, pSql);
|
tscSetNextLaunchTimer(pStream, pSql);
|
||||||
|
@ -617,6 +617,6 @@ void taos_close_stream(TAOS_STREAM *handle) {
|
||||||
pStream->pSql = NULL;
|
pStream->pSql = NULL;
|
||||||
|
|
||||||
taos_free_result(pSql);
|
taos_free_result(pSql);
|
||||||
taosTFree(pStream);
|
tfree(pStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,7 +255,7 @@ static void tscDestroyJoinSupporter(SJoinSupporter* pSupporter) {
|
||||||
pSupporter->pVgroupTables = NULL;
|
pSupporter->pVgroupTables = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pSupporter->pIdTagList);
|
tfree(pSupporter->pIdTagList);
|
||||||
tscTagCondRelease(&pSupporter->tagCond);
|
tscTagCondRelease(&pSupporter->tagCond);
|
||||||
free(pSupporter);
|
free(pSupporter);
|
||||||
}
|
}
|
||||||
|
@ -308,7 +308,7 @@ static void filterVgroupTables(SQueryInfo* pQueryInfo, SArray* pVgroupTables) {
|
||||||
assert(taosArrayGetSize(pVgroupTables) > 0);
|
assert(taosArrayGetSize(pVgroupTables) > 0);
|
||||||
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_MULTITABLE_QUERY);
|
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_MULTITABLE_QUERY);
|
||||||
|
|
||||||
taosTFree(list);
|
tfree(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SArray* buildVgroupTableByResult(SQueryInfo* pQueryInfo, SArray* pVgroupTables) {
|
static SArray* buildVgroupTableByResult(SQueryInfo* pQueryInfo, SArray* pVgroupTables) {
|
||||||
|
@ -335,7 +335,7 @@ static SArray* buildVgroupTableByResult(SQueryInfo* pQueryInfo, SArray* pVgroupT
|
||||||
taosArrayPush(pNew, &info);
|
taosArrayPush(pNew, &info);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(list);
|
tfree(list);
|
||||||
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_MULTITABLE_QUERY);
|
TSDB_QUERY_SET_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_MULTITABLE_QUERY);
|
||||||
|
|
||||||
return pNew;
|
return pNew;
|
||||||
|
@ -1624,8 +1624,8 @@ static void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs) {
|
||||||
|
|
||||||
SRetrieveSupport* pSupport = pSub->param;
|
SRetrieveSupport* pSupport = pSub->param;
|
||||||
|
|
||||||
taosTFree(pSupport->localBuffer);
|
tfree(pSupport->localBuffer);
|
||||||
taosTFree(pSupport);
|
tfree(pSupport);
|
||||||
|
|
||||||
taos_free_result(pSub);
|
taos_free_result(pSub);
|
||||||
}
|
}
|
||||||
|
@ -1666,7 +1666,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
tscQueueAsyncRes(pSql);
|
tscQueueAsyncRes(pSql);
|
||||||
taosTFree(pMemoryBuf);
|
tfree(pMemoryBuf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1675,7 +1675,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
||||||
tscDebug("%p retrieved query data from %d vnode(s)", pSql, pState->numOfSub);
|
tscDebug("%p retrieved query data from %d vnode(s)", pSql, pState->numOfSub);
|
||||||
|
|
||||||
if (pSql->pSubs == NULL) {
|
if (pSql->pSubs == NULL) {
|
||||||
taosTFree(pSql->pSubs);
|
tfree(pSql->pSubs);
|
||||||
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pModel, pState->numOfSub);
|
tscLocalReducerEnvDestroy(pMemoryBuf, pDesc, pModel, pState->numOfSub);
|
||||||
|
|
||||||
|
@ -1700,7 +1700,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
||||||
trs->localBuffer = (tFilePage *)calloc(1, nBufferSize + sizeof(tFilePage));
|
trs->localBuffer = (tFilePage *)calloc(1, nBufferSize + sizeof(tFilePage));
|
||||||
if (trs->localBuffer == NULL) {
|
if (trs->localBuffer == NULL) {
|
||||||
tscError("%p failed to malloc buffer for local buffer, orderOfSub:%d, reason:%s", pSql, i, strerror(errno));
|
tscError("%p failed to malloc buffer for local buffer, orderOfSub:%d, reason:%s", pSql, i, strerror(errno));
|
||||||
taosTFree(trs);
|
tfree(trs);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1711,8 +1711,8 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
|
||||||
SSqlObj *pNew = tscCreateSTableSubquery(pSql, trs, NULL);
|
SSqlObj *pNew = tscCreateSTableSubquery(pSql, trs, NULL);
|
||||||
if (pNew == NULL) {
|
if (pNew == NULL) {
|
||||||
tscError("%p failed to malloc buffer for subObj, orderOfSub:%d, reason:%s", pSql, i, strerror(errno));
|
tscError("%p failed to malloc buffer for subObj, orderOfSub:%d, reason:%s", pSql, i, strerror(errno));
|
||||||
taosTFree(trs->localBuffer);
|
tfree(trs->localBuffer);
|
||||||
taosTFree(trs);
|
tfree(trs);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1766,8 +1766,8 @@ static void tscFreeRetrieveSup(SSqlObj *pSql) {
|
||||||
// SSqlObj *pParentSql = trsupport->pParentSql;
|
// SSqlObj *pParentSql = trsupport->pParentSql;
|
||||||
|
|
||||||
// assert(pSql == pParentSql->pSubs[index]);
|
// assert(pSql == pParentSql->pSubs[index]);
|
||||||
taosTFree(trsupport->localBuffer);
|
tfree(trsupport->localBuffer);
|
||||||
taosTFree(trsupport);
|
tfree(trsupport);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfRows);
|
static void tscRetrieveFromDnodeCallBack(void *param, TAOS_RES *tres, int numOfRows);
|
||||||
|
@ -2167,7 +2167,7 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
|
||||||
pParentObj->res.code = pSql->res.code;
|
pParentObj->res.code = pSql->res.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pSupporter);
|
tfree(pSupporter);
|
||||||
|
|
||||||
if (atomic_sub_fetch_32(&pParentObj->subState.numOfRemain, 1) > 0) {
|
if (atomic_sub_fetch_32(&pParentObj->subState.numOfRemain, 1) > 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -2442,7 +2442,7 @@ TAOS_ROW doSetResultRowData(SSqlObj *pSql, bool finalResult) {
|
||||||
|
|
||||||
assert(pRes->row >= 0 && pRes->row <= pRes->numOfRows);
|
assert(pRes->row >= 0 && pRes->row <= pRes->numOfRows);
|
||||||
if (pRes->row >= pRes->numOfRows) { // all the results has returned to invoker
|
if (pRes->row >= pRes->numOfRows) { // all the results has returned to invoker
|
||||||
taosTFree(pRes->tsrow);
|
tfree(pRes->tsrow);
|
||||||
return pRes->tsrow;
|
return pRes->tsrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ void * tscTmr;
|
||||||
void * tscQhandle;
|
void * tscQhandle;
|
||||||
void * tscCheckDiskUsageTmr;
|
void * tscCheckDiskUsageTmr;
|
||||||
int tsInsertHeadSize;
|
int tsInsertHeadSize;
|
||||||
int tscRefId;
|
int tscRefId = -1;
|
||||||
|
|
||||||
int tscNumOfThreads;
|
int tscNumOfThreads;
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ void tscClearInterpInfo(SQueryInfo* pQueryInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pQueryInfo->fillType = TSDB_FILL_NONE;
|
pQueryInfo->fillType = TSDB_FILL_NONE;
|
||||||
taosTFree(pQueryInfo->fillVal);
|
tfree(pQueryInfo->fillVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
|
int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
|
||||||
|
@ -256,7 +256,7 @@ int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
|
||||||
|
|
||||||
// not enough memory
|
// not enough memory
|
||||||
if (pRes->tsrow == NULL || (pRes->buffer == NULL && pRes->numOfCols > 0)) {
|
if (pRes->tsrow == NULL || (pRes->buffer == NULL && pRes->numOfCols > 0)) {
|
||||||
taosTFree(pRes->tsrow);
|
tfree(pRes->tsrow);
|
||||||
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
pRes->code = TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
return pRes->code;
|
return pRes->code;
|
||||||
}
|
}
|
||||||
|
@ -268,24 +268,24 @@ int32_t tscCreateResPointerInfo(SSqlRes* pRes, SQueryInfo* pQueryInfo) {
|
||||||
static void tscDestroyResPointerInfo(SSqlRes* pRes) {
|
static void tscDestroyResPointerInfo(SSqlRes* pRes) {
|
||||||
if (pRes->buffer != NULL) { // free all buffers containing the multibyte string
|
if (pRes->buffer != NULL) { // free all buffers containing the multibyte string
|
||||||
for (int i = 0; i < pRes->numOfCols; i++) {
|
for (int i = 0; i < pRes->numOfCols; i++) {
|
||||||
taosTFree(pRes->buffer[i]);
|
tfree(pRes->buffer[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
pRes->numOfCols = 0;
|
pRes->numOfCols = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pRes->pRsp);
|
tfree(pRes->pRsp);
|
||||||
|
|
||||||
taosTFree(pRes->tsrow);
|
tfree(pRes->tsrow);
|
||||||
taosTFree(pRes->length);
|
tfree(pRes->length);
|
||||||
taosTFree(pRes->buffer);
|
tfree(pRes->buffer);
|
||||||
|
|
||||||
taosTFree(pRes->pGroupRec);
|
tfree(pRes->pGroupRec);
|
||||||
taosTFree(pRes->pColumnIndex);
|
tfree(pRes->pColumnIndex);
|
||||||
|
|
||||||
if (pRes->pArithSup != NULL) {
|
if (pRes->pArithSup != NULL) {
|
||||||
taosTFree(pRes->pArithSup->data);
|
tfree(pRes->pArithSup->data);
|
||||||
taosTFree(pRes->pArithSup);
|
tfree(pRes->pArithSup);
|
||||||
}
|
}
|
||||||
|
|
||||||
pRes->data = NULL; // pRes->data points to the buffer of pRsp, no need to free
|
pRes->data = NULL; // pRes->data points to the buffer of pRsp, no need to free
|
||||||
|
@ -302,11 +302,11 @@ static void tscFreeQueryInfo(SSqlCmd* pCmd, bool removeFromCache) {
|
||||||
|
|
||||||
freeQueryInfoImpl(pQueryInfo);
|
freeQueryInfoImpl(pQueryInfo);
|
||||||
clearAllTableMetaInfo(pQueryInfo, (const char*)addr, removeFromCache);
|
clearAllTableMetaInfo(pQueryInfo, (const char*)addr, removeFromCache);
|
||||||
taosTFree(pQueryInfo);
|
tfree(pQueryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
pCmd->numOfClause = 0;
|
pCmd->numOfClause = 0;
|
||||||
taosTFree(pCmd->pQueryInfo);
|
tfree(pCmd->pQueryInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscResetSqlCmdObj(SSqlCmd* pCmd, bool removeFromCache) {
|
void tscResetSqlCmdObj(SSqlCmd* pCmd, bool removeFromCache) {
|
||||||
|
@ -373,7 +373,7 @@ void tscFreeRegisteredSqlObj(void *pSql) {
|
||||||
tscDebug("%p free sqlObj completed, tscObj:%p ref:%d", *p, pTscObj, ref);
|
tscDebug("%p free sqlObj completed, tscObj:%p ref:%d", *p, pTscObj, ref);
|
||||||
if (ref == 0) {
|
if (ref == 0) {
|
||||||
tscDebug("%p all sqlObj freed, free tscObj:%p", *p, pTscObj);
|
tscDebug("%p all sqlObj freed, free tscObj:%p", *p, pTscObj);
|
||||||
taosRemoveRef(tscRefId, pTscObj);
|
taosRemoveRef(tscRefId, pTscObj->rid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,14 +384,14 @@ void tscFreeTableMetaHelper(void *pTableMeta) {
|
||||||
assert(numOfEps >= 0 && numOfEps <= TSDB_MAX_REPLICA);
|
assert(numOfEps >= 0 && numOfEps <= TSDB_MAX_REPLICA);
|
||||||
|
|
||||||
for(int32_t i = 0; i < numOfEps; ++i) {
|
for(int32_t i = 0; i < numOfEps; ++i) {
|
||||||
taosTFree(p->vgroupInfo.epAddr[i].fqdn);
|
tfree(p->vgroupInfo.epAddr[i].fqdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfEps1 = p->corVgroupInfo.numOfEps;
|
int32_t numOfEps1 = p->corVgroupInfo.numOfEps;
|
||||||
assert(numOfEps1 >= 0 && numOfEps1 <= TSDB_MAX_REPLICA);
|
assert(numOfEps1 >= 0 && numOfEps1 <= TSDB_MAX_REPLICA);
|
||||||
|
|
||||||
for(int32_t i = 0; i < numOfEps1; ++i) {
|
for(int32_t i = 0; i < numOfEps1; ++i) {
|
||||||
taosTFree(p->corVgroupInfo.epAddr[i].fqdn);
|
tfree(p->corVgroupInfo.epAddr[i].fqdn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,9 +415,9 @@ void tscFreeSqlObj(SSqlObj* pSql) {
|
||||||
|
|
||||||
pSql->signature = NULL;
|
pSql->signature = NULL;
|
||||||
pSql->fp = NULL;
|
pSql->fp = NULL;
|
||||||
taosTFree(pSql->sqlstr);
|
tfree(pSql->sqlstr);
|
||||||
|
|
||||||
taosTFree(pSql->pSubs);
|
tfree(pSql->pSubs);
|
||||||
pSql->subState.numOfSub = 0;
|
pSql->subState.numOfSub = 0;
|
||||||
pSql->self = 0;
|
pSql->self = 0;
|
||||||
|
|
||||||
|
@ -425,7 +425,7 @@ void tscFreeSqlObj(SSqlObj* pSql) {
|
||||||
tscResetSqlCmdObj(pCmd, false);
|
tscResetSqlCmdObj(pCmd, false);
|
||||||
|
|
||||||
memset(pCmd->payload, 0, (size_t)pCmd->allocSize);
|
memset(pCmd->payload, 0, (size_t)pCmd->allocSize);
|
||||||
taosTFree(pCmd->payload);
|
tfree(pCmd->payload);
|
||||||
pCmd->allocSize = 0;
|
pCmd->allocSize = 0;
|
||||||
|
|
||||||
tsem_destroy(&pSql->rspSem);
|
tsem_destroy(&pSql->rspSem);
|
||||||
|
@ -437,15 +437,15 @@ void tscDestroyDataBlock(STableDataBlocks* pDataBlock) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pDataBlock->pData);
|
tfree(pDataBlock->pData);
|
||||||
taosTFree(pDataBlock->params);
|
tfree(pDataBlock->params);
|
||||||
|
|
||||||
// free the refcount for metermeta
|
// free the refcount for metermeta
|
||||||
if (pDataBlock->pTableMeta != NULL) {
|
if (pDataBlock->pTableMeta != NULL) {
|
||||||
taosCacheRelease(tscMetaCache, (void**)&(pDataBlock->pTableMeta), false);
|
taosCacheRelease(tscMetaCache, (void**)&(pDataBlock->pTableMeta), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pDataBlock);
|
tfree(pDataBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, int16_t bytes,
|
SParamInfo* tscAddParamToDataBlock(STableDataBlocks* pDataBlock, char type, uint8_t timePrec, int16_t bytes,
|
||||||
|
@ -720,7 +720,7 @@ int32_t tscMergeTableDataBlocks(SSqlObj* pSql, SArray* pTableDataBlockList) {
|
||||||
|
|
||||||
taosHashCleanup(pVnodeDataBlockHashList);
|
taosHashCleanup(pVnodeDataBlockHashList);
|
||||||
tscDestroyBlockArrayList(pVnodeDataBlockList);
|
tscDestroyBlockArrayList(pVnodeDataBlockList);
|
||||||
taosTFree(dataBuf->pData);
|
tfree(dataBuf->pData);
|
||||||
|
|
||||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -780,7 +780,7 @@ void tscCloseTscObj(void *param) {
|
||||||
pthread_mutex_destroy(&pObj->mutex);
|
pthread_mutex_destroy(&pObj->mutex);
|
||||||
|
|
||||||
tscDebug("%p DB connection is closed, dnodeConn:%p", pObj, p);
|
tscDebug("%p DB connection is closed, dnodeConn:%p", pObj, p);
|
||||||
taosTFree(pObj);
|
tfree(pObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tscIsInsertData(char* sqlstr) {
|
bool tscIsInsertData(char* sqlstr) {
|
||||||
|
@ -944,12 +944,12 @@ void tscFieldInfoClear(SFieldInfo* pFieldInfo) {
|
||||||
|
|
||||||
if (pInfo->pArithExprInfo != NULL) {
|
if (pInfo->pArithExprInfo != NULL) {
|
||||||
tExprTreeDestroy(&pInfo->pArithExprInfo->pExpr, NULL);
|
tExprTreeDestroy(&pInfo->pArithExprInfo->pExpr, NULL);
|
||||||
taosTFree(pInfo->pArithExprInfo);
|
tfree(pInfo->pArithExprInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pFieldInfo->internalField);
|
taosArrayDestroy(pFieldInfo->internalField);
|
||||||
taosTFree(pFieldInfo->final);
|
tfree(pFieldInfo->final);
|
||||||
|
|
||||||
memset(pFieldInfo, 0, sizeof(SFieldInfo));
|
memset(pFieldInfo, 0, sizeof(SFieldInfo));
|
||||||
}
|
}
|
||||||
|
@ -1065,7 +1065,7 @@ void* sqlExprDestroy(SSqlExpr* pExpr) {
|
||||||
tVariantDestroy(&pExpr->param[i]);
|
tVariantDestroy(&pExpr->param[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pExpr);
|
tfree(pExpr);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1165,11 +1165,11 @@ SColumn* tscColumnListInsert(SArray* pColumnList, SColumnIndex* pColIndex) {
|
||||||
static void destroyFilterInfo(SColumnFilterInfo* pFilterInfo, int32_t numOfFilters) {
|
static void destroyFilterInfo(SColumnFilterInfo* pFilterInfo, int32_t numOfFilters) {
|
||||||
for(int32_t i = 0; i < numOfFilters; ++i) {
|
for(int32_t i = 0; i < numOfFilters; ++i) {
|
||||||
if (pFilterInfo[i].filterstr) {
|
if (pFilterInfo[i].filterstr) {
|
||||||
taosTFree(pFilterInfo[i].pz);
|
tfree(pFilterInfo[i].pz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pFilterInfo);
|
tfree(pFilterInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
SColumn* tscColumnClone(const SColumn* src) {
|
SColumn* tscColumnClone(const SColumn* src) {
|
||||||
|
@ -1457,7 +1457,7 @@ void tscTagCondRelease(STagCond* pTagCond) {
|
||||||
size_t s = taosArrayGetSize(pTagCond->pCond);
|
size_t s = taosArrayGetSize(pTagCond->pCond);
|
||||||
for (int32_t i = 0; i < s; ++i) {
|
for (int32_t i = 0; i < s; ++i) {
|
||||||
SCond* p = taosArrayGet(pTagCond->pCond, i);
|
SCond* p = taosArrayGet(pTagCond->pCond, i);
|
||||||
taosTFree(p->cond);
|
tfree(p->cond);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pTagCond->pCond);
|
taosArrayDestroy(pTagCond->pCond);
|
||||||
|
@ -1649,7 +1649,7 @@ static void freeQueryInfoImpl(SQueryInfo* pQueryInfo) {
|
||||||
|
|
||||||
pQueryInfo->tsBuf = tsBufDestroy(pQueryInfo->tsBuf);
|
pQueryInfo->tsBuf = tsBufDestroy(pQueryInfo->tsBuf);
|
||||||
|
|
||||||
taosTFree(pQueryInfo->fillVal);
|
tfree(pQueryInfo->fillVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tscClearSubqueryInfo(SSqlCmd* pCmd) {
|
void tscClearSubqueryInfo(SSqlCmd* pCmd) {
|
||||||
|
@ -1669,7 +1669,7 @@ void tscFreeVgroupTableInfo(SArray* pVgroupTables) {
|
||||||
SVgroupTableInfo* pInfo = taosArrayGet(pVgroupTables, i);
|
SVgroupTableInfo* pInfo = taosArrayGet(pVgroupTables, i);
|
||||||
|
|
||||||
for(int32_t j = 0; j < pInfo->vgInfo.numOfEps; ++j) {
|
for(int32_t j = 0; j < pInfo->vgInfo.numOfEps; ++j) {
|
||||||
taosTFree(pInfo->vgInfo.epAddr[j].fqdn);
|
tfree(pInfo->vgInfo.epAddr[j].fqdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pInfo->itemList);
|
taosArrayDestroy(pInfo->itemList);
|
||||||
|
@ -1686,7 +1686,7 @@ void tscRemoveVgroupTableGroup(SArray* pVgroupTable, int32_t index) {
|
||||||
|
|
||||||
SVgroupTableInfo* pInfo = taosArrayGet(pVgroupTable, index);
|
SVgroupTableInfo* pInfo = taosArrayGet(pVgroupTable, index);
|
||||||
for(int32_t j = 0; j < pInfo->vgInfo.numOfEps; ++j) {
|
for(int32_t j = 0; j < pInfo->vgInfo.numOfEps; ++j) {
|
||||||
taosTFree(pInfo->vgInfo.epAddr[j].fqdn);
|
tfree(pInfo->vgInfo.epAddr[j].fqdn);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pInfo->itemList);
|
taosArrayDestroy(pInfo->itemList);
|
||||||
|
@ -1734,7 +1734,7 @@ void clearAllTableMetaInfo(SQueryInfo* pQueryInfo, const char* address, bool rem
|
||||||
free(pTableMetaInfo);
|
free(pTableMetaInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pQueryInfo->pTableMetaInfo);
|
tfree(pQueryInfo->pTableMetaInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, STableMeta* pTableMeta,
|
STableMetaInfo* tscAddTableMetaInfo(SQueryInfo* pQueryInfo, const char* name, STableMeta* pTableMeta,
|
||||||
|
@ -2333,7 +2333,7 @@ void tscTryQueryNextClause(SSqlObj* pSql, __async_cb_func_t fp) {
|
||||||
|
|
||||||
pRes->numOfTotal = num;
|
pRes->numOfTotal = num;
|
||||||
|
|
||||||
taosTFree(pSql->pSubs);
|
tfree(pSql->pSubs);
|
||||||
pSql->subState.numOfSub = 0;
|
pSql->subState.numOfSub = 0;
|
||||||
pSql->fp = fp;
|
pSql->fp = fp;
|
||||||
|
|
||||||
|
@ -2458,11 +2458,11 @@ void* tscVgroupInfoClear(SVgroupsInfo *vgroupList) {
|
||||||
SVgroupInfo* pVgroupInfo = &vgroupList->vgroups[i];
|
SVgroupInfo* pVgroupInfo = &vgroupList->vgroups[i];
|
||||||
|
|
||||||
for(int32_t j = 0; j < pVgroupInfo->numOfEps; ++j) {
|
for(int32_t j = 0; j < pVgroupInfo->numOfEps; ++j) {
|
||||||
taosTFree(pVgroupInfo->epAddr[j].fqdn);
|
tfree(pVgroupInfo->epAddr[j].fqdn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(vgroupList);
|
tfree(vgroupList);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2470,7 +2470,7 @@ void tscSVgroupInfoCopy(SVgroupInfo* dst, const SVgroupInfo* src) {
|
||||||
dst->vgId = src->vgId;
|
dst->vgId = src->vgId;
|
||||||
dst->numOfEps = src->numOfEps;
|
dst->numOfEps = src->numOfEps;
|
||||||
for(int32_t i = 0; i < dst->numOfEps; ++i) {
|
for(int32_t i = 0; i < dst->numOfEps; ++i) {
|
||||||
taosTFree(dst->epAddr[i].fqdn);
|
tfree(dst->epAddr[i].fqdn);
|
||||||
dst->epAddr[i].port = src->epAddr[i].port;
|
dst->epAddr[i].port = src->epAddr[i].port;
|
||||||
dst->epAddr[i].fqdn = strdup(src->epAddr[i].fqdn);
|
dst->epAddr[i].fqdn = strdup(src->epAddr[i].fqdn);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ typedef struct {
|
||||||
#define schemaFLen(s) ((s)->flen)
|
#define schemaFLen(s) ((s)->flen)
|
||||||
#define schemaVLen(s) ((s)->vlen)
|
#define schemaVLen(s) ((s)->vlen)
|
||||||
#define schemaColAt(s, i) ((s)->columns + i)
|
#define schemaColAt(s, i) ((s)->columns + i)
|
||||||
#define tdFreeSchema(s) taosTFree((s))
|
#define tdFreeSchema(s) tfree((s))
|
||||||
|
|
||||||
STSchema *tdDupSchema(STSchema *pSchema);
|
STSchema *tdDupSchema(STSchema *pSchema);
|
||||||
int tdEncodeSchema(void **buf, STSchema *pSchema);
|
int tdEncodeSchema(void **buf, STSchema *pSchema);
|
||||||
|
@ -119,6 +119,33 @@ void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version);
|
||||||
int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int16_t colId, int16_t bytes);
|
int tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int16_t colId, int16_t bytes);
|
||||||
STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
|
STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
|
||||||
|
|
||||||
|
// ----------------- Semantic timestamp key definition
|
||||||
|
typedef uint64_t TKEY;
|
||||||
|
|
||||||
|
#define TKEY_INVALID UINT64_MAX
|
||||||
|
#define TKEY_NULL TKEY_INVALID
|
||||||
|
#define TKEY_NEGATIVE_FLAG (((TKEY)1) << 63)
|
||||||
|
#define TKEY_DELETE_FLAG (((TKEY)1) << 62)
|
||||||
|
#define TKEY_VALUE_FILTER (~(TKEY_NEGATIVE_FLAG | TKEY_DELETE_FLAG))
|
||||||
|
|
||||||
|
#define TKEY_IS_NEGATIVE(tkey) (((tkey)&TKEY_NEGATIVE_FLAG) != 0)
|
||||||
|
#define TKEY_IS_DELETED(tkey) (((tkey)&TKEY_DELETE_FLAG) != 0)
|
||||||
|
#define tdSetTKEYDeleted(tkey) ((tkey) | TKEY_DELETE_FLAG)
|
||||||
|
#define tdGetTKEY(key) (((TKEY)ABS(key)) | (TKEY_NEGATIVE_FLAG & (TKEY)(key)))
|
||||||
|
#define tdGetKey(tkey) (((TSKEY)((tkey)&TKEY_VALUE_FILTER)) * (TKEY_IS_NEGATIVE(tkey) ? -1 : 1))
|
||||||
|
|
||||||
|
static FORCE_INLINE int tkeyComparFn(const void *tkey1, const void *tkey2) {
|
||||||
|
TSKEY key1 = tdGetKey(*(TKEY *)tkey1);
|
||||||
|
TSKEY key2 = tdGetKey(*(TKEY *)tkey2);
|
||||||
|
|
||||||
|
if (key1 < key2) {
|
||||||
|
return -1;
|
||||||
|
} else if (key1 > key2) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
// ----------------- Data row structure
|
// ----------------- Data row structure
|
||||||
|
|
||||||
/* A data row, the format is like below:
|
/* A data row, the format is like below:
|
||||||
|
@ -129,6 +156,8 @@ STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
|
||||||
* +----------+----------+---------------------------------+---------------------------------+
|
* +----------+----------+---------------------------------+---------------------------------+
|
||||||
* | len | sversion | First part | Second part |
|
* | len | sversion | First part | Second part |
|
||||||
* +----------+----------+---------------------------------+---------------------------------+
|
* +----------+----------+---------------------------------+---------------------------------+
|
||||||
|
*
|
||||||
|
* NOTE: timestamp in this row structure is TKEY instead of TSKEY
|
||||||
*/
|
*/
|
||||||
typedef void *SDataRow;
|
typedef void *SDataRow;
|
||||||
|
|
||||||
|
@ -137,11 +166,13 @@ typedef void *SDataRow;
|
||||||
#define dataRowLen(r) (*(uint16_t *)(r))
|
#define dataRowLen(r) (*(uint16_t *)(r))
|
||||||
#define dataRowVersion(r) *(int16_t *)POINTER_SHIFT(r, sizeof(int16_t))
|
#define dataRowVersion(r) *(int16_t *)POINTER_SHIFT(r, sizeof(int16_t))
|
||||||
#define dataRowTuple(r) POINTER_SHIFT(r, TD_DATA_ROW_HEAD_SIZE)
|
#define dataRowTuple(r) POINTER_SHIFT(r, TD_DATA_ROW_HEAD_SIZE)
|
||||||
#define dataRowKey(r) (*(TSKEY *)(dataRowTuple(r)))
|
#define dataRowTKey(r) (*(TKEY *)(dataRowTuple(r)))
|
||||||
|
#define dataRowKey(r) tdGetKey(dataRowTKey(r))
|
||||||
#define dataRowSetLen(r, l) (dataRowLen(r) = (l))
|
#define dataRowSetLen(r, l) (dataRowLen(r) = (l))
|
||||||
#define dataRowSetVersion(r, v) (dataRowVersion(r) = (v))
|
#define dataRowSetVersion(r, v) (dataRowVersion(r) = (v))
|
||||||
#define dataRowCpy(dst, r) memcpy((dst), (r), dataRowLen(r))
|
#define dataRowCpy(dst, r) memcpy((dst), (r), dataRowLen(r))
|
||||||
#define dataRowMaxBytesFromSchema(s) (schemaTLen(s) + TD_DATA_ROW_HEAD_SIZE)
|
#define dataRowMaxBytesFromSchema(s) (schemaTLen(s) + TD_DATA_ROW_HEAD_SIZE)
|
||||||
|
#define dataRowDeleted(r) TKEY_IS_DELETED(dataRowTKey(r))
|
||||||
|
|
||||||
SDataRow tdNewDataRowFromSchema(STSchema *pSchema);
|
SDataRow tdNewDataRowFromSchema(STSchema *pSchema);
|
||||||
void tdFreeDataRow(SDataRow row);
|
void tdFreeDataRow(SDataRow row);
|
||||||
|
@ -154,16 +185,18 @@ static FORCE_INLINE int tdAppendColVal(SDataRow row, void *value, int8_t type, i
|
||||||
int32_t toffset = offset + TD_DATA_ROW_HEAD_SIZE;
|
int32_t toffset = offset + TD_DATA_ROW_HEAD_SIZE;
|
||||||
char * ptr = (char *)POINTER_SHIFT(row, dataRowLen(row));
|
char * ptr = (char *)POINTER_SHIFT(row, dataRowLen(row));
|
||||||
|
|
||||||
switch (type) {
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
|
||||||
*(VarDataOffsetT *)POINTER_SHIFT(row, toffset) = dataRowLen(row);
|
*(VarDataOffsetT *)POINTER_SHIFT(row, toffset) = dataRowLen(row);
|
||||||
memcpy(ptr, value, varDataTLen(value));
|
memcpy(ptr, value, varDataTLen(value));
|
||||||
dataRowLen(row) += varDataTLen(value);
|
dataRowLen(row) += varDataTLen(value);
|
||||||
break;
|
} else {
|
||||||
default:
|
if (offset == 0) {
|
||||||
|
ASSERT(type == TSDB_DATA_TYPE_TIMESTAMP);
|
||||||
|
TKEY tvalue = tdGetTKEY(*(TSKEY *)value);
|
||||||
|
memcpy(POINTER_SHIFT(row, toffset), (void *)(&tvalue), TYPE_BYTES[type]);
|
||||||
|
} else {
|
||||||
memcpy(POINTER_SHIFT(row, toffset), value, TYPE_BYTES[type]);
|
memcpy(POINTER_SHIFT(row, toffset), value, TYPE_BYTES[type]);
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -171,11 +204,9 @@ static FORCE_INLINE int tdAppendColVal(SDataRow row, void *value, int8_t type, i
|
||||||
|
|
||||||
// NOTE: offset here including the header size
|
// NOTE: offset here including the header size
|
||||||
static FORCE_INLINE void *tdGetRowDataOfCol(SDataRow row, int8_t type, int32_t offset) {
|
static FORCE_INLINE void *tdGetRowDataOfCol(SDataRow row, int8_t type, int32_t offset) {
|
||||||
switch (type) {
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
|
||||||
return POINTER_SHIFT(row, *(VarDataOffsetT *)POINTER_SHIFT(row, offset));
|
return POINTER_SHIFT(row, *(VarDataOffsetT *)POINTER_SHIFT(row, offset));
|
||||||
default:
|
} else {
|
||||||
return POINTER_SHIFT(row, offset);
|
return POINTER_SHIFT(row, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,7 +227,6 @@ static FORCE_INLINE void dataColReset(SDataCol *pDataCol) { pDataCol->len = 0; }
|
||||||
|
|
||||||
void dataColInit(SDataCol *pDataCol, STColumn *pCol, void **pBuf, int maxPoints);
|
void dataColInit(SDataCol *pDataCol, STColumn *pCol, void **pBuf, int maxPoints);
|
||||||
void dataColAppendVal(SDataCol *pCol, void *value, int numOfRows, int maxPoints);
|
void dataColAppendVal(SDataCol *pCol, void *value, int numOfRows, int maxPoints);
|
||||||
void dataColPopPoints(SDataCol *pCol, int pointsToPop, int numOfRows);
|
|
||||||
void dataColSetOffset(SDataCol *pCol, int nEle);
|
void dataColSetOffset(SDataCol *pCol, int nEle);
|
||||||
|
|
||||||
bool isNEleNull(SDataCol *pCol, int nEle);
|
bool isNEleNull(SDataCol *pCol, int nEle);
|
||||||
|
@ -204,27 +234,19 @@ void dataColSetNEleNull(SDataCol *pCol, int nEle, int maxPoints);
|
||||||
|
|
||||||
// Get the data pointer from a column-wised data
|
// Get the data pointer from a column-wised data
|
||||||
static FORCE_INLINE void *tdGetColDataOfRow(SDataCol *pCol, int row) {
|
static FORCE_INLINE void *tdGetColDataOfRow(SDataCol *pCol, int row) {
|
||||||
switch (pCol->type) {
|
if (IS_VAR_DATA_TYPE(pCol->type)) {
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
|
||||||
return POINTER_SHIFT(pCol->pData, pCol->dataOff[row]);
|
return POINTER_SHIFT(pCol->pData, pCol->dataOff[row]);
|
||||||
break;
|
} else {
|
||||||
|
|
||||||
default:
|
|
||||||
return POINTER_SHIFT(pCol->pData, TYPE_BYTES[pCol->type] * row);
|
return POINTER_SHIFT(pCol->pData, TYPE_BYTES[pCol->type] * row);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static FORCE_INLINE int32_t dataColGetNEleLen(SDataCol *pDataCol, int rows) {
|
static FORCE_INLINE int32_t dataColGetNEleLen(SDataCol *pDataCol, int rows) {
|
||||||
ASSERT(rows > 0);
|
ASSERT(rows > 0);
|
||||||
|
|
||||||
switch (pDataCol->type) {
|
if (IS_VAR_DATA_TYPE(pDataCol->type)) {
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
|
||||||
return pDataCol->dataOff[rows - 1] + varDataTLen(tdGetColDataOfRow(pDataCol, rows - 1));
|
return pDataCol->dataOff[rows - 1] + varDataTLen(tdGetColDataOfRow(pDataCol, rows - 1));
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
return TYPE_BYTES[pDataCol->type] * rows;
|
return TYPE_BYTES[pDataCol->type] * rows;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -243,9 +265,14 @@ typedef struct {
|
||||||
} SDataCols;
|
} SDataCols;
|
||||||
|
|
||||||
#define keyCol(pCols) (&((pCols)->cols[0])) // Key column
|
#define keyCol(pCols) (&((pCols)->cols[0])) // Key column
|
||||||
#define dataColsKeyAt(pCols, idx) ((TSKEY *)(keyCol(pCols)->pData))[(idx)]
|
#define dataColsTKeyAt(pCols, idx) ((TKEY *)(keyCol(pCols)->pData))[(idx)]
|
||||||
#define dataColsKeyFirst(pCols) dataColsKeyAt(pCols, 0)
|
#define dataColsKeyAt(pCols, idx) tdGetKey(dataColsTKeyAt(pCols, idx))
|
||||||
#define dataColsKeyLast(pCols) ((pCols->numOfRows == 0) ? 0 : dataColsKeyAt(pCols, (pCols)->numOfRows - 1))
|
#define dataColsTKeyFirst(pCols) (((pCols)->numOfRows == 0) ? TKEY_INVALID : dataColsTKeyAt(pCols, 0))
|
||||||
|
#define dataColsKeyFirst(pCols) (((pCols)->numOfRows == 0) ? TSDB_DATA_TIMESTAMP_NULL : dataColsKeyAt(pCols, 0))
|
||||||
|
#define dataColsTKeyLast(pCols) \
|
||||||
|
(((pCols)->numOfRows == 0) ? TKEY_INVALID : dataColsTKeyAt(pCols, (pCols)->numOfRows - 1))
|
||||||
|
#define dataColsKeyLast(pCols) \
|
||||||
|
(((pCols)->numOfRows == 0) ? TSDB_DATA_TIMESTAMP_NULL : dataColsKeyAt(pCols, (pCols)->numOfRows - 1))
|
||||||
|
|
||||||
SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows);
|
SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows);
|
||||||
void tdResetDataCols(SDataCols *pCols);
|
void tdResetDataCols(SDataCols *pCols);
|
||||||
|
@ -253,10 +280,7 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema);
|
||||||
SDataCols *tdDupDataCols(SDataCols *pCols, bool keepData);
|
SDataCols *tdDupDataCols(SDataCols *pCols, bool keepData);
|
||||||
void tdFreeDataCols(SDataCols *pCols);
|
void tdFreeDataCols(SDataCols *pCols);
|
||||||
void tdAppendDataRowToDataCol(SDataRow row, STSchema *pSchema, SDataCols *pCols);
|
void tdAppendDataRowToDataCol(SDataRow row, STSchema *pSchema, SDataCols *pCols);
|
||||||
void tdPopDataColsPoints(SDataCols *pCols, int pointsToPop); //!!!!
|
|
||||||
int tdMergeDataCols(SDataCols *target, SDataCols *src, int rowsToMerge);
|
int tdMergeDataCols(SDataCols *target, SDataCols *src, int rowsToMerge);
|
||||||
void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limit1, SDataCols *src2, int *iter2,
|
|
||||||
int limit2, int tRows);
|
|
||||||
|
|
||||||
// ----------------- K-V data row structure
|
// ----------------- K-V data row structure
|
||||||
/*
|
/*
|
||||||
|
@ -284,7 +308,7 @@ typedef struct {
|
||||||
#define kvRowCpy(dst, r) memcpy((dst), (r), kvRowLen(r))
|
#define kvRowCpy(dst, r) memcpy((dst), (r), kvRowLen(r))
|
||||||
#define kvRowColVal(r, colIdx) POINTER_SHIFT(kvRowValues(r), (colIdx)->offset)
|
#define kvRowColVal(r, colIdx) POINTER_SHIFT(kvRowValues(r), (colIdx)->offset)
|
||||||
#define kvRowColIdxAt(r, i) (kvRowColIdx(r) + (i))
|
#define kvRowColIdxAt(r, i) (kvRowColIdx(r) + (i))
|
||||||
#define kvRowFree(r) taosTFree(r)
|
#define kvRowFree(r) tfree(r)
|
||||||
#define kvRowEnd(r) POINTER_SHIFT(r, kvRowLen(r))
|
#define kvRowEnd(r) POINTER_SHIFT(r, kvRowLen(r))
|
||||||
|
|
||||||
SKVRow tdKVRowDup(SKVRow row);
|
SKVRow tdKVRowDup(SKVRow row);
|
||||||
|
|
|
@ -88,6 +88,7 @@ extern int16_t tsWAL;
|
||||||
extern int32_t tsFsyncPeriod;
|
extern int32_t tsFsyncPeriod;
|
||||||
extern int32_t tsReplications;
|
extern int32_t tsReplications;
|
||||||
extern int32_t tsQuorum;
|
extern int32_t tsQuorum;
|
||||||
|
extern int32_t tsUpdate;
|
||||||
|
|
||||||
// balance
|
// balance
|
||||||
extern int32_t tsEnableBalance;
|
extern int32_t tsEnableBalance;
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
#include "tcoding.h"
|
#include "tcoding.h"
|
||||||
#include "wchar.h"
|
#include "wchar.h"
|
||||||
|
|
||||||
|
static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limit1, SDataCols *src2, int *iter2,
|
||||||
|
int limit2, int tRows);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicate the schema and return a new object
|
* Duplicate the schema and return a new object
|
||||||
*/
|
*/
|
||||||
|
@ -94,7 +97,7 @@ int tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) {
|
||||||
|
|
||||||
void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder) {
|
void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder) {
|
||||||
if (pBuilder) {
|
if (pBuilder) {
|
||||||
taosTFree(pBuilder->columns);
|
tfree(pBuilder->columns);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +205,7 @@ void dataColInit(SDataCol *pDataCol, STColumn *pCol, void **pBuf, int maxPoints)
|
||||||
pDataCol->offset = colOffset(pCol) + TD_DATA_ROW_HEAD_SIZE;
|
pDataCol->offset = colOffset(pCol) + TD_DATA_ROW_HEAD_SIZE;
|
||||||
|
|
||||||
pDataCol->len = 0;
|
pDataCol->len = 0;
|
||||||
if (pDataCol->type == TSDB_DATA_TYPE_BINARY || pDataCol->type == TSDB_DATA_TYPE_NCHAR) {
|
if (IS_VAR_DATA_TYPE(pDataCol->type)) {
|
||||||
pDataCol->dataOff = (VarDataOffsetT *)(*pBuf);
|
pDataCol->dataOff = (VarDataOffsetT *)(*pBuf);
|
||||||
pDataCol->pData = POINTER_SHIFT(*pBuf, sizeof(VarDataOffsetT) * maxPoints);
|
pDataCol->pData = POINTER_SHIFT(*pBuf, sizeof(VarDataOffsetT) * maxPoints);
|
||||||
pDataCol->spaceSize = pDataCol->bytes * maxPoints;
|
pDataCol->spaceSize = pDataCol->bytes * maxPoints;
|
||||||
|
@ -215,60 +218,29 @@ void dataColInit(SDataCol *pDataCol, STColumn *pCol, void **pBuf, int maxPoints)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// value from timestamp should be TKEY here instead of TSKEY
|
||||||
void dataColAppendVal(SDataCol *pCol, void *value, int numOfRows, int maxPoints) {
|
void dataColAppendVal(SDataCol *pCol, void *value, int numOfRows, int maxPoints) {
|
||||||
ASSERT(pCol != NULL && value != NULL);
|
ASSERT(pCol != NULL && value != NULL);
|
||||||
|
|
||||||
switch (pCol->type) {
|
if (IS_VAR_DATA_TYPE(pCol->type)) {
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
|
||||||
// set offset
|
// set offset
|
||||||
pCol->dataOff[numOfRows] = pCol->len;
|
pCol->dataOff[numOfRows] = pCol->len;
|
||||||
// Copy data
|
// Copy data
|
||||||
memcpy(POINTER_SHIFT(pCol->pData, pCol->len), value, varDataTLen(value));
|
memcpy(POINTER_SHIFT(pCol->pData, pCol->len), value, varDataTLen(value));
|
||||||
// Update the length
|
// Update the length
|
||||||
pCol->len += varDataTLen(value);
|
pCol->len += varDataTLen(value);
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
ASSERT(pCol->len == TYPE_BYTES[pCol->type] * numOfRows);
|
ASSERT(pCol->len == TYPE_BYTES[pCol->type] * numOfRows);
|
||||||
memcpy(POINTER_SHIFT(pCol->pData, pCol->len), value, pCol->bytes);
|
memcpy(POINTER_SHIFT(pCol->pData, pCol->len), value, pCol->bytes);
|
||||||
pCol->len += pCol->bytes;
|
pCol->len += pCol->bytes;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void dataColPopPoints(SDataCol *pCol, int pointsToPop, int numOfRows) {
|
|
||||||
int pointsLeft = numOfRows - pointsToPop;
|
|
||||||
|
|
||||||
ASSERT(pointsLeft > 0);
|
|
||||||
|
|
||||||
if (pCol->type == TSDB_DATA_TYPE_BINARY || pCol->type == TSDB_DATA_TYPE_NCHAR) {
|
|
||||||
ASSERT(pCol->len > 0);
|
|
||||||
VarDataOffsetT toffset = pCol->dataOff[pointsToPop];
|
|
||||||
pCol->len = pCol->len - toffset;
|
|
||||||
ASSERT(pCol->len > 0);
|
|
||||||
memmove(pCol->pData, POINTER_SHIFT(pCol->pData, toffset), pCol->len);
|
|
||||||
dataColSetOffset(pCol, pointsLeft);
|
|
||||||
} else {
|
|
||||||
ASSERT(pCol->len == TYPE_BYTES[pCol->type] * numOfRows);
|
|
||||||
pCol->len = TYPE_BYTES[pCol->type] * pointsLeft;
|
|
||||||
memmove(pCol->pData, POINTER_SHIFT(pCol->pData, TYPE_BYTES[pCol->type] * pointsToPop), pCol->len);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNEleNull(SDataCol *pCol, int nEle) {
|
bool isNEleNull(SDataCol *pCol, int nEle) {
|
||||||
switch (pCol->type) {
|
|
||||||
case TSDB_DATA_TYPE_BINARY:
|
|
||||||
case TSDB_DATA_TYPE_NCHAR:
|
|
||||||
for (int i = 0; i < nEle; i++) {
|
for (int i = 0; i < nEle; i++) {
|
||||||
if (!isNull(tdGetColDataOfRow(pCol, i), pCol->type)) return false;
|
if (!isNull(tdGetColDataOfRow(pCol, i), pCol->type)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
|
||||||
for (int i = 0; i < nEle; i++) {
|
|
||||||
if (!isNull(tdGetColDataOfRow(pCol, i), pCol->type)) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dataColSetNullAt(SDataCol *pCol, int index) {
|
void dataColSetNullAt(SDataCol *pCol, int index) {
|
||||||
|
@ -367,8 +339,8 @@ int tdInitDataCols(SDataCols *pCols, STSchema *pSchema) {
|
||||||
|
|
||||||
void tdFreeDataCols(SDataCols *pCols) {
|
void tdFreeDataCols(SDataCols *pCols) {
|
||||||
if (pCols) {
|
if (pCols) {
|
||||||
taosTFree(pCols->buf);
|
tfree(pCols->buf);
|
||||||
taosTFree(pCols->cols);
|
tfree(pCols->cols);
|
||||||
free(pCols);
|
free(pCols);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -390,7 +362,7 @@ SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
|
||||||
pRet->cols[i].spaceSize = pDataCols->cols[i].spaceSize;
|
pRet->cols[i].spaceSize = pDataCols->cols[i].spaceSize;
|
||||||
pRet->cols[i].pData = (void *)((char *)pRet->buf + ((char *)(pDataCols->cols[i].pData) - (char *)(pDataCols->buf)));
|
pRet->cols[i].pData = (void *)((char *)pRet->buf + ((char *)(pDataCols->cols[i].pData) - (char *)(pDataCols->buf)));
|
||||||
|
|
||||||
if (pRet->cols[i].type == TSDB_DATA_TYPE_BINARY || pRet->cols[i].type == TSDB_DATA_TYPE_NCHAR) {
|
if (IS_VAR_DATA_TYPE(pRet->cols[i].type)) {
|
||||||
ASSERT(pDataCols->cols[i].dataOff != NULL);
|
ASSERT(pDataCols->cols[i].dataOff != NULL);
|
||||||
pRet->cols[i].dataOff =
|
pRet->cols[i].dataOff =
|
||||||
(int32_t *)((char *)pRet->buf + ((char *)(pDataCols->cols[i].dataOff) - (char *)(pDataCols->buf)));
|
(int32_t *)((char *)pRet->buf + ((char *)(pDataCols->cols[i].dataOff) - (char *)(pDataCols->buf)));
|
||||||
|
@ -400,7 +372,7 @@ SDataCols *tdDupDataCols(SDataCols *pDataCols, bool keepData) {
|
||||||
pRet->cols[i].len = pDataCols->cols[i].len;
|
pRet->cols[i].len = pDataCols->cols[i].len;
|
||||||
if (pDataCols->cols[i].len > 0) {
|
if (pDataCols->cols[i].len > 0) {
|
||||||
memcpy(pRet->cols[i].pData, pDataCols->cols[i].pData, pDataCols->cols[i].len);
|
memcpy(pRet->cols[i].pData, pDataCols->cols[i].pData, pDataCols->cols[i].len);
|
||||||
if (pRet->cols[i].type == TSDB_DATA_TYPE_BINARY || pRet->cols[i].type == TSDB_DATA_TYPE_NCHAR) {
|
if (IS_VAR_DATA_TYPE(pRet->cols[i].type)) {
|
||||||
memcpy(pRet->cols[i].dataOff, pDataCols->cols[i].dataOff, sizeof(VarDataOffsetT) * pDataCols->maxPoints);
|
memcpy(pRet->cols[i].dataOff, pDataCols->cols[i].dataOff, sizeof(VarDataOffsetT) * pDataCols->maxPoints);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -420,11 +392,21 @@ void tdResetDataCols(SDataCols *pCols) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdAppendDataRowToDataCol(SDataRow row, STSchema *pSchema, SDataCols *pCols) {
|
void tdAppendDataRowToDataCol(SDataRow row, STSchema *pSchema, SDataCols *pCols) {
|
||||||
ASSERT(dataColsKeyLast(pCols) < dataRowKey(row));
|
ASSERT(pCols->numOfRows == 0 || dataColsKeyLast(pCols) < dataRowKey(row));
|
||||||
|
|
||||||
int rcol = 0;
|
int rcol = 0;
|
||||||
int dcol = 0;
|
int dcol = 0;
|
||||||
|
|
||||||
|
if (dataRowDeleted(row)) {
|
||||||
|
for (; dcol < pCols->numOfCols; dcol++) {
|
||||||
|
SDataCol *pDataCol = &(pCols->cols[dcol]);
|
||||||
|
if (dcol == 0) {
|
||||||
|
dataColAppendVal(pDataCol, dataRowTuple(row), pCols->numOfRows, pCols->maxPoints);
|
||||||
|
} else {
|
||||||
|
dataColSetNullAt(pDataCol, pCols->numOfRows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
while (dcol < pCols->numOfCols) {
|
while (dcol < pCols->numOfCols) {
|
||||||
SDataCol *pDataCol = &(pCols->cols[dcol]);
|
SDataCol *pDataCol = &(pCols->cols[dcol]);
|
||||||
if (rcol >= schemaNCols(pSchema)) {
|
if (rcol >= schemaNCols(pSchema)) {
|
||||||
|
@ -435,7 +417,7 @@ void tdAppendDataRowToDataCol(SDataRow row, STSchema *pSchema, SDataCols *pCols)
|
||||||
|
|
||||||
STColumn *pRowCol = schemaColAt(pSchema, rcol);
|
STColumn *pRowCol = schemaColAt(pSchema, rcol);
|
||||||
if (pRowCol->colId == pDataCol->colId) {
|
if (pRowCol->colId == pDataCol->colId) {
|
||||||
void *value = tdGetRowDataOfCol(row, pRowCol->type, pRowCol->offset+TD_DATA_ROW_HEAD_SIZE);
|
void *value = tdGetRowDataOfCol(row, pRowCol->type, pRowCol->offset + TD_DATA_ROW_HEAD_SIZE);
|
||||||
dataColAppendVal(pDataCol, value, pCols->numOfRows, pCols->maxPoints);
|
dataColAppendVal(pDataCol, value, pCols->numOfRows, pCols->maxPoints);
|
||||||
dcol++;
|
dcol++;
|
||||||
rcol++;
|
rcol++;
|
||||||
|
@ -446,32 +428,18 @@ void tdAppendDataRowToDataCol(SDataRow row, STSchema *pSchema, SDataCols *pCols)
|
||||||
dcol++;
|
dcol++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
pCols->numOfRows++;
|
pCols->numOfRows++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pop pointsToPop points from the SDataCols
|
|
||||||
void tdPopDataColsPoints(SDataCols *pCols, int pointsToPop) {
|
|
||||||
int pointsLeft = pCols->numOfRows - pointsToPop;
|
|
||||||
if (pointsLeft <= 0) {
|
|
||||||
tdResetDataCols(pCols);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int iCol = 0; iCol < pCols->numOfCols; iCol++) {
|
|
||||||
SDataCol *pCol = pCols->cols + iCol;
|
|
||||||
dataColPopPoints(pCol, pointsToPop, pCols->numOfRows);
|
|
||||||
}
|
|
||||||
pCols->numOfRows = pointsLeft;
|
|
||||||
}
|
|
||||||
|
|
||||||
int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge) {
|
int tdMergeDataCols(SDataCols *target, SDataCols *source, int rowsToMerge) {
|
||||||
ASSERT(rowsToMerge > 0 && rowsToMerge <= source->numOfRows);
|
ASSERT(rowsToMerge > 0 && rowsToMerge <= source->numOfRows);
|
||||||
ASSERT(target->numOfRows + rowsToMerge <= target->maxPoints);
|
|
||||||
ASSERT(target->numOfCols == source->numOfCols);
|
ASSERT(target->numOfCols == source->numOfCols);
|
||||||
|
|
||||||
SDataCols *pTarget = NULL;
|
SDataCols *pTarget = NULL;
|
||||||
|
|
||||||
if (dataColsKeyLast(target) < dataColsKeyFirst(source)) { // No overlap
|
if (dataColsKeyLast(target) < dataColsKeyFirst(source)) { // No overlap
|
||||||
|
ASSERT(target->numOfRows + rowsToMerge <= target->maxPoints);
|
||||||
for (int i = 0; i < rowsToMerge; i++) {
|
for (int i = 0; i < rowsToMerge; i++) {
|
||||||
for (int j = 0; j < source->numOfCols; j++) {
|
for (int j = 0; j < source->numOfCols; j++) {
|
||||||
if (source->cols[j].len > 0) {
|
if (source->cols[j].len > 0) {
|
||||||
|
@ -499,17 +467,23 @@ _err:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limit1, SDataCols *src2, int *iter2, int limit2, int tRows) {
|
// src2 data has more priority than src1
|
||||||
|
static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limit1, SDataCols *src2, int *iter2,
|
||||||
|
int limit2, int tRows) {
|
||||||
tdResetDataCols(target);
|
tdResetDataCols(target);
|
||||||
ASSERT(limit1 <= src1->numOfRows && limit2 <= src2->numOfRows);
|
ASSERT(limit1 <= src1->numOfRows && limit2 <= src2->numOfRows);
|
||||||
|
|
||||||
while (target->numOfRows < tRows) {
|
while (target->numOfRows < tRows) {
|
||||||
if (*iter1 >= limit1 && *iter2 >= limit2) break;
|
if (*iter1 >= limit1 && *iter2 >= limit2) break;
|
||||||
|
|
||||||
TSKEY key1 = (*iter1 >= limit1) ? INT64_MAX : ((TSKEY *)(src1->cols[0].pData))[*iter1];
|
TSKEY key1 = (*iter1 >= limit1) ? INT64_MAX : dataColsKeyAt(src1, *iter1);
|
||||||
TSKEY key2 = (*iter2 >= limit2) ? INT64_MAX : ((TSKEY *)(src2->cols[0].pData))[*iter2];
|
TKEY tkey1 = (*iter1 >= limit1) ? TKEY_NULL : dataColsTKeyAt(src1, *iter1);
|
||||||
|
TSKEY key2 = (*iter2 >= limit2) ? INT64_MAX : dataColsKeyAt(src2, *iter2);
|
||||||
|
TKEY tkey2 = (*iter2 >= limit2) ? TKEY_NULL : dataColsTKeyAt(src2, *iter2);
|
||||||
|
|
||||||
if (key1 <= key2) {
|
ASSERT(tkey1 == TKEY_NULL || (!TKEY_IS_DELETED(tkey1)));
|
||||||
|
|
||||||
|
if (key1 < key2) {
|
||||||
for (int i = 0; i < src1->numOfCols; i++) {
|
for (int i = 0; i < src1->numOfCols; i++) {
|
||||||
ASSERT(target->cols[i].type == src1->cols[i].type);
|
ASSERT(target->cols[i].type == src1->cols[i].type);
|
||||||
if (src1->cols[i].len > 0) {
|
if (src1->cols[i].len > 0) {
|
||||||
|
@ -520,8 +494,8 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limi
|
||||||
|
|
||||||
target->numOfRows++;
|
target->numOfRows++;
|
||||||
(*iter1)++;
|
(*iter1)++;
|
||||||
if (key1 == key2) (*iter2)++;
|
} else if (key1 >= key2) {
|
||||||
} else {
|
if ((key1 > key2) || (key1 == key2 && !TKEY_IS_DELETED(tkey2))) {
|
||||||
for (int i = 0; i < src2->numOfCols; i++) {
|
for (int i = 0; i < src2->numOfCols; i++) {
|
||||||
ASSERT(target->cols[i].type == src2->cols[i].type);
|
ASSERT(target->cols[i].type == src2->cols[i].type);
|
||||||
if (src2->cols[i].len > 0) {
|
if (src2->cols[i].len > 0) {
|
||||||
|
@ -529,10 +503,14 @@ void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, int limi
|
||||||
target->maxPoints);
|
target->maxPoints);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
target->numOfRows++;
|
target->numOfRows++;
|
||||||
(*iter2)++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(*iter2)++;
|
||||||
|
if (key1 == key2) (*iter1)++;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(target->numOfRows <= target->maxPoints);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -691,8 +669,8 @@ int tdInitKVRowBuilder(SKVRowBuilder *pBuilder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdDestroyKVRowBuilder(SKVRowBuilder *pBuilder) {
|
void tdDestroyKVRowBuilder(SKVRowBuilder *pBuilder) {
|
||||||
taosTFree(pBuilder->pColIdx);
|
tfree(pBuilder->pColIdx);
|
||||||
taosTFree(pBuilder->buf);
|
tfree(pBuilder->buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdResetKVRowBuilder(SKVRowBuilder *pBuilder) {
|
void tdResetKVRowBuilder(SKVRowBuilder *pBuilder) {
|
||||||
|
|
|
@ -120,6 +120,7 @@ int16_t tsWAL = TSDB_DEFAULT_WAL_LEVEL;
|
||||||
int32_t tsFsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD;
|
int32_t tsFsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD;
|
||||||
int32_t tsReplications = TSDB_DEFAULT_DB_REPLICA_OPTION;
|
int32_t tsReplications = TSDB_DEFAULT_DB_REPLICA_OPTION;
|
||||||
int32_t tsQuorum = TSDB_DEFAULT_DB_QUORUM_OPTION;
|
int32_t tsQuorum = TSDB_DEFAULT_DB_QUORUM_OPTION;
|
||||||
|
int32_t tsUpdate = TSDB_DEFAULT_DB_UPDATE_OPTION;
|
||||||
int32_t tsMaxVgroupsPerDb = 0;
|
int32_t tsMaxVgroupsPerDb = 0;
|
||||||
int32_t tsMinTablePerVnode = TSDB_TABLES_STEP;
|
int32_t tsMinTablePerVnode = TSDB_TABLES_STEP;
|
||||||
int32_t tsMaxTablePerVnode = TSDB_DEFAULT_TABLES;
|
int32_t tsMaxTablePerVnode = TSDB_DEFAULT_TABLES;
|
||||||
|
@ -217,6 +218,8 @@ int32_t (*monitorStartSystemFp)() = NULL;
|
||||||
void (*monitorStopSystemFp)() = NULL;
|
void (*monitorStopSystemFp)() = NULL;
|
||||||
void (*monitorExecuteSQLFp)(char *sql) = NULL;
|
void (*monitorExecuteSQLFp)(char *sql) = NULL;
|
||||||
|
|
||||||
|
char *qtypeStr[] = {"rpc", "fwd", "wal", "cq", "query"};
|
||||||
|
|
||||||
static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT;
|
static pthread_once_t tsInitGlobalCfgOnce = PTHREAD_ONCE_INIT;
|
||||||
|
|
||||||
void taosSetAllDebugFlag() {
|
void taosSetAllDebugFlag() {
|
||||||
|
@ -786,6 +789,16 @@ static void doInitGlobalConfig(void) {
|
||||||
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||||
taosInitConfigOption(cfg);
|
taosInitConfigOption(cfg);
|
||||||
|
|
||||||
|
cfg.option = "update";
|
||||||
|
cfg.ptr = &tsUpdate;
|
||||||
|
cfg.valType = TAOS_CFG_VTYPE_INT32;
|
||||||
|
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW;
|
||||||
|
cfg.minValue = TSDB_MIN_DB_UPDATE;
|
||||||
|
cfg.maxValue = TSDB_MAX_DB_UPDATE;
|
||||||
|
cfg.ptrLength = 0;
|
||||||
|
cfg.unitType = TAOS_CFG_UTYPE_NONE;
|
||||||
|
taosInitConfigOption(cfg);
|
||||||
|
|
||||||
cfg.option = "mqttHostName";
|
cfg.option = "mqttHostName";
|
||||||
cfg.ptr = tsMqttHostName;
|
cfg.ptr = tsMqttHostName;
|
||||||
cfg.valType = TAOS_CFG_VTYPE_STRING;
|
cfg.valType = TAOS_CFG_VTYPE_STRING;
|
||||||
|
|
|
@ -125,7 +125,7 @@ void tVariantDestroy(tVariant *pVar) {
|
||||||
if (pVar == NULL) return;
|
if (pVar == NULL) return;
|
||||||
|
|
||||||
if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR) {
|
if (pVar->nType == TSDB_DATA_TYPE_BINARY || pVar->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||||
taosTFree(pVar->pz);
|
tfree(pVar->pz);
|
||||||
pVar->nLen = 0;
|
pVar->nLen = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,154 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace TDengineDriver
|
||||||
|
{
|
||||||
|
enum TDengineDataType {
|
||||||
|
TSDB_DATA_TYPE_NULL = 0, // 1 bytes
|
||||||
|
TSDB_DATA_TYPE_BOOL = 1, // 1 bytes
|
||||||
|
TSDB_DATA_TYPE_TINYINT = 2, // 1 bytes
|
||||||
|
TSDB_DATA_TYPE_SMALLINT = 3, // 2 bytes
|
||||||
|
TSDB_DATA_TYPE_INT = 4, // 4 bytes
|
||||||
|
TSDB_DATA_TYPE_BIGINT = 5, // 8 bytes
|
||||||
|
TSDB_DATA_TYPE_FLOAT = 6, // 4 bytes
|
||||||
|
TSDB_DATA_TYPE_DOUBLE = 7, // 8 bytes
|
||||||
|
TSDB_DATA_TYPE_BINARY = 8, // string
|
||||||
|
TSDB_DATA_TYPE_TIMESTAMP = 9,// 8 bytes
|
||||||
|
TSDB_DATA_TYPE_NCHAR = 10 // unicode string
|
||||||
|
}
|
||||||
|
|
||||||
|
enum TDengineInitOption
|
||||||
|
{
|
||||||
|
TSDB_OPTION_LOCALE = 0,
|
||||||
|
TSDB_OPTION_CHARSET = 1,
|
||||||
|
TSDB_OPTION_TIMEZONE = 2,
|
||||||
|
TDDB_OPTION_CONFIGDIR = 3,
|
||||||
|
TDDB_OPTION_SHELL_ACTIVITY_TIMER = 4
|
||||||
|
}
|
||||||
|
|
||||||
|
class TDengineMeta
|
||||||
|
{
|
||||||
|
public string name;
|
||||||
|
public short size;
|
||||||
|
public byte type;
|
||||||
|
public string TypeName()
|
||||||
|
{
|
||||||
|
switch ((TDengineDataType)type)
|
||||||
|
{
|
||||||
|
case TDengineDataType.TSDB_DATA_TYPE_BOOL:
|
||||||
|
return "BOOLEAN";
|
||||||
|
case TDengineDataType.TSDB_DATA_TYPE_TINYINT:
|
||||||
|
return "BYTE";
|
||||||
|
case TDengineDataType.TSDB_DATA_TYPE_SMALLINT:
|
||||||
|
return "SHORT";
|
||||||
|
case TDengineDataType.TSDB_DATA_TYPE_INT:
|
||||||
|
return "INT";
|
||||||
|
case TDengineDataType.TSDB_DATA_TYPE_BIGINT:
|
||||||
|
return "LONG";
|
||||||
|
case TDengineDataType.TSDB_DATA_TYPE_FLOAT:
|
||||||
|
return "FLOAT";
|
||||||
|
case TDengineDataType.TSDB_DATA_TYPE_DOUBLE:
|
||||||
|
return "DOUBLE";
|
||||||
|
case TDengineDataType.TSDB_DATA_TYPE_BINARY:
|
||||||
|
return "STRING";
|
||||||
|
case TDengineDataType.TSDB_DATA_TYPE_TIMESTAMP:
|
||||||
|
return "TIMESTAMP";
|
||||||
|
case TDengineDataType.TSDB_DATA_TYPE_NCHAR:
|
||||||
|
return "NCHAR";
|
||||||
|
default:
|
||||||
|
return "undefine";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class TDengine
|
||||||
|
{
|
||||||
|
public const int TSDB_CODE_SUCCESS = 0;
|
||||||
|
|
||||||
|
[DllImport("taos.dll", EntryPoint = "taos_init", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern public void Init();
|
||||||
|
|
||||||
|
[DllImport("taos.dll", EntryPoint = "taos_cleanup", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern public void Cleanup();
|
||||||
|
|
||||||
|
[DllImport("taos.dll", EntryPoint = "taos_options", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern public void Options(int option, string value);
|
||||||
|
|
||||||
|
[DllImport("taos.dll", EntryPoint = "taos_connect", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern public IntPtr Connect(string ip, string user, string password, string db, short port);
|
||||||
|
|
||||||
|
[DllImport("taos.dll", EntryPoint = "taos_errstr", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern private IntPtr taos_errstr(IntPtr res);
|
||||||
|
static public string Error(IntPtr res)
|
||||||
|
{
|
||||||
|
IntPtr errPtr = taos_errstr(res);
|
||||||
|
return Marshal.PtrToStringAnsi(errPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("taos.dll", EntryPoint = "taos_errno", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern public int ErrorNo(IntPtr res);
|
||||||
|
|
||||||
|
[DllImport("taos.dll", EntryPoint = "taos_query", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern public IntPtr Query(IntPtr conn, string sqlstr);
|
||||||
|
|
||||||
|
[DllImport("taos.dll", EntryPoint = "taos_affected_rows", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern public int AffectRows(IntPtr res);
|
||||||
|
|
||||||
|
[DllImport("taos.dll", EntryPoint = "taos_field_count", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern public int FieldCount(IntPtr res);
|
||||||
|
|
||||||
|
[DllImport("taos.dll", EntryPoint = "taos_fetch_fields", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern private IntPtr taos_fetch_fields(IntPtr res);
|
||||||
|
static public List<TDengineMeta> FetchFields(IntPtr res)
|
||||||
|
{
|
||||||
|
const int fieldSize = 68;
|
||||||
|
|
||||||
|
List<TDengineMeta> metas = new List<TDengineMeta>();
|
||||||
|
if (res == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
return metas;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fieldCount = FieldCount(res);
|
||||||
|
IntPtr fieldsPtr = taos_fetch_fields(res);
|
||||||
|
|
||||||
|
for (int i = 0; i < fieldCount; ++i)
|
||||||
|
{
|
||||||
|
int offset = i * fieldSize;
|
||||||
|
|
||||||
|
TDengineMeta meta = new TDengineMeta();
|
||||||
|
meta.name = Marshal.PtrToStringAnsi(fieldsPtr + offset);
|
||||||
|
meta.type = Marshal.ReadByte(fieldsPtr + offset + 65);
|
||||||
|
meta.size = Marshal.ReadInt16(fieldsPtr + offset + 66);
|
||||||
|
metas.Add(meta);
|
||||||
|
}
|
||||||
|
|
||||||
|
return metas;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("taos.dll", EntryPoint = "taos_fetch_row", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern public IntPtr FetchRows(IntPtr res);
|
||||||
|
|
||||||
|
[DllImport("taos.dll", EntryPoint = "taos_free_result", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern public IntPtr FreeResult(IntPtr res);
|
||||||
|
|
||||||
|
[DllImport("taos.dll", EntryPoint = "taos_close", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern public int Close(IntPtr taos);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8c58c512b6acda8bcdfa48fdc7140227b5221766
|
Subproject commit 8d7bf743852897110cbdcc7c4322cd7a74d4167b
|
|
@ -1 +1 @@
|
||||||
Subproject commit d598db167eb256fe67409b7bb3d0eb7fffc3ff8c
|
Subproject commit ec77d9049a719dabfd1a7c1122a209e201861944
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
<groupId>com.taosdata.jdbc</groupId>
|
<groupId>com.taosdata.jdbc</groupId>
|
||||||
<artifactId>taos-jdbcdriver</artifactId>
|
<artifactId>taos-jdbcdriver</artifactId>
|
||||||
<version>2.0.6</version>
|
<version>2.0.9</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>JDBCDriver</name>
|
<name>JDBCDriver</name>
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class TSDBJNIConnector {
|
||||||
pSql = this.executeQueryImp(sql.getBytes(TaosGlobalConfig.getCharset()), this.taos);
|
pSql = this.executeQueryImp(sql.getBytes(TaosGlobalConfig.getCharset()), this.taos);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
this.freeResultSet(pSql);
|
this.freeResultSetImp(this.taos, pSql);
|
||||||
throw new SQLException(TSDBConstants.WrapErrMsg("Unsupported encoding"));
|
throw new SQLException(TSDBConstants.WrapErrMsg("Unsupported encoding"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public class TSDBJNIConnector {
|
||||||
affectedRows = -1;
|
affectedRows = -1;
|
||||||
String msg = this.getErrMsg(pSql);
|
String msg = this.getErrMsg(pSql);
|
||||||
|
|
||||||
this.freeResultSet(pSql);
|
this.freeResultSetImp(this.taos, pSql);
|
||||||
throw new SQLException(TSDBConstants.WrapErrMsg(msg), "", code);
|
throw new SQLException(TSDBConstants.WrapErrMsg(msg), "", code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ public class TSDBJNIConnector {
|
||||||
private native long getResultSetImp(long connection, long pSql);
|
private native long getResultSetImp(long connection, long pSql);
|
||||||
|
|
||||||
public boolean isUpdateQuery(long pSql) {
|
public boolean isUpdateQuery(long pSql) {
|
||||||
return isUpdateQueryImp(this.taos, pSql) == 1? true:false;
|
return isUpdateQueryImp(this.taos, pSql) == 1 ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private native long isUpdateQueryImp(long connection, long pSql);
|
private native long isUpdateQueryImp(long connection, long pSql);
|
||||||
|
|
|
@ -39,16 +39,16 @@
|
||||||
#define cTrace(...) { if (cqDebugFlag & DEBUG_TRACE) { taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__); }}
|
#define cTrace(...) { if (cqDebugFlag & DEBUG_TRACE) { taosPrintLog("CQ ", cqDebugFlag, __VA_ARGS__); }}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int vgId;
|
int32_t vgId;
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
char pass[TSDB_PASSWORD_LEN];
|
char pass[TSDB_PASSWORD_LEN];
|
||||||
char db[TSDB_DB_NAME_LEN];
|
char db[TSDB_DB_NAME_LEN];
|
||||||
FCqWrite cqWrite;
|
FCqWrite cqWrite;
|
||||||
void *ahandle;
|
void *ahandle;
|
||||||
int num; // number of continuous streams
|
int32_t num; // number of continuous streams
|
||||||
struct SCqObj *pHead;
|
struct SCqObj *pHead;
|
||||||
void *dbConn;
|
void *dbConn;
|
||||||
int master;
|
int32_t master;
|
||||||
void *tmrCtrl;
|
void *tmrCtrl;
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
} SCqContext;
|
} SCqContext;
|
||||||
|
@ -57,7 +57,7 @@ typedef struct SCqObj {
|
||||||
tmr_h tmrId;
|
tmr_h tmrId;
|
||||||
uint64_t uid;
|
uint64_t uid;
|
||||||
int32_t tid; // table ID
|
int32_t tid; // table ID
|
||||||
int rowSize; // bytes of a row
|
int32_t rowSize; // bytes of a row
|
||||||
char * sqlStr; // SQL string
|
char * sqlStr; // SQL string
|
||||||
STSchema * pSchema; // pointer to schema array
|
STSchema * pSchema; // pointer to schema array
|
||||||
void * pStream;
|
void * pStream;
|
||||||
|
@ -115,7 +115,7 @@ void cqClose(void *handle) {
|
||||||
SCqObj *pTemp = pObj;
|
SCqObj *pTemp = pObj;
|
||||||
pObj = pObj->next;
|
pObj = pObj->next;
|
||||||
tdFreeSchema(pTemp->pSchema);
|
tdFreeSchema(pTemp->pSchema);
|
||||||
taosTFree(pTemp->sqlStr);
|
tfree(pTemp->sqlStr);
|
||||||
free(pTemp);
|
free(pTemp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ void cqStop(void *handle) {
|
||||||
pthread_mutex_unlock(&pContext->mutex);
|
pthread_mutex_unlock(&pContext->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *cqCreate(void *handle, uint64_t uid, int tid, char *sqlStr, STSchema *pSchema) {
|
void *cqCreate(void *handle, uint64_t uid, int32_t tid, char *sqlStr, STSchema *pSchema) {
|
||||||
SCqContext *pContext = handle;
|
SCqContext *pContext = handle;
|
||||||
|
|
||||||
SCqObj *pObj = calloc(sizeof(SCqObj), 1);
|
SCqObj *pObj = calloc(sizeof(SCqObj), 1);
|
||||||
|
@ -237,7 +237,7 @@ void cqDrop(void *handle) {
|
||||||
pthread_mutex_unlock(&pContext->mutex);
|
pthread_mutex_unlock(&pContext->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doCreateStream(void *param, TAOS_RES *result, int code) {
|
static void doCreateStream(void *param, TAOS_RES *result, int32_t code) {
|
||||||
SCqObj* pObj = (SCqObj*)param;
|
SCqObj* pObj = (SCqObj*)param;
|
||||||
SCqContext* pContext = pObj->pContext;
|
SCqContext* pContext = pObj->pContext;
|
||||||
SSqlObj* pSql = (SSqlObj*)result;
|
SSqlObj* pSql = (SSqlObj*)result;
|
||||||
|
@ -288,7 +288,7 @@ static void cqProcessStreamRes(void *param, TAOS_RES *tres, TAOS_ROW row) {
|
||||||
|
|
||||||
cDebug("vgId:%d, id:%d CQ:%s stream result is ready", pContext->vgId, pObj->tid, pObj->sqlStr);
|
cDebug("vgId:%d, id:%d CQ:%s stream result is ready", pContext->vgId, pObj->tid, pObj->sqlStr);
|
||||||
|
|
||||||
int size = sizeof(SWalHead) + sizeof(SSubmitMsg) + sizeof(SSubmitBlk) + TD_DATA_ROW_HEAD_SIZE + pObj->rowSize;
|
int32_t size = sizeof(SWalHead) + sizeof(SSubmitMsg) + sizeof(SSubmitBlk) + TD_DATA_ROW_HEAD_SIZE + pObj->rowSize;
|
||||||
char *buffer = calloc(size, 1);
|
char *buffer = calloc(size, 1);
|
||||||
|
|
||||||
SWalHead *pHead = (SWalHead *)buffer;
|
SWalHead *pHead = (SWalHead *)buffer;
|
||||||
|
|
|
@ -20,11 +20,11 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t dnodeInitMnodePeer();
|
int32_t dnodeInitMPeer();
|
||||||
void dnodeCleanupMnodePeer();
|
void dnodeCleanupMPeer();
|
||||||
int32_t dnodeAllocateMnodePqueue();
|
int32_t dnodeAllocateMPeerQueue();
|
||||||
void dnodeFreeMnodePqueue();
|
void dnodeFreeMPeerQueue();
|
||||||
void dnodeDispatchToMnodePeerQueue(SRpcMsg *pMsg);
|
void dnodeDispatchToMPeerQueue(SRpcMsg *pMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,11 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t dnodeInitMnodeRead();
|
int32_t dnodeInitMRead();
|
||||||
void dnodeCleanupMnodeRead();
|
void dnodeCleanupMRead();
|
||||||
int32_t dnodeAllocateMnodeRqueue();
|
int32_t dnodeAllocMReadQueue();
|
||||||
void dnodeFreeMnodeRqueue();
|
void dnodeFreeMReadQueue();
|
||||||
void dnodeDispatchToMnodeReadQueue(SRpcMsg *rpcMsg);
|
void dnodeDispatchToMReadQueue(SRpcMsg *rpcMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,11 +20,11 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t dnodeInitMnodeWrite();
|
int32_t dnodeInitMWrite();
|
||||||
void dnodeCleanupMnodeWrite();
|
void dnodeCleanupMWrite();
|
||||||
int32_t dnodeAllocateMnodeWqueue();
|
int32_t dnodeAllocMWritequeue();
|
||||||
void dnodeFreeMnodeWqueue();
|
void dnodeFreeMWritequeue();
|
||||||
void dnodeDispatchToMnodeWriteQueue(SRpcMsg *pMsg);
|
void dnodeDispatchToMWriteQueue(SRpcMsg *pMsg);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,44 +35,44 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t curNum;
|
int32_t curNum;
|
||||||
int32_t maxNum;
|
int32_t maxNum;
|
||||||
SMPeerWorker *peerWorker;
|
SMPeerWorker *worker;
|
||||||
} SMPeerWorkerPool;
|
} SMPeerWorkerPool;
|
||||||
|
|
||||||
static SMPeerWorkerPool tsMPeerPool;
|
static SMPeerWorkerPool tsMPeerWP;
|
||||||
static taos_qset tsMPeerQset;
|
static taos_qset tsMPeerQset;
|
||||||
static taos_queue tsMPeerQueue;
|
static taos_queue tsMPeerQueue;
|
||||||
|
|
||||||
static void *dnodeProcessMnodePeerQueue(void *param);
|
static void *dnodeProcessMPeerQueue(void *param);
|
||||||
|
|
||||||
int32_t dnodeInitMnodePeer() {
|
int32_t dnodeInitMPeer() {
|
||||||
tsMPeerQset = taosOpenQset();
|
tsMPeerQset = taosOpenQset();
|
||||||
|
|
||||||
tsMPeerPool.maxNum = 1;
|
tsMPeerWP.maxNum = 1;
|
||||||
tsMPeerPool.curNum = 0;
|
tsMPeerWP.curNum = 0;
|
||||||
tsMPeerPool.peerWorker = (SMPeerWorker *)calloc(sizeof(SMPeerWorker), tsMPeerPool.maxNum);
|
tsMPeerWP.worker = (SMPeerWorker *)calloc(sizeof(SMPeerWorker), tsMPeerWP.maxNum);
|
||||||
|
|
||||||
if (tsMPeerPool.peerWorker == NULL) return -1;
|
if (tsMPeerWP.worker == NULL) return -1;
|
||||||
for (int32_t i = 0; i < tsMPeerPool.maxNum; ++i) {
|
for (int32_t i = 0; i < tsMPeerWP.maxNum; ++i) {
|
||||||
SMPeerWorker *pWorker = tsMPeerPool.peerWorker + i;
|
SMPeerWorker *pWorker = tsMPeerWP.worker + i;
|
||||||
pWorker->workerId = i;
|
pWorker->workerId = i;
|
||||||
dDebug("dnode mpeer worker:%d is created", i);
|
dDebug("dnode mpeer worker:%d is created", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
dDebug("dnode mpeer is initialized, workers:%d qset:%p", tsMPeerPool.maxNum, tsMPeerQset);
|
dDebug("dnode mpeer is initialized, workers:%d qset:%p", tsMPeerWP.maxNum, tsMPeerQset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeCleanupMnodePeer() {
|
void dnodeCleanupMPeer() {
|
||||||
for (int32_t i = 0; i < tsMPeerPool.maxNum; ++i) {
|
for (int32_t i = 0; i < tsMPeerWP.maxNum; ++i) {
|
||||||
SMPeerWorker *pWorker = tsMPeerPool.peerWorker + i;
|
SMPeerWorker *pWorker = tsMPeerWP.worker + i;
|
||||||
if (pWorker->thread) {
|
if (pWorker->thread) {
|
||||||
taosQsetThreadResume(tsMPeerQset);
|
taosQsetThreadResume(tsMPeerQset);
|
||||||
}
|
}
|
||||||
dDebug("dnode mpeer worker:%d is closed", i);
|
dDebug("dnode mpeer worker:%d is closed", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < tsMPeerPool.maxNum; ++i) {
|
for (int32_t i = 0; i < tsMPeerWP.maxNum; ++i) {
|
||||||
SMPeerWorker *pWorker = tsMPeerPool.peerWorker + i;
|
SMPeerWorker *pWorker = tsMPeerWP.worker + i;
|
||||||
dDebug("dnode mpeer worker:%d start to join", i);
|
dDebug("dnode mpeer worker:%d start to join", i);
|
||||||
if (pWorker->thread) {
|
if (pWorker->thread) {
|
||||||
pthread_join(pWorker->thread, NULL);
|
pthread_join(pWorker->thread, NULL);
|
||||||
|
@ -84,61 +84,60 @@ void dnodeCleanupMnodePeer() {
|
||||||
|
|
||||||
taosCloseQset(tsMPeerQset);
|
taosCloseQset(tsMPeerQset);
|
||||||
tsMPeerQset = NULL;
|
tsMPeerQset = NULL;
|
||||||
taosTFree(tsMPeerPool.peerWorker);
|
tfree(tsMPeerWP.worker);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dnodeAllocateMnodePqueue() {
|
int32_t dnodeAllocateMPeerQueue() {
|
||||||
tsMPeerQueue = taosOpenQueue();
|
tsMPeerQueue = taosOpenQueue();
|
||||||
if (tsMPeerQueue == NULL) return TSDB_CODE_DND_OUT_OF_MEMORY;
|
if (tsMPeerQueue == NULL) return TSDB_CODE_DND_OUT_OF_MEMORY;
|
||||||
|
|
||||||
taosAddIntoQset(tsMPeerQset, tsMPeerQueue, NULL);
|
taosAddIntoQset(tsMPeerQset, tsMPeerQueue, NULL);
|
||||||
|
|
||||||
for (int32_t i = tsMPeerPool.curNum; i < tsMPeerPool.maxNum; ++i) {
|
for (int32_t i = tsMPeerWP.curNum; i < tsMPeerWP.maxNum; ++i) {
|
||||||
SMPeerWorker *pWorker = tsMPeerPool.peerWorker + i;
|
SMPeerWorker *pWorker = tsMPeerWP.worker + i;
|
||||||
pWorker->workerId = i;
|
pWorker->workerId = i;
|
||||||
|
|
||||||
pthread_attr_t thAttr;
|
pthread_attr_t thAttr;
|
||||||
pthread_attr_init(&thAttr);
|
pthread_attr_init(&thAttr);
|
||||||
pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE);
|
pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||||
|
|
||||||
if (pthread_create(&pWorker->thread, &thAttr, dnodeProcessMnodePeerQueue, pWorker) != 0) {
|
if (pthread_create(&pWorker->thread, &thAttr, dnodeProcessMPeerQueue, pWorker) != 0) {
|
||||||
dError("failed to create thread to process mpeer queue, reason:%s", strerror(errno));
|
dError("failed to create thread to process mpeer queue, reason:%s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_attr_destroy(&thAttr);
|
pthread_attr_destroy(&thAttr);
|
||||||
|
|
||||||
tsMPeerPool.curNum = i + 1;
|
tsMPeerWP.curNum = i + 1;
|
||||||
dDebug("dnode mpeer worker:%d is launched, total:%d", pWorker->workerId, tsMPeerPool.maxNum);
|
dDebug("dnode mpeer worker:%d is launched, total:%d", pWorker->workerId, tsMPeerWP.maxNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
dDebug("dnode mpeer queue:%p is allocated", tsMPeerQueue);
|
dDebug("dnode mpeer queue:%p is allocated", tsMPeerQueue);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeFreeMnodePqueue() {
|
void dnodeFreeMPeerQueue() {
|
||||||
dDebug("dnode mpeer queue:%p is freed", tsMPeerQueue);
|
dDebug("dnode mpeer queue:%p is freed", tsMPeerQueue);
|
||||||
taosCloseQueue(tsMPeerQueue);
|
taosCloseQueue(tsMPeerQueue);
|
||||||
tsMPeerQueue = NULL;
|
tsMPeerQueue = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeDispatchToMnodePeerQueue(SRpcMsg *pMsg) {
|
void dnodeDispatchToMPeerQueue(SRpcMsg *pMsg) {
|
||||||
if (!mnodeIsRunning() || tsMPeerQueue == NULL) {
|
if (!mnodeIsRunning() || tsMPeerQueue == NULL) {
|
||||||
dnodeSendRedirectMsg(pMsg, false);
|
dnodeSendRedirectMsg(pMsg, false);
|
||||||
rpcFreeCont(pMsg->pCont);
|
} else {
|
||||||
return;
|
SMnodeMsg *pPeer = mnodeCreateMsg(pMsg);
|
||||||
|
taosWriteQitem(tsMPeerQueue, TAOS_QTYPE_RPC, pPeer);
|
||||||
}
|
}
|
||||||
|
|
||||||
SMnodeMsg *pPeer = (SMnodeMsg *)taosAllocateQitem(sizeof(SMnodeMsg));
|
rpcFreeCont(pMsg->pCont);
|
||||||
mnodeCreateMsg(pPeer, pMsg);
|
|
||||||
taosWriteQitem(tsMPeerQueue, TAOS_QTYPE_RPC, pPeer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dnodeFreeMnodePeerMsg(SMnodeMsg *pPeer) {
|
static void dnodeFreeMPeerMsg(SMnodeMsg *pPeer) {
|
||||||
mnodeCleanupMsg(pPeer);
|
mnodeCleanupMsg(pPeer);
|
||||||
taosFreeQitem(pPeer);
|
taosFreeQitem(pPeer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dnodeSendRpcMnodePeerRsp(SMnodeMsg *pPeer, int32_t code) {
|
static void dnodeSendRpcMPeerRsp(SMnodeMsg *pPeer, int32_t code) {
|
||||||
if (code == TSDB_CODE_MND_ACTION_IN_PROGRESS) return;
|
if (code == TSDB_CODE_MND_ACTION_IN_PROGRESS) return;
|
||||||
|
|
||||||
SRpcMsg rpcRsp = {
|
SRpcMsg rpcRsp = {
|
||||||
|
@ -149,10 +148,10 @@ static void dnodeSendRpcMnodePeerRsp(SMnodeMsg *pPeer, int32_t code) {
|
||||||
};
|
};
|
||||||
|
|
||||||
rpcSendResponse(&rpcRsp);
|
rpcSendResponse(&rpcRsp);
|
||||||
dnodeFreeMnodePeerMsg(pPeer);
|
dnodeFreeMPeerMsg(pPeer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *dnodeProcessMnodePeerQueue(void *param) {
|
static void *dnodeProcessMPeerQueue(void *param) {
|
||||||
SMnodeMsg *pPeerMsg;
|
SMnodeMsg *pPeerMsg;
|
||||||
int32_t type;
|
int32_t type;
|
||||||
void * unUsed;
|
void * unUsed;
|
||||||
|
@ -165,7 +164,7 @@ static void *dnodeProcessMnodePeerQueue(void *param) {
|
||||||
|
|
||||||
dDebug("msg:%s will be processed in mpeer queue", taosMsg[pPeerMsg->rpcMsg.msgType]);
|
dDebug("msg:%s will be processed in mpeer queue", taosMsg[pPeerMsg->rpcMsg.msgType]);
|
||||||
int32_t code = mnodeProcessPeerReq(pPeerMsg);
|
int32_t code = mnodeProcessPeerReq(pPeerMsg);
|
||||||
dnodeSendRpcMnodePeerRsp(pPeerMsg, code);
|
dnodeSendRpcMPeerRsp(pPeerMsg, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -35,46 +35,46 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t curNum;
|
int32_t curNum;
|
||||||
int32_t maxNum;
|
int32_t maxNum;
|
||||||
SMReadWorker *readWorker;
|
SMReadWorker *worker;
|
||||||
} SMReadWorkerPool;
|
} SMReadWorkerPool;
|
||||||
|
|
||||||
static SMReadWorkerPool tsMReadPool;
|
static SMReadWorkerPool tsMReadWP;
|
||||||
static taos_qset tsMReadQset;
|
static taos_qset tsMReadQset;
|
||||||
static taos_queue tsMReadQueue;
|
static taos_queue tsMReadQueue;
|
||||||
|
|
||||||
static void *dnodeProcessMnodeReadQueue(void *param);
|
static void *dnodeProcessMReadQueue(void *param);
|
||||||
|
|
||||||
int32_t dnodeInitMnodeRead() {
|
int32_t dnodeInitMRead() {
|
||||||
tsMReadQset = taosOpenQset();
|
tsMReadQset = taosOpenQset();
|
||||||
|
|
||||||
tsMReadPool.maxNum = tsNumOfCores * tsNumOfThreadsPerCore / 2;
|
tsMReadWP.maxNum = tsNumOfCores * tsNumOfThreadsPerCore / 2;
|
||||||
tsMReadPool.maxNum = MAX(2, tsMReadPool.maxNum);
|
tsMReadWP.maxNum = MAX(2, tsMReadWP.maxNum);
|
||||||
tsMReadPool.maxNum = MIN(4, tsMReadPool.maxNum);
|
tsMReadWP.maxNum = MIN(4, tsMReadWP.maxNum);
|
||||||
tsMReadPool.curNum = 0;
|
tsMReadWP.curNum = 0;
|
||||||
tsMReadPool.readWorker = (SMReadWorker *)calloc(sizeof(SMReadWorker), tsMReadPool.maxNum);
|
tsMReadWP.worker = (SMReadWorker *)calloc(sizeof(SMReadWorker), tsMReadWP.maxNum);
|
||||||
|
|
||||||
if (tsMReadPool.readWorker == NULL) return -1;
|
if (tsMReadWP.worker == NULL) return -1;
|
||||||
for (int32_t i = 0; i < tsMReadPool.maxNum; ++i) {
|
for (int32_t i = 0; i < tsMReadWP.maxNum; ++i) {
|
||||||
SMReadWorker *pWorker = tsMReadPool.readWorker + i;
|
SMReadWorker *pWorker = tsMReadWP.worker + i;
|
||||||
pWorker->workerId = i;
|
pWorker->workerId = i;
|
||||||
dDebug("dnode mread worker:%d is created", i);
|
dDebug("dnode mread worker:%d is created", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
dDebug("dnode mread is initialized, workers:%d qset:%p", tsMReadPool.maxNum, tsMReadQset);
|
dDebug("dnode mread is initialized, workers:%d qset:%p", tsMReadWP.maxNum, tsMReadQset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeCleanupMnodeRead() {
|
void dnodeCleanupMRead() {
|
||||||
for (int32_t i = 0; i < tsMReadPool.maxNum; ++i) {
|
for (int32_t i = 0; i < tsMReadWP.maxNum; ++i) {
|
||||||
SMReadWorker *pWorker = tsMReadPool.readWorker + i;
|
SMReadWorker *pWorker = tsMReadWP.worker + i;
|
||||||
if (pWorker->thread) {
|
if (pWorker->thread) {
|
||||||
taosQsetThreadResume(tsMReadQset);
|
taosQsetThreadResume(tsMReadQset);
|
||||||
}
|
}
|
||||||
dDebug("dnode mread worker:%d is closed", i);
|
dDebug("dnode mread worker:%d is closed", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < tsMReadPool.maxNum; ++i) {
|
for (int32_t i = 0; i < tsMReadWP.maxNum; ++i) {
|
||||||
SMReadWorker *pWorker = tsMReadPool.readWorker + i;
|
SMReadWorker *pWorker = tsMReadWP.worker + i;
|
||||||
dDebug("dnode mread worker:%d start to join", i);
|
dDebug("dnode mread worker:%d start to join", i);
|
||||||
if (pWorker->thread) {
|
if (pWorker->thread) {
|
||||||
pthread_join(pWorker->thread, NULL);
|
pthread_join(pWorker->thread, NULL);
|
||||||
|
@ -86,64 +86,63 @@ void dnodeCleanupMnodeRead() {
|
||||||
|
|
||||||
taosCloseQset(tsMReadQset);
|
taosCloseQset(tsMReadQset);
|
||||||
tsMReadQset = NULL;
|
tsMReadQset = NULL;
|
||||||
free(tsMReadPool.readWorker);
|
free(tsMReadWP.worker);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dnodeAllocateMnodeRqueue() {
|
int32_t dnodeAllocMReadQueue() {
|
||||||
tsMReadQueue = taosOpenQueue();
|
tsMReadQueue = taosOpenQueue();
|
||||||
if (tsMReadQueue == NULL) return TSDB_CODE_DND_OUT_OF_MEMORY;
|
if (tsMReadQueue == NULL) return TSDB_CODE_DND_OUT_OF_MEMORY;
|
||||||
|
|
||||||
taosAddIntoQset(tsMReadQset, tsMReadQueue, NULL);
|
taosAddIntoQset(tsMReadQset, tsMReadQueue, NULL);
|
||||||
|
|
||||||
for (int32_t i = tsMReadPool.curNum; i < tsMReadPool.maxNum; ++i) {
|
for (int32_t i = tsMReadWP.curNum; i < tsMReadWP.maxNum; ++i) {
|
||||||
SMReadWorker *pWorker = tsMReadPool.readWorker + i;
|
SMReadWorker *pWorker = tsMReadWP.worker + i;
|
||||||
pWorker->workerId = i;
|
pWorker->workerId = i;
|
||||||
|
|
||||||
pthread_attr_t thAttr;
|
pthread_attr_t thAttr;
|
||||||
pthread_attr_init(&thAttr);
|
pthread_attr_init(&thAttr);
|
||||||
pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE);
|
pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||||
|
|
||||||
if (pthread_create(&pWorker->thread, &thAttr, dnodeProcessMnodeReadQueue, pWorker) != 0) {
|
if (pthread_create(&pWorker->thread, &thAttr, dnodeProcessMReadQueue, pWorker) != 0) {
|
||||||
dError("failed to create thread to process mread queue, reason:%s", strerror(errno));
|
dError("failed to create thread to process mread queue, reason:%s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_attr_destroy(&thAttr);
|
pthread_attr_destroy(&thAttr);
|
||||||
tsMReadPool.curNum = i + 1;
|
tsMReadWP.curNum = i + 1;
|
||||||
dDebug("dnode mread worker:%d is launched, total:%d", pWorker->workerId, tsMReadPool.maxNum);
|
dDebug("dnode mread worker:%d is launched, total:%d", pWorker->workerId, tsMReadWP.maxNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
dDebug("dnode mread queue:%p is allocated", tsMReadQueue);
|
dDebug("dnode mread queue:%p is allocated", tsMReadQueue);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeFreeMnodeRqueue() {
|
void dnodeFreeMReadQueue() {
|
||||||
dDebug("dnode mread queue:%p is freed", tsMReadQueue);
|
dDebug("dnode mread queue:%p is freed", tsMReadQueue);
|
||||||
taosCloseQueue(tsMReadQueue);
|
taosCloseQueue(tsMReadQueue);
|
||||||
tsMReadQueue = NULL;
|
tsMReadQueue = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeDispatchToMnodeReadQueue(SRpcMsg *pMsg) {
|
void dnodeDispatchToMReadQueue(SRpcMsg *pMsg) {
|
||||||
if (!mnodeIsRunning() || tsMReadQueue == NULL) {
|
if (!mnodeIsRunning() || tsMReadQueue == NULL) {
|
||||||
dnodeSendRedirectMsg(pMsg, true);
|
dnodeSendRedirectMsg(pMsg, true);
|
||||||
rpcFreeCont(pMsg->pCont);
|
} else {
|
||||||
return;
|
SMnodeMsg *pRead = mnodeCreateMsg(pMsg);
|
||||||
|
taosWriteQitem(tsMReadQueue, TAOS_QTYPE_RPC, pRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
SMnodeMsg *pRead = (SMnodeMsg *)taosAllocateQitem(sizeof(SMnodeMsg));
|
rpcFreeCont(pMsg->pCont);
|
||||||
mnodeCreateMsg(pRead, pMsg);
|
|
||||||
taosWriteQitem(tsMReadQueue, TAOS_QTYPE_RPC, pRead);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dnodeFreeMnodeReadMsg(SMnodeMsg *pRead) {
|
static void dnodeFreeMReadMsg(SMnodeMsg *pRead) {
|
||||||
mnodeCleanupMsg(pRead);
|
mnodeCleanupMsg(pRead);
|
||||||
taosFreeQitem(pRead);
|
taosFreeQitem(pRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dnodeSendRpcMnodeReadRsp(SMnodeMsg *pRead, int32_t code) {
|
static void dnodeSendRpcMReadRsp(SMnodeMsg *pRead, int32_t code) {
|
||||||
if (code == TSDB_CODE_MND_ACTION_IN_PROGRESS) return;
|
if (code == TSDB_CODE_MND_ACTION_IN_PROGRESS) return;
|
||||||
if (code == TSDB_CODE_MND_ACTION_NEED_REPROCESSED) {
|
if (code == TSDB_CODE_MND_ACTION_NEED_REPROCESSED) {
|
||||||
// may be a auto create req, should put into write queue
|
// may be a auto create req, should put into write queue
|
||||||
dnodeReprocessMnodeWriteMsg(pRead);
|
dnodeReprocessMWriteMsg(pRead);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,23 +154,23 @@ static void dnodeSendRpcMnodeReadRsp(SMnodeMsg *pRead, int32_t code) {
|
||||||
};
|
};
|
||||||
|
|
||||||
rpcSendResponse(&rpcRsp);
|
rpcSendResponse(&rpcRsp);
|
||||||
dnodeFreeMnodeReadMsg(pRead);
|
dnodeFreeMReadMsg(pRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *dnodeProcessMnodeReadQueue(void *param) {
|
static void *dnodeProcessMReadQueue(void *param) {
|
||||||
SMnodeMsg *pReadMsg;
|
SMnodeMsg *pRead;
|
||||||
int32_t type;
|
int32_t type;
|
||||||
void * unUsed;
|
void * unUsed;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (taosReadQitemFromQset(tsMReadQset, &type, (void **)&pReadMsg, &unUsed) == 0) {
|
if (taosReadQitemFromQset(tsMReadQset, &type, (void **)&pRead, &unUsed) == 0) {
|
||||||
dDebug("qset:%p, mnode read got no message from qset, exiting", tsMReadQset);
|
dDebug("qset:%p, mnode read got no message from qset, exiting", tsMReadQset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dDebug("%p, msg:%s will be processed in mread queue", pReadMsg->rpcMsg.ahandle, taosMsg[pReadMsg->rpcMsg.msgType]);
|
dDebug("%p, msg:%s will be processed in mread queue", pRead->rpcMsg.ahandle, taosMsg[pRead->rpcMsg.msgType]);
|
||||||
int32_t code = mnodeProcessRead(pReadMsg);
|
int32_t code = mnodeProcessRead(pRead);
|
||||||
dnodeSendRpcMnodeReadRsp(pReadMsg, code);
|
dnodeSendRpcMReadRsp(pRead, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -36,45 +36,45 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t curNum;
|
int32_t curNum;
|
||||||
int32_t maxNum;
|
int32_t maxNum;
|
||||||
SMWriteWorker *writeWorker;
|
SMWriteWorker *worker;
|
||||||
} SMWriteWorkerPool;
|
} SMWriteWorkerPool;
|
||||||
|
|
||||||
static SMWriteWorkerPool tsMWritePool;
|
static SMWriteWorkerPool tsMWriteWP;
|
||||||
static taos_qset tsMWriteQset;
|
static taos_qset tsMWriteQset;
|
||||||
static taos_queue tsMWriteQueue;
|
static taos_queue tsMWriteQueue;
|
||||||
extern void * tsDnodeTmr;
|
extern void * tsDnodeTmr;
|
||||||
|
|
||||||
static void *dnodeProcessMnodeWriteQueue(void *param);
|
static void *dnodeProcessMWriteQueue(void *param);
|
||||||
|
|
||||||
int32_t dnodeInitMnodeWrite() {
|
int32_t dnodeInitMWrite() {
|
||||||
tsMWriteQset = taosOpenQset();
|
tsMWriteQset = taosOpenQset();
|
||||||
|
|
||||||
tsMWritePool.maxNum = 1;
|
tsMWriteWP.maxNum = 1;
|
||||||
tsMWritePool.curNum = 0;
|
tsMWriteWP.curNum = 0;
|
||||||
tsMWritePool.writeWorker = (SMWriteWorker *)calloc(sizeof(SMWriteWorker), tsMWritePool.maxNum);
|
tsMWriteWP.worker = (SMWriteWorker *)calloc(sizeof(SMWriteWorker), tsMWriteWP.maxNum);
|
||||||
|
|
||||||
if (tsMWritePool.writeWorker == NULL) return -1;
|
if (tsMWriteWP.worker == NULL) return -1;
|
||||||
for (int32_t i = 0; i < tsMWritePool.maxNum; ++i) {
|
for (int32_t i = 0; i < tsMWriteWP.maxNum; ++i) {
|
||||||
SMWriteWorker *pWorker = tsMWritePool.writeWorker + i;
|
SMWriteWorker *pWorker = tsMWriteWP.worker + i;
|
||||||
pWorker->workerId = i;
|
pWorker->workerId = i;
|
||||||
dDebug("dnode mwrite worker:%d is created", i);
|
dDebug("dnode mwrite worker:%d is created", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
dDebug("dnode mwrite is initialized, workers:%d qset:%p", tsMWritePool.maxNum, tsMWriteQset);
|
dDebug("dnode mwrite is initialized, workers:%d qset:%p", tsMWriteWP.maxNum, tsMWriteQset);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeCleanupMnodeWrite() {
|
void dnodeCleanupMWrite() {
|
||||||
for (int32_t i = 0; i < tsMWritePool.maxNum; ++i) {
|
for (int32_t i = 0; i < tsMWriteWP.maxNum; ++i) {
|
||||||
SMWriteWorker *pWorker = tsMWritePool.writeWorker + i;
|
SMWriteWorker *pWorker = tsMWriteWP.worker + i;
|
||||||
if (pWorker->thread) {
|
if (pWorker->thread) {
|
||||||
taosQsetThreadResume(tsMWriteQset);
|
taosQsetThreadResume(tsMWriteQset);
|
||||||
}
|
}
|
||||||
dDebug("dnode mwrite worker:%d is closed", i);
|
dDebug("dnode mwrite worker:%d is closed", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < tsMWritePool.maxNum; ++i) {
|
for (int32_t i = 0; i < tsMWriteWP.maxNum; ++i) {
|
||||||
SMWriteWorker *pWorker = tsMWritePool.writeWorker + i;
|
SMWriteWorker *pWorker = tsMWriteWP.worker + i;
|
||||||
dDebug("dnode mwrite worker:%d start to join", i);
|
dDebug("dnode mwrite worker:%d start to join", i);
|
||||||
if (pWorker->thread) {
|
if (pWorker->thread) {
|
||||||
pthread_join(pWorker->thread, NULL);
|
pthread_join(pWorker->thread, NULL);
|
||||||
|
@ -86,58 +86,56 @@ void dnodeCleanupMnodeWrite() {
|
||||||
|
|
||||||
taosCloseQset(tsMWriteQset);
|
taosCloseQset(tsMWriteQset);
|
||||||
tsMWriteQset = NULL;
|
tsMWriteQset = NULL;
|
||||||
taosTFree(tsMWritePool.writeWorker);
|
tfree(tsMWriteWP.worker);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dnodeAllocateMnodeWqueue() {
|
int32_t dnodeAllocMWritequeue() {
|
||||||
tsMWriteQueue = taosOpenQueue();
|
tsMWriteQueue = taosOpenQueue();
|
||||||
if (tsMWriteQueue == NULL) return TSDB_CODE_DND_OUT_OF_MEMORY;
|
if (tsMWriteQueue == NULL) return TSDB_CODE_DND_OUT_OF_MEMORY;
|
||||||
|
|
||||||
taosAddIntoQset(tsMWriteQset, tsMWriteQueue, NULL);
|
taosAddIntoQset(tsMWriteQset, tsMWriteQueue, NULL);
|
||||||
|
|
||||||
for (int32_t i = tsMWritePool.curNum; i < tsMWritePool.maxNum; ++i) {
|
for (int32_t i = tsMWriteWP.curNum; i < tsMWriteWP.maxNum; ++i) {
|
||||||
SMWriteWorker *pWorker = tsMWritePool.writeWorker + i;
|
SMWriteWorker *pWorker = tsMWriteWP.worker + i;
|
||||||
pWorker->workerId = i;
|
pWorker->workerId = i;
|
||||||
|
|
||||||
pthread_attr_t thAttr;
|
pthread_attr_t thAttr;
|
||||||
pthread_attr_init(&thAttr);
|
pthread_attr_init(&thAttr);
|
||||||
pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE);
|
pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||||
|
|
||||||
if (pthread_create(&pWorker->thread, &thAttr, dnodeProcessMnodeWriteQueue, pWorker) != 0) {
|
if (pthread_create(&pWorker->thread, &thAttr, dnodeProcessMWriteQueue, pWorker) != 0) {
|
||||||
dError("failed to create thread to process mwrite queue, reason:%s", strerror(errno));
|
dError("failed to create thread to process mwrite queue, reason:%s", strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_attr_destroy(&thAttr);
|
pthread_attr_destroy(&thAttr);
|
||||||
tsMWritePool.curNum = i + 1;
|
tsMWriteWP.curNum = i + 1;
|
||||||
dDebug("dnode mwrite worker:%d is launched, total:%d", pWorker->workerId, tsMWritePool.maxNum);
|
dDebug("dnode mwrite worker:%d is launched, total:%d", pWorker->workerId, tsMWriteWP.maxNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
dDebug("dnode mwrite queue:%p is allocated", tsMWriteQueue);
|
dDebug("dnode mwrite queue:%p is allocated", tsMWriteQueue);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeFreeMnodeWqueue() {
|
void dnodeFreeMWritequeue() {
|
||||||
dDebug("dnode mwrite queue:%p is freed", tsMWriteQueue);
|
dDebug("dnode mwrite queue:%p is freed", tsMWriteQueue);
|
||||||
taosCloseQueue(tsMWriteQueue);
|
taosCloseQueue(tsMWriteQueue);
|
||||||
tsMWriteQueue = NULL;
|
tsMWriteQueue = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeDispatchToMnodeWriteQueue(SRpcMsg *pMsg) {
|
void dnodeDispatchToMWriteQueue(SRpcMsg *pMsg) {
|
||||||
if (!mnodeIsRunning() || tsMWriteQueue == NULL) {
|
if (!mnodeIsRunning() || tsMWriteQueue == NULL) {
|
||||||
dnodeSendRedirectMsg(pMsg, true);
|
dnodeSendRedirectMsg(pMsg, true);
|
||||||
rpcFreeCont(pMsg->pCont);
|
} else {
|
||||||
return;
|
SMnodeMsg *pWrite = mnodeCreateMsg(pMsg);
|
||||||
}
|
|
||||||
|
|
||||||
SMnodeMsg *pWrite = (SMnodeMsg *)taosAllocateQitem(sizeof(SMnodeMsg));
|
|
||||||
mnodeCreateMsg(pWrite, pMsg);
|
|
||||||
|
|
||||||
dDebug("app:%p:%p, msg:%s is put into mwrite queue:%p", pWrite->rpcMsg.ahandle, pWrite,
|
dDebug("app:%p:%p, msg:%s is put into mwrite queue:%p", pWrite->rpcMsg.ahandle, pWrite,
|
||||||
taosMsg[pWrite->rpcMsg.msgType], tsMWriteQueue);
|
taosMsg[pWrite->rpcMsg.msgType], tsMWriteQueue);
|
||||||
taosWriteQitem(tsMWriteQueue, TAOS_QTYPE_RPC, pWrite);
|
taosWriteQitem(tsMWriteQueue, TAOS_QTYPE_RPC, pWrite);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dnodeFreeMnodeWriteMsg(SMnodeMsg *pWrite) {
|
static void dnodeFreeMWriteMsg(SMnodeMsg *pWrite) {
|
||||||
dDebug("app:%p:%p, msg:%s is freed from mwrite queue:%p", pWrite->rpcMsg.ahandle, pWrite,
|
dDebug("app:%p:%p, msg:%s is freed from mwrite queue:%p", pWrite->rpcMsg.ahandle, pWrite,
|
||||||
taosMsg[pWrite->rpcMsg.msgType], tsMWriteQueue);
|
taosMsg[pWrite->rpcMsg.msgType], tsMWriteQueue);
|
||||||
|
|
||||||
|
@ -145,12 +143,12 @@ static void dnodeFreeMnodeWriteMsg(SMnodeMsg *pWrite) {
|
||||||
taosFreeQitem(pWrite);
|
taosFreeQitem(pWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeSendRpcMnodeWriteRsp(void *pMsg, int32_t code) {
|
void dnodeSendRpcMWriteRsp(void *pMsg, int32_t code) {
|
||||||
SMnodeMsg *pWrite = pMsg;
|
SMnodeMsg *pWrite = pMsg;
|
||||||
if (pWrite == NULL) return;
|
if (pWrite == NULL) return;
|
||||||
if (code == TSDB_CODE_MND_ACTION_IN_PROGRESS) return;
|
if (code == TSDB_CODE_MND_ACTION_IN_PROGRESS) return;
|
||||||
if (code == TSDB_CODE_MND_ACTION_NEED_REPROCESSED) {
|
if (code == TSDB_CODE_MND_ACTION_NEED_REPROCESSED) {
|
||||||
dnodeReprocessMnodeWriteMsg(pWrite);
|
dnodeReprocessMWriteMsg(pWrite);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,10 +160,10 @@ void dnodeSendRpcMnodeWriteRsp(void *pMsg, int32_t code) {
|
||||||
};
|
};
|
||||||
|
|
||||||
rpcSendResponse(&rpcRsp);
|
rpcSendResponse(&rpcRsp);
|
||||||
dnodeFreeMnodeWriteMsg(pWrite);
|
dnodeFreeMWriteMsg(pWrite);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *dnodeProcessMnodeWriteQueue(void *param) {
|
static void *dnodeProcessMWriteQueue(void *param) {
|
||||||
SMnodeMsg *pWrite;
|
SMnodeMsg *pWrite;
|
||||||
int32_t type;
|
int32_t type;
|
||||||
void * unUsed;
|
void * unUsed;
|
||||||
|
@ -180,13 +178,13 @@ static void *dnodeProcessMnodeWriteQueue(void *param) {
|
||||||
taosMsg[pWrite->rpcMsg.msgType]);
|
taosMsg[pWrite->rpcMsg.msgType]);
|
||||||
|
|
||||||
int32_t code = mnodeProcessWrite(pWrite);
|
int32_t code = mnodeProcessWrite(pWrite);
|
||||||
dnodeSendRpcMnodeWriteRsp(pWrite, code);
|
dnodeSendRpcMWriteRsp(pWrite, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeReprocessMnodeWriteMsg(void *pMsg) {
|
void dnodeReprocessMWriteMsg(void *pMsg) {
|
||||||
SMnodeMsg *pWrite = pMsg;
|
SMnodeMsg *pWrite = pMsg;
|
||||||
|
|
||||||
if (!mnodeIsRunning() || tsMWriteQueue == NULL) {
|
if (!mnodeIsRunning() || tsMWriteQueue == NULL) {
|
||||||
|
@ -194,7 +192,7 @@ void dnodeReprocessMnodeWriteMsg(void *pMsg) {
|
||||||
taosMsg[pWrite->rpcMsg.msgType], pWrite->retry);
|
taosMsg[pWrite->rpcMsg.msgType], pWrite->retry);
|
||||||
|
|
||||||
dnodeSendRedirectMsg(pMsg, true);
|
dnodeSendRedirectMsg(pMsg, true);
|
||||||
dnodeFreeMnodeWriteMsg(pWrite);
|
dnodeFreeMWriteMsg(pWrite);
|
||||||
} else {
|
} else {
|
||||||
dDebug("app:%p:%p, msg:%s is reput into mwrite queue:%p, retry times:%d", pWrite->rpcMsg.ahandle, pWrite,
|
dDebug("app:%p:%p, msg:%s is reput into mwrite queue:%p, retry times:%d", pWrite->rpcMsg.ahandle, pWrite,
|
||||||
taosMsg[pWrite->rpcMsg.msgType], tsMWriteQueue, pWrite->retry);
|
taosMsg[pWrite->rpcMsg.msgType], tsMWriteQueue, pWrite->retry);
|
||||||
|
@ -203,12 +201,12 @@ void dnodeReprocessMnodeWriteMsg(void *pMsg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dnodeDoDelayReprocessMnodeWriteMsg(void *param, void *tmrId) {
|
static void dnodeDoDelayReprocessMWriteMsg(void *param, void *tmrId) {
|
||||||
dnodeReprocessMnodeWriteMsg(param);
|
dnodeReprocessMWriteMsg(param);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeDelayReprocessMnodeWriteMsg(void *pMsg) {
|
void dnodeDelayReprocessMWriteMsg(void *pMsg) {
|
||||||
SMnodeMsg *mnodeMsg = pMsg;
|
SMnodeMsg *mnodeMsg = pMsg;
|
||||||
void *unUsed = NULL;
|
void *unUsed = NULL;
|
||||||
taosTmrReset(dnodeDoDelayReprocessMnodeWriteMsg, 300, mnodeMsg, tsDnodeTmr, &unUsed);
|
taosTmrReset(dnodeDoDelayReprocessMWriteMsg, 300, mnodeMsg, tsDnodeTmr, &unUsed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,11 @@
|
||||||
#include "dnodeShell.h"
|
#include "dnodeShell.h"
|
||||||
#include "dnodeTelemetry.h"
|
#include "dnodeTelemetry.h"
|
||||||
|
|
||||||
static SDnodeRunStatus tsDnodeRunStatus = TSDB_DNODE_RUN_STATUS_STOPPED;
|
static SRunStatus tsRunStatus = TSDB_RUN_STATUS_STOPPED;
|
||||||
|
|
||||||
static int32_t dnodeInitStorage();
|
static int32_t dnodeInitStorage();
|
||||||
static void dnodeCleanupStorage();
|
static void dnodeCleanupStorage();
|
||||||
static void dnodeSetRunStatus(SDnodeRunStatus status);
|
static void dnodeSetRunStatus(SRunStatus status);
|
||||||
static void dnodeCheckDataDirOpenned(char *dir);
|
static void dnodeCheckDataDirOpenned(char *dir);
|
||||||
static int32_t dnodeInitComponents();
|
static int32_t dnodeInitComponents();
|
||||||
static void dnodeCleanupComponents(int32_t stepId);
|
static void dnodeCleanupComponents(int32_t stepId);
|
||||||
|
@ -63,9 +63,9 @@ static const SDnodeComponent tsDnodeComponents[] = {
|
||||||
{"check", dnodeInitCheck, dnodeCleanupCheck}, // NOTES: dnodeInitCheck must be behind the dnodeinitStorage component !!!
|
{"check", dnodeInitCheck, dnodeCleanupCheck}, // NOTES: dnodeInitCheck must be behind the dnodeinitStorage component !!!
|
||||||
{"vread", dnodeInitVRead, dnodeCleanupVRead},
|
{"vread", dnodeInitVRead, dnodeCleanupVRead},
|
||||||
{"vwrite", dnodeInitVWrite, dnodeCleanupVWrite},
|
{"vwrite", dnodeInitVWrite, dnodeCleanupVWrite},
|
||||||
{"mread", dnodeInitMnodeRead, dnodeCleanupMnodeRead},
|
{"mread", dnodeInitMRead, dnodeCleanupMRead},
|
||||||
{"mwrite", dnodeInitMnodeWrite, dnodeCleanupMnodeWrite},
|
{"mwrite", dnodeInitMWrite, dnodeCleanupMWrite},
|
||||||
{"mpeer", dnodeInitMnodePeer, dnodeCleanupMnodePeer},
|
{"mpeer", dnodeInitMPeer, dnodeCleanupMPeer},
|
||||||
{"client", dnodeInitClient, dnodeCleanupClient},
|
{"client", dnodeInitClient, dnodeCleanupClient},
|
||||||
{"server", dnodeInitServer, dnodeCleanupServer},
|
{"server", dnodeInitServer, dnodeCleanupServer},
|
||||||
{"mgmt", dnodeInitMgmt, dnodeCleanupMgmt},
|
{"mgmt", dnodeInitMgmt, dnodeCleanupMgmt},
|
||||||
|
@ -104,7 +104,7 @@ static int32_t dnodeInitComponents() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t dnodeInitSystem() {
|
int32_t dnodeInitSystem() {
|
||||||
dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_INITIALIZE);
|
dnodeSetRunStatus(TSDB_RUN_STATUS_INITIALIZE);
|
||||||
tscEmbedded = 1;
|
tscEmbedded = 1;
|
||||||
taosBlockSIGPIPE();
|
taosBlockSIGPIPE();
|
||||||
taosResolveCRC();
|
taosResolveCRC();
|
||||||
|
@ -137,7 +137,7 @@ int32_t dnodeInitSystem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
dnodeStartModules();
|
dnodeStartModules();
|
||||||
dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_RUNING);
|
dnodeSetRunStatus(TSDB_RUN_STATUS_RUNING);
|
||||||
|
|
||||||
dInfo("TDengine is initialized successfully");
|
dInfo("TDengine is initialized successfully");
|
||||||
|
|
||||||
|
@ -145,20 +145,20 @@ int32_t dnodeInitSystem() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeCleanUpSystem() {
|
void dnodeCleanUpSystem() {
|
||||||
if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_STOPPED) {
|
if (dnodeGetRunStatus() != TSDB_RUN_STATUS_STOPPED) {
|
||||||
dnodeSetRunStatus(TSDB_DNODE_RUN_STATUS_STOPPED);
|
dnodeSetRunStatus(TSDB_RUN_STATUS_STOPPED);
|
||||||
dnodeCleanupComponents(sizeof(tsDnodeComponents) / sizeof(tsDnodeComponents[0]) - 1);
|
dnodeCleanupComponents(sizeof(tsDnodeComponents) / sizeof(tsDnodeComponents[0]) - 1);
|
||||||
taos_cleanup();
|
taos_cleanup();
|
||||||
taosCloseLog();
|
taosCloseLog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeRunStatus dnodeGetRunStatus() {
|
SRunStatus dnodeGetRunStatus() {
|
||||||
return tsDnodeRunStatus;
|
return tsRunStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dnodeSetRunStatus(SDnodeRunStatus status) {
|
static void dnodeSetRunStatus(SRunStatus status) {
|
||||||
tsDnodeRunStatus = status;
|
tsRunStatus = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dnodeCheckDataDirOpenned(char *dir) {
|
static void dnodeCheckDataDirOpenned(char *dir) {
|
||||||
|
|
|
@ -47,6 +47,11 @@ typedef struct {
|
||||||
int32_t * vnodeList;
|
int32_t * vnodeList;
|
||||||
} SOpenVnodeThread;
|
} SOpenVnodeThread;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
SRpcMsg rpcMsg;
|
||||||
|
char pCont[];
|
||||||
|
} SMgmtMsg;
|
||||||
|
|
||||||
void * tsDnodeTmr = NULL;
|
void * tsDnodeTmr = NULL;
|
||||||
static void * tsStatusTimer = NULL;
|
static void * tsStatusTimer = NULL;
|
||||||
static uint32_t tsRebootTime;
|
static uint32_t tsRebootTime;
|
||||||
|
@ -172,38 +177,46 @@ void dnodeCleanupMgmt() {
|
||||||
vnodeCleanupResources();
|
vnodeCleanupResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeDispatchToMgmtQueue(SRpcMsg *pMsg) {
|
static int32_t dnodeWriteToMgmtQueue(SRpcMsg *pMsg) {
|
||||||
void *item;
|
int32_t size = sizeof(SMgmtMsg) + pMsg->contLen;
|
||||||
|
SMgmtMsg *pMgmt = taosAllocateQitem(size);
|
||||||
item = taosAllocateQitem(sizeof(SRpcMsg));
|
if (pMgmt == NULL) {
|
||||||
if (item) {
|
return TSDB_CODE_DND_OUT_OF_MEMORY;
|
||||||
memcpy(item, pMsg, sizeof(SRpcMsg));
|
|
||||||
taosWriteQitem(tsMgmtQueue, 1, item);
|
|
||||||
} else {
|
|
||||||
SRpcMsg rsp = {
|
|
||||||
.handle = pMsg->handle,
|
|
||||||
.pCont = NULL,
|
|
||||||
.code = TSDB_CODE_DND_OUT_OF_MEMORY
|
|
||||||
};
|
|
||||||
|
|
||||||
rpcSendResponse(&rsp);
|
|
||||||
rpcFreeCont(pMsg->pCont);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pMgmt->rpcMsg = *pMsg;
|
||||||
|
pMgmt->rpcMsg.pCont = pMgmt->pCont;
|
||||||
|
memcpy(pMgmt->pCont, pMsg->pCont, pMsg->contLen);
|
||||||
|
taosWriteQitem(tsMgmtQueue, TAOS_QTYPE_RPC, pMgmt);
|
||||||
|
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dnodeDispatchToMgmtQueue(SRpcMsg *pMsg) {
|
||||||
|
int32_t code = dnodeWriteToMgmtQueue(pMsg);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
SRpcMsg rsp = {.handle = pMsg->handle, .code = code};
|
||||||
|
rpcSendResponse(&rsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *dnodeProcessMgmtQueue(void *param) {
|
static void *dnodeProcessMgmtQueue(void *param) {
|
||||||
SRpcMsg *pMsg;
|
SMgmtMsg *pMgmt;
|
||||||
|
SRpcMsg * pMsg;
|
||||||
SRpcMsg rsp = {0};
|
SRpcMsg rsp = {0};
|
||||||
int type;
|
int32_t qtype;
|
||||||
void * handle;
|
void * handle;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (taosReadQitemFromQset(tsMgmtQset, &type, (void **) &pMsg, &handle) == 0) {
|
if (taosReadQitemFromQset(tsMgmtQset, &qtype, (void **)&pMgmt, &handle) == 0) {
|
||||||
dDebug("qset:%p, dnode mgmt got no message from qset, exit", tsMgmtQset);
|
dDebug("qset:%p, dnode mgmt got no message from qset, exit", tsMgmtQset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dDebug("%p, msg:%s will be processed", pMsg->ahandle, taosMsg[pMsg->msgType]);
|
pMsg = &pMgmt->rpcMsg;
|
||||||
|
dDebug("%p, msg:%p:%s will be processed", pMsg->ahandle, pMgmt, taosMsg[pMsg->msgType]);
|
||||||
if (dnodeProcessMgmtMsgFp[pMsg->msgType]) {
|
if (dnodeProcessMgmtMsgFp[pMsg->msgType]) {
|
||||||
rsp.code = (*dnodeProcessMgmtMsgFp[pMsg->msgType])(pMsg);
|
rsp.code = (*dnodeProcessMgmtMsgFp[pMsg->msgType])(pMsg);
|
||||||
} else {
|
} else {
|
||||||
|
@ -214,7 +227,6 @@ static void *dnodeProcessMgmtQueue(void *param) {
|
||||||
rsp.pCont = NULL;
|
rsp.pCont = NULL;
|
||||||
rpcSendResponse(&rsp);
|
rpcSendResponse(&rsp);
|
||||||
|
|
||||||
rpcFreeCont(pMsg->pCont);
|
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
* to dnode. All theses messages are handled from here
|
* to dnode. All theses messages are handled from here
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "tglobal.h"
|
#include "tglobal.h"
|
||||||
|
@ -34,8 +35,8 @@ static void (*dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
|
||||||
static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcEpSet *);
|
static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcEpSet *);
|
||||||
static void (*dnodeProcessRspMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg);
|
static void (*dnodeProcessRspMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *rpcMsg);
|
||||||
static void dnodeProcessRspFromDnode(SRpcMsg *pMsg, SRpcEpSet *pEpSet);
|
static void dnodeProcessRspFromDnode(SRpcMsg *pMsg, SRpcEpSet *pEpSet);
|
||||||
static void *tsDnodeServerRpc = NULL;
|
static void *tsServerRpc = NULL;
|
||||||
static void *tsDnodeClientRpc = NULL;
|
static void *tsClientRpc = NULL;
|
||||||
|
|
||||||
int32_t dnodeInitServer() {
|
int32_t dnodeInitServer() {
|
||||||
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_TABLE] = dnodeDispatchToVWriteQueue;
|
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_TABLE] = dnodeDispatchToVWriteQueue;
|
||||||
|
@ -50,11 +51,11 @@ int32_t dnodeInitServer() {
|
||||||
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeDispatchToMgmtQueue;
|
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CONFIG_DNODE] = dnodeDispatchToMgmtQueue;
|
||||||
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_MNODE] = dnodeDispatchToMgmtQueue;
|
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_MD_CREATE_MNODE] = dnodeDispatchToMgmtQueue;
|
||||||
|
|
||||||
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_TABLE] = dnodeDispatchToMnodePeerQueue;
|
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_TABLE] = dnodeDispatchToMPeerQueue;
|
||||||
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = dnodeDispatchToMnodePeerQueue;
|
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_CONFIG_VNODE] = dnodeDispatchToMPeerQueue;
|
||||||
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_AUTH] = dnodeDispatchToMnodePeerQueue;
|
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_AUTH] = dnodeDispatchToMPeerQueue;
|
||||||
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_GRANT] = dnodeDispatchToMnodePeerQueue;
|
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_GRANT] = dnodeDispatchToMPeerQueue;
|
||||||
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_STATUS] = dnodeDispatchToMnodePeerQueue;
|
dnodeProcessReqMsgFp[TSDB_MSG_TYPE_DM_STATUS] = dnodeDispatchToMPeerQueue;
|
||||||
|
|
||||||
SRpcInit rpcInit;
|
SRpcInit rpcInit;
|
||||||
memset(&rpcInit, 0, sizeof(rpcInit));
|
memset(&rpcInit, 0, sizeof(rpcInit));
|
||||||
|
@ -66,8 +67,8 @@ int32_t dnodeInitServer() {
|
||||||
rpcInit.connType = TAOS_CONN_SERVER;
|
rpcInit.connType = TAOS_CONN_SERVER;
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
|
|
||||||
tsDnodeServerRpc = rpcOpen(&rpcInit);
|
tsServerRpc = rpcOpen(&rpcInit);
|
||||||
if (tsDnodeServerRpc == NULL) {
|
if (tsServerRpc == NULL) {
|
||||||
dError("failed to init inter-dnodes RPC server");
|
dError("failed to init inter-dnodes RPC server");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -77,9 +78,9 @@ int32_t dnodeInitServer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeCleanupServer() {
|
void dnodeCleanupServer() {
|
||||||
if (tsDnodeServerRpc) {
|
if (tsServerRpc) {
|
||||||
rpcClose(tsDnodeServerRpc);
|
rpcClose(tsServerRpc);
|
||||||
tsDnodeServerRpc = NULL;
|
tsServerRpc = NULL;
|
||||||
dInfo("inter-dnodes RPC server is closed");
|
dInfo("inter-dnodes RPC server is closed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +94,7 @@ static void dnodeProcessReqMsgFromDnode(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
|
||||||
|
|
||||||
if (pMsg->pCont == NULL) return;
|
if (pMsg->pCont == NULL) return;
|
||||||
|
|
||||||
if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_RUNING) {
|
if (dnodeGetRunStatus() != TSDB_RUN_STATUS_RUNING) {
|
||||||
rspMsg.code = TSDB_CODE_APP_NOT_READY;
|
rspMsg.code = TSDB_CODE_APP_NOT_READY;
|
||||||
rpcSendResponse(&rspMsg);
|
rpcSendResponse(&rspMsg);
|
||||||
rpcFreeCont(pMsg->pCont);
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
@ -131,8 +132,8 @@ int32_t dnodeInitClient() {
|
||||||
rpcInit.ckey = "key";
|
rpcInit.ckey = "key";
|
||||||
rpcInit.secret = secret;
|
rpcInit.secret = secret;
|
||||||
|
|
||||||
tsDnodeClientRpc = rpcOpen(&rpcInit);
|
tsClientRpc = rpcOpen(&rpcInit);
|
||||||
if (tsDnodeClientRpc == NULL) {
|
if (tsClientRpc == NULL) {
|
||||||
dError("failed to init mnode rpc client");
|
dError("failed to init mnode rpc client");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -142,9 +143,9 @@ int32_t dnodeInitClient() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeCleanupClient() {
|
void dnodeCleanupClient() {
|
||||||
if (tsDnodeClientRpc) {
|
if (tsClientRpc) {
|
||||||
rpcClose(tsDnodeClientRpc);
|
rpcClose(tsClientRpc);
|
||||||
tsDnodeClientRpc = NULL;
|
tsClientRpc = NULL;
|
||||||
dInfo("dnode inter-dnodes rpc client is closed");
|
dInfo("dnode inter-dnodes rpc client is closed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,15 +169,15 @@ void dnodeAddClientRspHandle(uint8_t msgType, void (*fp)(SRpcMsg *rpcMsg)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeSendMsgToDnode(SRpcEpSet *epSet, SRpcMsg *rpcMsg) {
|
void dnodeSendMsgToDnode(SRpcEpSet *epSet, SRpcMsg *rpcMsg) {
|
||||||
rpcSendRequest(tsDnodeClientRpc, epSet, rpcMsg);
|
rpcSendRequest(tsClientRpc, epSet, rpcMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeSendMsgToMnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp) {
|
void dnodeSendMsgToMnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp) {
|
||||||
SRpcEpSet epSet = {0};
|
SRpcEpSet epSet = {0};
|
||||||
dnodeGetEpSetForPeer(&epSet);
|
dnodeGetEpSetForPeer(&epSet);
|
||||||
rpcSendRecv(tsDnodeClientRpc, &epSet, rpcMsg, rpcRsp);
|
rpcSendRecv(tsClientRpc, &epSet, rpcMsg, rpcRsp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp, SRpcEpSet *epSet) {
|
void dnodeSendMsgToDnodeRecv(SRpcMsg *rpcMsg, SRpcMsg *rpcRsp, SRpcEpSet *epSet) {
|
||||||
rpcSendRecv(tsDnodeClientRpc, epSet, rpcMsg, rpcRsp);
|
rpcSendRecv(tsClientRpc, epSet, rpcMsg, rpcRsp);
|
||||||
}
|
}
|
|
@ -33,9 +33,9 @@
|
||||||
static void (*dnodeProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
|
static void (*dnodeProcessShellMsgFp[TSDB_MSG_TYPE_MAX])(SRpcMsg *);
|
||||||
static void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcEpSet *);
|
static void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcEpSet *);
|
||||||
static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
static int dnodeRetrieveUserAuthInfo(char *user, char *spi, char *encrypt, char *secret, char *ckey);
|
||||||
static void * tsDnodeShellRpc = NULL;
|
static void * tsShellRpc = NULL;
|
||||||
static int32_t tsDnodeQueryReqNum = 0;
|
static int32_t tsQueryReqNum = 0;
|
||||||
static int32_t tsDnodeSubmitReqNum = 0;
|
static int32_t tsSubmitReqNum = 0;
|
||||||
|
|
||||||
int32_t dnodeInitShell() {
|
int32_t dnodeInitShell() {
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_SUBMIT] = dnodeDispatchToVWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_SUBMIT] = dnodeDispatchToVWriteQueue;
|
||||||
|
@ -44,35 +44,35 @@ int32_t dnodeInitShell() {
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_UPDATE_TAG_VAL] = dnodeDispatchToVWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_UPDATE_TAG_VAL] = dnodeDispatchToVWriteQueue;
|
||||||
|
|
||||||
// the following message shall be treated as mnode write
|
// the following message shall be treated as mnode write
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_ACCT] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_ACCT] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_ACCT] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_ACCT] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_ACCT] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_ACCT] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_USER] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_USER] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_USER] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_USER] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_USER] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_USER] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_DNODE]= dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_DNODE]= dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_DNODE] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_DNODE] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_DB] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_DB] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_DB] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_DB] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_DB] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_DB] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_TABLE]= dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CREATE_TABLE]= dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_TABLE] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_DROP_TABLE] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_TABLE] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_TABLE] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_STREAM]= dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_ALTER_STREAM]= dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_KILL_QUERY] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_KILL_QUERY] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_KILL_STREAM] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_KILL_STREAM] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_KILL_CONN] = dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_KILL_CONN] = dnodeDispatchToMWriteQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CONFIG_DNODE]= dnodeDispatchToMnodeWriteQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CONFIG_DNODE]= dnodeDispatchToMWriteQueue;
|
||||||
|
|
||||||
// the following message shall be treated as mnode query
|
// the following message shall be treated as mnode query
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_HEARTBEAT] = dnodeDispatchToMnodeReadQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_HEARTBEAT] = dnodeDispatchToMReadQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CONNECT] = dnodeDispatchToMnodeReadQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_CONNECT] = dnodeDispatchToMReadQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_USE_DB] = dnodeDispatchToMnodeReadQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_USE_DB] = dnodeDispatchToMReadQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_TABLE_META] = dnodeDispatchToMnodeReadQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_TABLE_META] = dnodeDispatchToMReadQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_STABLE_VGROUP]= dnodeDispatchToMnodeReadQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_STABLE_VGROUP]= dnodeDispatchToMReadQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_TABLES_META] = dnodeDispatchToMnodeReadQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_TABLES_META] = dnodeDispatchToMReadQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_SHOW] = dnodeDispatchToMnodeReadQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_SHOW] = dnodeDispatchToMReadQueue;
|
||||||
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_RETRIEVE] = dnodeDispatchToMnodeReadQueue;
|
dnodeProcessShellMsgFp[TSDB_MSG_TYPE_CM_RETRIEVE] = dnodeDispatchToMReadQueue;
|
||||||
|
|
||||||
int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore;
|
int32_t numOfThreads = tsNumOfCores * tsNumOfThreadsPerCore;
|
||||||
numOfThreads = (int32_t) ((1.0 - tsRatioOfQueryThreads) * numOfThreads / 2.0);
|
numOfThreads = (int32_t) ((1.0 - tsRatioOfQueryThreads) * numOfThreads / 2.0);
|
||||||
|
@ -91,8 +91,8 @@ int32_t dnodeInitShell() {
|
||||||
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
rpcInit.idleTime = tsShellActivityTimer * 1000;
|
||||||
rpcInit.afp = dnodeRetrieveUserAuthInfo;
|
rpcInit.afp = dnodeRetrieveUserAuthInfo;
|
||||||
|
|
||||||
tsDnodeShellRpc = rpcOpen(&rpcInit);
|
tsShellRpc = rpcOpen(&rpcInit);
|
||||||
if (tsDnodeShellRpc == NULL) {
|
if (tsShellRpc == NULL) {
|
||||||
dError("failed to init shell rpc server");
|
dError("failed to init shell rpc server");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -102,13 +102,13 @@ int32_t dnodeInitShell() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeCleanupShell() {
|
void dnodeCleanupShell() {
|
||||||
if (tsDnodeShellRpc) {
|
if (tsShellRpc) {
|
||||||
rpcClose(tsDnodeShellRpc);
|
rpcClose(tsShellRpc);
|
||||||
tsDnodeShellRpc = NULL;
|
tsShellRpc = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
|
static void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
|
||||||
SRpcMsg rpcMsg = {
|
SRpcMsg rpcMsg = {
|
||||||
.handle = pMsg->handle,
|
.handle = pMsg->handle,
|
||||||
.pCont = NULL,
|
.pCont = NULL,
|
||||||
|
@ -117,7 +117,7 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
|
||||||
|
|
||||||
if (pMsg->pCont == NULL) return;
|
if (pMsg->pCont == NULL) return;
|
||||||
|
|
||||||
if (dnodeGetRunStatus() != TSDB_DNODE_RUN_STATUS_RUNING) {
|
if (dnodeGetRunStatus() != TSDB_RUN_STATUS_RUNING) {
|
||||||
dError("RPC %p, shell msg:%s is ignored since dnode not running", pMsg->handle, taosMsg[pMsg->msgType]);
|
dError("RPC %p, shell msg:%s is ignored since dnode not running", pMsg->handle, taosMsg[pMsg->msgType]);
|
||||||
rpcMsg.code = TSDB_CODE_APP_NOT_READY;
|
rpcMsg.code = TSDB_CODE_APP_NOT_READY;
|
||||||
rpcSendResponse(&rpcMsg);
|
rpcSendResponse(&rpcMsg);
|
||||||
|
@ -126,9 +126,9 @@ void dnodeProcessMsgFromShell(SRpcMsg *pMsg, SRpcEpSet *pEpSet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMsg->msgType == TSDB_MSG_TYPE_QUERY) {
|
if (pMsg->msgType == TSDB_MSG_TYPE_QUERY) {
|
||||||
atomic_fetch_add_32(&tsDnodeQueryReqNum, 1);
|
atomic_fetch_add_32(&tsQueryReqNum, 1);
|
||||||
} else if (pMsg->msgType == TSDB_MSG_TYPE_SUBMIT) {
|
} else if (pMsg->msgType == TSDB_MSG_TYPE_SUBMIT) {
|
||||||
atomic_fetch_add_32(&tsDnodeSubmitReqNum, 1);
|
atomic_fetch_add_32(&tsSubmitReqNum, 1);
|
||||||
} else {}
|
} else {}
|
||||||
|
|
||||||
if ( dnodeProcessShellMsgFp[pMsg->msgType] ) {
|
if ( dnodeProcessShellMsgFp[pMsg->msgType] ) {
|
||||||
|
@ -211,12 +211,12 @@ void *dnodeSendCfgTableToRecv(int32_t vgId, int32_t tid) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDnodeStatisInfo dnodeGetStatisInfo() {
|
SStatisInfo dnodeGetStatisInfo() {
|
||||||
SDnodeStatisInfo info = {0};
|
SStatisInfo info = {0};
|
||||||
if (dnodeGetRunStatus() == TSDB_DNODE_RUN_STATUS_RUNING) {
|
if (dnodeGetRunStatus() == TSDB_RUN_STATUS_RUNING) {
|
||||||
info.httpReqNum = httpGetReqCount();
|
info.httpReqNum = httpGetReqCount();
|
||||||
info.queryReqNum = atomic_exchange_32(&tsDnodeQueryReqNum, 0);
|
info.queryReqNum = atomic_exchange_32(&tsQueryReqNum, 0);
|
||||||
info.submitReqNum = atomic_exchange_32(&tsDnodeSubmitReqNum, 0);
|
info.submitReqNum = atomic_exchange_32(&tsSubmitReqNum, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
|
|
|
@ -92,33 +92,23 @@ void dnodeDispatchToVReadQueue(SRpcMsg *pMsg) {
|
||||||
pHead->vgId = htonl(pHead->vgId);
|
pHead->vgId = htonl(pHead->vgId);
|
||||||
pHead->contLen = htonl(pHead->contLen);
|
pHead->contLen = htonl(pHead->contLen);
|
||||||
|
|
||||||
taos_queue queue = vnodeAcquireRqueue(pHead->vgId);
|
void *pVnode = vnodeAcquire(pHead->vgId);
|
||||||
|
if (pVnode != NULL) {
|
||||||
if (queue == NULL) {
|
int32_t code = vnodeWriteToRQueue(pVnode, pCont, pHead->contLen, TAOS_QTYPE_RPC, pMsg);
|
||||||
leftLen -= pHead->contLen;
|
if (code == TSDB_CODE_SUCCESS) queuedMsgNum++;
|
||||||
pCont -= pHead->contLen;
|
vnodeRelease(pVnode);
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// put message into queue
|
|
||||||
SVReadMsg *pRead = taosAllocateQitem(sizeof(SVReadMsg));
|
|
||||||
pRead->rpcMsg = *pMsg;
|
|
||||||
pRead->pCont = pCont;
|
|
||||||
pRead->contLen = pHead->contLen;
|
|
||||||
|
|
||||||
// next vnode
|
|
||||||
leftLen -= pHead->contLen;
|
leftLen -= pHead->contLen;
|
||||||
pCont -= pHead->contLen;
|
pCont -= pHead->contLen;
|
||||||
queuedMsgNum++;
|
|
||||||
|
|
||||||
taosWriteQitem(queue, TAOS_QTYPE_RPC, pRead);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queuedMsgNum == 0) {
|
if (queuedMsgNum == 0) {
|
||||||
SRpcMsg rpcRsp = {.handle = pMsg->handle, .code = TSDB_CODE_VND_INVALID_VGROUP_ID};
|
SRpcMsg rpcRsp = {.handle = pMsg->handle, .code = TSDB_CODE_VND_INVALID_VGROUP_ID};
|
||||||
rpcSendResponse(&rpcRsp);
|
rpcSendResponse(&rpcRsp);
|
||||||
rpcFreeCont(pMsg->pCont);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *dnodeAllocVReadQueue(void *pVnode) {
|
void *dnodeAllocVReadQueue(void *pVnode) {
|
||||||
|
@ -162,50 +152,48 @@ void dnodeFreeVReadQueue(void *rqueue) {
|
||||||
|
|
||||||
void dnodeSendRpcVReadRsp(void *pVnode, SVReadMsg *pRead, int32_t code) {
|
void dnodeSendRpcVReadRsp(void *pVnode, SVReadMsg *pRead, int32_t code) {
|
||||||
SRpcMsg rpcRsp = {
|
SRpcMsg rpcRsp = {
|
||||||
.handle = pRead->rpcMsg.handle,
|
.handle = pRead->rpcHandle,
|
||||||
.pCont = pRead->rspRet.rsp,
|
.pCont = pRead->rspRet.rsp,
|
||||||
.contLen = pRead->rspRet.len,
|
.contLen = pRead->rspRet.len,
|
||||||
.code = code,
|
.code = code,
|
||||||
};
|
};
|
||||||
|
|
||||||
rpcSendResponse(&rpcRsp);
|
rpcSendResponse(&rpcRsp);
|
||||||
rpcFreeCont(pRead->rpcMsg.pCont);
|
|
||||||
vnodeRelease(pVnode);
|
vnodeRelease(pVnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dnodeDispatchNonRspMsg(void *pVnode, SVReadMsg *pRead, int32_t code) {
|
void dnodeDispatchNonRspMsg(void *pVnode, SVReadMsg *pRead, int32_t code) {
|
||||||
rpcFreeCont(pRead->rpcMsg.pCont);
|
|
||||||
vnodeRelease(pVnode);
|
vnodeRelease(pVnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *dnodeProcessReadQueue(void *param) {
|
static void *dnodeProcessReadQueue(void *param) {
|
||||||
SVReadMsg *pReadMsg;
|
SVReadMsg *pRead;
|
||||||
int32_t qtype;
|
int32_t qtype;
|
||||||
void * pVnode;
|
void * pVnode;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (taosReadQitemFromQset(tsVReadQset, &qtype, (void **)&pReadMsg, &pVnode) == 0) {
|
if (taosReadQitemFromQset(tsVReadQset, &qtype, (void **)&pRead, &pVnode) == 0) {
|
||||||
dDebug("qset:%p dnode vread got no message from qset, exiting", tsVReadQset);
|
dDebug("qset:%p dnode vread got no message from qset, exiting", tsVReadQset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dDebug("%p, msg:%s will be processed in vread queue, qtype:%d, msg:%p", pReadMsg->rpcMsg.ahandle,
|
dDebug("%p, msg:%p:%s will be processed in vread queue, qtype:%d", pRead->rpcAhandle, pRead,
|
||||||
taosMsg[pReadMsg->rpcMsg.msgType], qtype, pReadMsg);
|
taosMsg[pRead->msgType], qtype);
|
||||||
|
|
||||||
int32_t code = vnodeProcessRead(pVnode, pReadMsg);
|
int32_t code = vnodeProcessRead(pVnode, pRead);
|
||||||
|
|
||||||
if (qtype == TAOS_QTYPE_RPC && code != TSDB_CODE_QRY_NOT_READY) {
|
if (qtype == TAOS_QTYPE_RPC && code != TSDB_CODE_QRY_NOT_READY) {
|
||||||
dnodeSendRpcVReadRsp(pVnode, pReadMsg, code);
|
dnodeSendRpcVReadRsp(pVnode, pRead, code);
|
||||||
} else {
|
} else {
|
||||||
if (code == TSDB_CODE_QRY_HAS_RSP) {
|
if (code == TSDB_CODE_QRY_HAS_RSP) {
|
||||||
dnodeSendRpcVReadRsp(pVnode, pReadMsg, pReadMsg->rpcMsg.code);
|
dnodeSendRpcVReadRsp(pVnode, pRead, pRead->code);
|
||||||
} else { // code == TSDB_CODE_QRY_NOT_READY, do not return msg to client
|
} else { // code == TSDB_CODE_QRY_NOT_READY, do not return msg to client
|
||||||
assert(pReadMsg->rpcMsg.handle == NULL || (pReadMsg->rpcMsg.handle != NULL && pReadMsg->rpcMsg.msgType == 5));
|
assert(pRead->rpcHandle == NULL || (pRead->rpcHandle != NULL && pRead->msgType == 5));
|
||||||
dnodeDispatchNonRspMsg(pVnode, pReadMsg, code);
|
dnodeDispatchNonRspMsg(pVnode, pRead, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosFreeQitem(pReadMsg);
|
taosFreeQitem(pRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -113,7 +113,7 @@ void dnodeDispatchToVWriteQueue(SRpcMsg *pRpcMsg) {
|
||||||
void *dnodeAllocVWriteQueue(void *pVnode) {
|
void *dnodeAllocVWriteQueue(void *pVnode) {
|
||||||
pthread_mutex_lock(&tsVWriteWP.mutex);
|
pthread_mutex_lock(&tsVWriteWP.mutex);
|
||||||
SVWriteWorker *pWorker = tsVWriteWP.worker + tsVWriteWP.nextId;
|
SVWriteWorker *pWorker = tsVWriteWP.worker + tsVWriteWP.nextId;
|
||||||
void *queue = taosOpenQueue();
|
taos_queue *queue = taosOpenQueue();
|
||||||
if (queue == NULL) {
|
if (queue == NULL) {
|
||||||
pthread_mutex_unlock(&tsVWriteWP.mutex);
|
pthread_mutex_unlock(&tsVWriteWP.mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -207,8 +207,8 @@ static void *dnodeProcessVWriteQueue(void *param) {
|
||||||
bool forceFsync = false;
|
bool forceFsync = false;
|
||||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||||
taosGetQitem(pWorker->qall, &qtype, (void **)&pWrite);
|
taosGetQitem(pWorker->qall, &qtype, (void **)&pWrite);
|
||||||
dTrace("%p, msg:%p:%s will be processed in vwrite queue, qtype:%d version:%" PRIu64, pWrite->rpcAhandle, pWrite,
|
dTrace("%p, msg:%p:%s will be processed in vwrite queue, qtype:%s hver:%" PRIu64, pWrite->rpcAhandle, pWrite,
|
||||||
taosMsg[pWrite->pHead->msgType], qtype, pWrite->pHead->version);
|
taosMsg[pWrite->pHead->msgType], qtypeStr[qtype], pWrite->pHead->version);
|
||||||
|
|
||||||
pWrite->code = vnodeProcessWrite(pVnode, pWrite->pHead, qtype, &pWrite->rspRet);
|
pWrite->code = vnodeProcessWrite(pVnode, pWrite->pHead, qtype, &pWrite->rspRet);
|
||||||
if (pWrite->code <= 0) pWrite->processedCount = 1;
|
if (pWrite->code <= 0) pWrite->processedCount = 1;
|
||||||
|
|
|
@ -27,16 +27,16 @@ typedef struct {
|
||||||
int32_t queryReqNum;
|
int32_t queryReqNum;
|
||||||
int32_t submitReqNum;
|
int32_t submitReqNum;
|
||||||
int32_t httpReqNum;
|
int32_t httpReqNum;
|
||||||
} SDnodeStatisInfo;
|
} SStatisInfo;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_DNODE_RUN_STATUS_INITIALIZE,
|
TSDB_RUN_STATUS_INITIALIZE,
|
||||||
TSDB_DNODE_RUN_STATUS_RUNING,
|
TSDB_RUN_STATUS_RUNING,
|
||||||
TSDB_DNODE_RUN_STATUS_STOPPED
|
TSDB_RUN_STATUS_STOPPED
|
||||||
} SDnodeRunStatus;
|
} SRunStatus;
|
||||||
|
|
||||||
SDnodeRunStatus dnodeGetRunStatus();
|
SRunStatus dnodeGetRunStatus();
|
||||||
SDnodeStatisInfo dnodeGetStatisInfo();
|
SStatisInfo dnodeGetStatisInfo();
|
||||||
|
|
||||||
bool dnodeIsFirstDeploy();
|
bool dnodeIsFirstDeploy();
|
||||||
bool dnodeIsMasterEp(char *ep);
|
bool dnodeIsMasterEp(char *ep);
|
||||||
|
@ -59,15 +59,15 @@ void dnodeSendRpcVWriteRsp(void *pVnode, void *param, int32_t code);
|
||||||
void *dnodeAllocVReadQueue(void *pVnode);
|
void *dnodeAllocVReadQueue(void *pVnode);
|
||||||
void dnodeFreeVReadQueue(void *rqueue);
|
void dnodeFreeVReadQueue(void *rqueue);
|
||||||
|
|
||||||
int32_t dnodeAllocateMnodePqueue();
|
int32_t dnodeAllocateMPeerQueue();
|
||||||
void dnodeFreeMnodePqueue();
|
void dnodeFreeMPeerQueue();
|
||||||
int32_t dnodeAllocateMnodeRqueue();
|
int32_t dnodeAllocMReadQueue();
|
||||||
void dnodeFreeMnodeRqueue();
|
void dnodeFreeMReadQueue();
|
||||||
int32_t dnodeAllocateMnodeWqueue();
|
int32_t dnodeAllocMWritequeue();
|
||||||
void dnodeFreeMnodeWqueue();
|
void dnodeFreeMWritequeue();
|
||||||
void dnodeSendRpcMnodeWriteRsp(void *pMsg, int32_t code);
|
void dnodeSendRpcMWriteRsp(void *pMsg, int32_t code);
|
||||||
void dnodeReprocessMnodeWriteMsg(void *pMsg);
|
void dnodeReprocessMWriteMsg(void *pMsg);
|
||||||
void dnodeDelayReprocessMnodeWriteMsg(void *pMsg);
|
void dnodeDelayReprocessMWriteMsg(void *pMsg);
|
||||||
|
|
||||||
void dnodeSendStatusMsgToMnode();
|
void dnodeSendStatusMsgToMnode();
|
||||||
|
|
||||||
|
|
|
@ -35,24 +35,26 @@ typedef struct {
|
||||||
} SMnodeRsp;
|
} SMnodeRsp;
|
||||||
|
|
||||||
typedef struct SMnodeMsg {
|
typedef struct SMnodeMsg {
|
||||||
SRpcMsg rpcMsg;
|
|
||||||
SMnodeRsp rpcRsp;
|
|
||||||
int8_t received;
|
|
||||||
int8_t successed;
|
|
||||||
int8_t expected;
|
|
||||||
int8_t retry;
|
|
||||||
int32_t code;
|
|
||||||
void * pObj;
|
|
||||||
struct SAcctObj * pAcct;
|
struct SAcctObj * pAcct;
|
||||||
struct SDnodeObj *pDnode;
|
struct SDnodeObj *pDnode;
|
||||||
struct SUserObj * pUser;
|
struct SUserObj * pUser;
|
||||||
struct SDbObj * pDb;
|
struct SDbObj * pDb;
|
||||||
struct SVgObj * pVgroup;
|
struct SVgObj * pVgroup;
|
||||||
struct STableObj *pTable;
|
struct STableObj *pTable;
|
||||||
struct SSuperTableObj *pSTable;
|
struct SSTableObj*pSTable;
|
||||||
|
SMnodeRsp rpcRsp;
|
||||||
|
int8_t received;
|
||||||
|
int8_t successed;
|
||||||
|
int8_t expected;
|
||||||
|
int8_t retry;
|
||||||
|
int32_t incomingTs;
|
||||||
|
int32_t code;
|
||||||
|
void * pObj;
|
||||||
|
SRpcMsg rpcMsg;
|
||||||
|
char pCont[];
|
||||||
} SMnodeMsg;
|
} SMnodeMsg;
|
||||||
|
|
||||||
void mnodeCreateMsg(SMnodeMsg *pMsg, SRpcMsg *rpcMsg);
|
void * mnodeCreateMsg(SRpcMsg *pRpcMsg);
|
||||||
int32_t mnodeInitMsg(SMnodeMsg *pMsg);
|
int32_t mnodeInitMsg(SMnodeMsg *pMsg);
|
||||||
void mnodeCleanupMsg(SMnodeMsg *pMsg);
|
void mnodeCleanupMsg(SMnodeMsg *pMsg);
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ extern const int32_t TYPE_BYTES[11];
|
||||||
#define TSDB_DATA_SMALLINT_NULL 0x8000
|
#define TSDB_DATA_SMALLINT_NULL 0x8000
|
||||||
#define TSDB_DATA_INT_NULL 0x80000000L
|
#define TSDB_DATA_INT_NULL 0x80000000L
|
||||||
#define TSDB_DATA_BIGINT_NULL 0x8000000000000000L
|
#define TSDB_DATA_BIGINT_NULL 0x8000000000000000L
|
||||||
|
#define TSDB_DATA_TIMESTAMP_NULL TSDB_DATA_BIGINT_NULL
|
||||||
|
|
||||||
#define TSDB_DATA_FLOAT_NULL 0x7FF00000 // it is an NAN
|
#define TSDB_DATA_FLOAT_NULL 0x7FF00000 // it is an NAN
|
||||||
#define TSDB_DATA_DOUBLE_NULL 0x7FFFFF0000000000L // an NAN
|
#define TSDB_DATA_DOUBLE_NULL 0x7FFFFF0000000000L // an NAN
|
||||||
|
@ -361,6 +362,10 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf
|
||||||
#define TSDB_MAX_WAL_LEVEL 2
|
#define TSDB_MAX_WAL_LEVEL 2
|
||||||
#define TSDB_DEFAULT_WAL_LEVEL 1
|
#define TSDB_DEFAULT_WAL_LEVEL 1
|
||||||
|
|
||||||
|
#define TSDB_MIN_DB_UPDATE 0
|
||||||
|
#define TSDB_MAX_DB_UPDATE 1
|
||||||
|
#define TSDB_DEFAULT_DB_UPDATE_OPTION 0
|
||||||
|
|
||||||
#define TSDB_MIN_FSYNC_PERIOD 0
|
#define TSDB_MIN_FSYNC_PERIOD 0
|
||||||
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
|
#define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond
|
||||||
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
|
#define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second
|
||||||
|
@ -418,17 +423,26 @@ void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void* buf
|
||||||
#define TSDB_DEFAULT_STABLES_HASH_SIZE 100
|
#define TSDB_DEFAULT_STABLES_HASH_SIZE 100
|
||||||
#define TSDB_DEFAULT_CTABLES_HASH_SIZE 20000
|
#define TSDB_DEFAULT_CTABLES_HASH_SIZE 20000
|
||||||
|
|
||||||
|
#define TSDB_PORT_DNODESHELL 0
|
||||||
|
#define TSDB_PORT_DNODEDNODE 5
|
||||||
|
#define TSDB_PORT_SYNC 10
|
||||||
|
#define TSDB_PORT_HTTP 11
|
||||||
|
#define TSDB_PORT_ARBITRATOR 12
|
||||||
#define TSDB_PORT_DNODESHELL 0
|
#define TSDB_PORT_DNODESHELL 0
|
||||||
#define TSDB_PORT_DNODEDNODE 5
|
#define TSDB_PORT_DNODEDNODE 5
|
||||||
#define TSDB_PORT_SYNC 10
|
#define TSDB_PORT_SYNC 10
|
||||||
#define TSDB_PORT_HTTP 11
|
#define TSDB_PORT_HTTP 11
|
||||||
#define TSDB_PORT_ARBITRATOR 12
|
#define TSDB_PORT_ARBITRATOR 12
|
||||||
|
|
||||||
#define TAOS_QTYPE_RPC 0
|
#define TSDB_MAX_WAL_SIZE (1024*1024)
|
||||||
#define TAOS_QTYPE_FWD 1
|
|
||||||
#define TAOS_QTYPE_WAL 2
|
typedef enum {
|
||||||
#define TAOS_QTYPE_CQ 3
|
TAOS_QTYPE_RPC = 0,
|
||||||
#define TAOS_QTYPE_QUERY 4
|
TAOS_QTYPE_FWD = 1,
|
||||||
|
TAOS_QTYPE_WAL = 2,
|
||||||
|
TAOS_QTYPE_CQ = 3,
|
||||||
|
TAOS_QTYPE_QUERY = 4
|
||||||
|
} EQType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_SUPER_TABLE = 0, // super table
|
TSDB_SUPER_TABLE = 0, // super table
|
||||||
|
@ -439,14 +453,14 @@ typedef enum {
|
||||||
} ETableType;
|
} ETableType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_MOD_MNODE,
|
TSDB_MOD_MNODE = 0,
|
||||||
TSDB_MOD_HTTP,
|
TSDB_MOD_HTTP = 1,
|
||||||
TSDB_MOD_MONITOR,
|
TSDB_MOD_MONITOR = 2,
|
||||||
TSDB_MOD_MQTT,
|
TSDB_MOD_MQTT = 3,
|
||||||
TSDB_MOD_MAX
|
TSDB_MOD_MAX = 4
|
||||||
} EModuleType;
|
} EModuleType;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_CHECK_ITEM_NETWORK,
|
TSDB_CHECK_ITEM_NETWORK,
|
||||||
TSDB_CHECK_ITEM_MEM,
|
TSDB_CHECK_ITEM_MEM,
|
||||||
TSDB_CHECK_ITEM_CPU,
|
TSDB_CHECK_ITEM_CPU,
|
||||||
|
@ -456,8 +470,9 @@ typedef enum {
|
||||||
TSDB_CHECK_ITEM_VERSION,
|
TSDB_CHECK_ITEM_VERSION,
|
||||||
TSDB_CHECK_ITEM_DATAFILE,
|
TSDB_CHECK_ITEM_DATAFILE,
|
||||||
TSDB_CHECK_ITEM_MAX
|
TSDB_CHECK_ITEM_MAX
|
||||||
} ECheckItemType;
|
} ECheckItemType;
|
||||||
|
|
||||||
|
extern char *qtypeStr[];
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,6 +181,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DB, 0, 0x0383, "Invalid da
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_MONITOR_DB_FORBIDDEN, 0, 0x0384, "Cannot delete monitor database")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_MONITOR_DB_FORBIDDEN, 0, 0x0384, "Cannot delete monitor database")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_DATABASES, 0, 0x0385, "Too many databases for account")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_DATABASES, 0, 0x0385, "Too many databases for account")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_IN_DROPPING, 0, 0x0386, "Database not available")
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_DB_IN_DROPPING, 0, 0x0386, "Database not available")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_MND_VGROUP_NOT_READY, 0, 0x0387, "Database unsynced")
|
||||||
|
|
||||||
// dnode
|
// dnode
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_DND_MSG_NOT_PROCESSED, 0, 0x0400, "Message not processed")
|
TAOS_DEFINE_ERROR(TSDB_CODE_DND_MSG_NOT_PROCESSED, 0, 0x0400, "Message not processed")
|
||||||
|
@ -260,6 +261,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_SYN_INVALID_VERSION, 0, 0x0902, "Invalid Sy
|
||||||
// wal
|
// wal
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_WAL_APP_ERROR, 0, 0x1000, "Unexpected generic error in wal")
|
TAOS_DEFINE_ERROR(TSDB_CODE_WAL_APP_ERROR, 0, 0x1000, "Unexpected generic error in wal")
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_WAL_FILE_CORRUPTED, 0, 0x1001, "WAL file is corrupted")
|
TAOS_DEFINE_ERROR(TSDB_CODE_WAL_FILE_CORRUPTED, 0, 0x1001, "WAL file is corrupted")
|
||||||
|
TAOS_DEFINE_ERROR(TSDB_CODE_WAL_SIZE_LIMIT, 0, 0x1002, "WAL size exceeds limit")
|
||||||
|
|
||||||
// http
|
// http
|
||||||
TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_SERVER_OFFLINE, 0, 0x1100, "http server is not onlin")
|
TAOS_DEFINE_ERROR(TSDB_CODE_HTTP_SERVER_OFFLINE, 0, 0x1100, "http server is not onlin")
|
||||||
|
|
|
@ -544,6 +544,8 @@ typedef struct {
|
||||||
int8_t replications;
|
int8_t replications;
|
||||||
int8_t quorum;
|
int8_t quorum;
|
||||||
int8_t ignoreExist;
|
int8_t ignoreExist;
|
||||||
|
int8_t update;
|
||||||
|
int8_t reserve[9];
|
||||||
} SCreateDbMsg, SAlterDbMsg;
|
} SCreateDbMsg, SAlterDbMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -654,7 +656,8 @@ typedef struct {
|
||||||
int8_t replications;
|
int8_t replications;
|
||||||
int8_t wals;
|
int8_t wals;
|
||||||
int8_t quorum;
|
int8_t quorum;
|
||||||
int8_t reserved[16];
|
int8_t update;
|
||||||
|
int8_t reserved[15];
|
||||||
} SVnodeCfg;
|
} SVnodeCfg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
@ -24,7 +24,7 @@ extern "C" {
|
||||||
typedef int32_t (*FCqWrite)(void *ahandle, void *pHead, int32_t qtype, void *pMsg);
|
typedef int32_t (*FCqWrite)(void *ahandle, void *pHead, int32_t qtype, void *pMsg);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int vgId;
|
int32_t vgId;
|
||||||
char user[TSDB_USER_LEN];
|
char user[TSDB_USER_LEN];
|
||||||
char pass[TSDB_PASSWORD_LEN];
|
char pass[TSDB_PASSWORD_LEN];
|
||||||
char db[TSDB_DB_NAME_LEN];
|
char db[TSDB_DB_NAME_LEN];
|
||||||
|
@ -42,12 +42,12 @@ void cqStart(void *handle);
|
||||||
void cqStop(void *handle);
|
void cqStop(void *handle);
|
||||||
|
|
||||||
// cqCreate is called by TSDB to start an instance of CQ
|
// cqCreate is called by TSDB to start an instance of CQ
|
||||||
void *cqCreate(void *handle, uint64_t uid, int sid, char *sqlStr, STSchema *pSchema);
|
void *cqCreate(void *handle, uint64_t uid, int32_t sid, char *sqlStr, STSchema *pSchema);
|
||||||
|
|
||||||
// cqDrop is called by TSDB to stop an instance of CQ, handle is the return value of cqCreate
|
// cqDrop is called by TSDB to stop an instance of CQ, handle is the return value of cqCreate
|
||||||
void cqDrop(void *handle);
|
void cqDrop(void *handle);
|
||||||
|
|
||||||
extern int cqDebugFlag;
|
extern int32_t cqDebugFlag;
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -83,13 +83,13 @@ void rpcClose(void *);
|
||||||
void *rpcMallocCont(int contLen);
|
void *rpcMallocCont(int contLen);
|
||||||
void rpcFreeCont(void *pCont);
|
void rpcFreeCont(void *pCont);
|
||||||
void *rpcReallocCont(void *ptr, int contLen);
|
void *rpcReallocCont(void *ptr, int contLen);
|
||||||
void rpcSendRequest(void *thandle, const SRpcEpSet *pEpSet, SRpcMsg *pMsg);
|
int64_t rpcSendRequest(void *thandle, const SRpcEpSet *pEpSet, SRpcMsg *pMsg);
|
||||||
void rpcSendResponse(const SRpcMsg *pMsg);
|
void rpcSendResponse(const SRpcMsg *pMsg);
|
||||||
void rpcSendRedirectRsp(void *pConn, const SRpcEpSet *pEpSet);
|
void rpcSendRedirectRsp(void *pConn, const SRpcEpSet *pEpSet);
|
||||||
int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo);
|
int rpcGetConnInfo(void *thandle, SRpcConnInfo *pInfo);
|
||||||
void rpcSendRecv(void *shandle, SRpcEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
void rpcSendRecv(void *shandle, SRpcEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp);
|
||||||
int rpcReportProgress(void *pConn, char *pCont, int contLen);
|
int rpcReportProgress(void *pConn, char *pCont, int contLen);
|
||||||
void rpcCancelRequest(void *pContext);
|
void rpcCancelRequest(int64_t rid);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,6 +65,7 @@ typedef struct {
|
||||||
int32_t maxRowsPerFileBlock; // maximum rows per file block
|
int32_t maxRowsPerFileBlock; // maximum rows per file block
|
||||||
int8_t precision;
|
int8_t precision;
|
||||||
int8_t compression;
|
int8_t compression;
|
||||||
|
int8_t update;
|
||||||
} STsdbCfg;
|
} STsdbCfg;
|
||||||
|
|
||||||
// --------- TSDB REPOSITORY USAGE STATISTICS
|
// --------- TSDB REPOSITORY USAGE STATISTICS
|
||||||
|
|
|
@ -51,9 +51,9 @@ typedef struct {
|
||||||
} SSyncCfg;
|
} SSyncCfg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int selfIndex;
|
int32_t selfIndex;
|
||||||
uint32_t nodeId[TAOS_SYNC_MAX_REPLICA];
|
uint32_t nodeId[TAOS_SYNC_MAX_REPLICA];
|
||||||
int role[TAOS_SYNC_MAX_REPLICA];
|
int32_t role[TAOS_SYNC_MAX_REPLICA];
|
||||||
} SNodesRole;
|
} SNodesRole;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -83,15 +83,14 @@ typedef void (*FNotifyRole)(void *ahandle, int8_t role);
|
||||||
typedef void (*FNotifyFlowCtrl)(void *ahandle, int32_t mseconds);
|
typedef void (*FNotifyFlowCtrl)(void *ahandle, int32_t mseconds);
|
||||||
|
|
||||||
// when data file is synced successfully, notity app
|
// when data file is synced successfully, notity app
|
||||||
typedef int (*FNotifyFileSynced)(void *ahandle, uint64_t fversion);
|
typedef int32_t (*FNotifyFileSynced)(void *ahandle, uint64_t fversion);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vgId; // vgroup ID
|
int32_t vgId; // vgroup ID
|
||||||
uint64_t version; // initial version
|
uint64_t version; // initial version
|
||||||
SSyncCfg syncCfg; // configuration from mgmt
|
SSyncCfg syncCfg; // configuration from mgmt
|
||||||
char path[128]; // path to the file
|
char path[128]; // path to the file
|
||||||
|
void * ahandle; // handle provided by APP
|
||||||
void *ahandle; // handle provided by APP
|
|
||||||
FGetFileInfo getFileInfo;
|
FGetFileInfo getFileInfo;
|
||||||
FGetWalInfo getWalInfo;
|
FGetWalInfo getWalInfo;
|
||||||
FWriteToCache writeToCache;
|
FWriteToCache writeToCache;
|
||||||
|
@ -101,28 +100,28 @@ typedef struct {
|
||||||
FNotifyFileSynced notifyFileSynced;
|
FNotifyFileSynced notifyFileSynced;
|
||||||
} SSyncInfo;
|
} SSyncInfo;
|
||||||
|
|
||||||
typedef void* tsync_h;
|
typedef void *tsync_h;
|
||||||
|
|
||||||
int32_t syncInit();
|
int32_t syncInit();
|
||||||
void syncCleanUp();
|
void syncCleanUp();
|
||||||
|
|
||||||
tsync_h syncStart(const SSyncInfo *);
|
int64_t syncStart(const SSyncInfo *);
|
||||||
void syncStop(tsync_h shandle);
|
void syncStop(int64_t rid);
|
||||||
int32_t syncReconfig(tsync_h shandle, const SSyncCfg *);
|
int32_t syncReconfig(int64_t rid, const SSyncCfg *);
|
||||||
int32_t syncForwardToPeer(tsync_h shandle, void *pHead, void *mhandle, int qtype);
|
int32_t syncForwardToPeer(int64_t rid, void *pHead, void *mhandle, int32_t qtype);
|
||||||
void syncConfirmForward(tsync_h shandle, uint64_t version, int32_t code);
|
void syncConfirmForward(int64_t rid, uint64_t version, int32_t code);
|
||||||
void syncRecover(tsync_h shandle); // recover from other nodes:
|
void syncRecover(int64_t rid); // recover from other nodes:
|
||||||
int syncGetNodesRole(tsync_h shandle, SNodesRole *);
|
int32_t syncGetNodesRole(int64_t rid, SNodesRole *);
|
||||||
|
|
||||||
extern char *syncRole[];
|
extern char *syncRole[];
|
||||||
|
|
||||||
//global configurable parameters
|
//global configurable parameters
|
||||||
extern int tsMaxSyncNum;
|
extern int32_t tsMaxSyncNum;
|
||||||
extern int tsSyncTcpThreads;
|
extern int32_t tsSyncTcpThreads;
|
||||||
extern int tsMaxWatchFiles;
|
extern int32_t tsMaxWatchFiles;
|
||||||
extern int tsSyncTimer;
|
extern int32_t tsSyncTimer;
|
||||||
extern int tsMaxFwdInfo;
|
extern int32_t tsMaxFwdInfo;
|
||||||
extern int sDebugFlag;
|
extern int32_t sDebugFlag;
|
||||||
extern char tsArbitrator[];
|
extern char tsArbitrator[];
|
||||||
extern uint16_t tsSyncPort;
|
extern uint16_t tsSyncPort;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#ifndef TDENGINE_TTOKENDEF_H
|
#ifndef TDENGINE_TTOKENDEF_H
|
||||||
#define TDENGINE_TTOKENDEF_H
|
#define TDENGINE_TTOKENDEF_H
|
||||||
|
|
||||||
|
|
||||||
#define TK_ID 1
|
#define TK_ID 1
|
||||||
#define TK_BOOL 2
|
#define TK_BOOL 2
|
||||||
#define TK_TINYINT 3
|
#define TK_TINYINT 3
|
||||||
|
@ -114,114 +113,116 @@
|
||||||
#define TK_FSYNC 95
|
#define TK_FSYNC 95
|
||||||
#define TK_COMP 96
|
#define TK_COMP 96
|
||||||
#define TK_PRECISION 97
|
#define TK_PRECISION 97
|
||||||
#define TK_LP 98
|
#define TK_UPDATE 98
|
||||||
#define TK_RP 99
|
#define TK_LP 99
|
||||||
#define TK_TAGS 100
|
#define TK_RP 100
|
||||||
#define TK_USING 101
|
#define TK_TAGS 101
|
||||||
#define TK_AS 102
|
#define TK_USING 102
|
||||||
#define TK_COMMA 103
|
#define TK_AS 103
|
||||||
#define TK_NULL 104
|
#define TK_COMMA 104
|
||||||
#define TK_SELECT 105
|
#define TK_NULL 105
|
||||||
#define TK_UNION 106
|
#define TK_SELECT 106
|
||||||
#define TK_ALL 107
|
#define TK_UNION 107
|
||||||
#define TK_FROM 108
|
#define TK_ALL 108
|
||||||
#define TK_VARIABLE 109
|
#define TK_FROM 109
|
||||||
#define TK_INTERVAL 110
|
#define TK_VARIABLE 110
|
||||||
#define TK_FILL 111
|
#define TK_INTERVAL 111
|
||||||
#define TK_SLIDING 112
|
#define TK_FILL 112
|
||||||
#define TK_ORDER 113
|
#define TK_SLIDING 113
|
||||||
#define TK_BY 114
|
#define TK_ORDER 114
|
||||||
#define TK_ASC 115
|
#define TK_BY 115
|
||||||
#define TK_DESC 116
|
#define TK_ASC 116
|
||||||
#define TK_GROUP 117
|
#define TK_DESC 117
|
||||||
#define TK_HAVING 118
|
#define TK_GROUP 118
|
||||||
#define TK_LIMIT 119
|
#define TK_HAVING 119
|
||||||
#define TK_OFFSET 120
|
#define TK_LIMIT 120
|
||||||
#define TK_SLIMIT 121
|
#define TK_OFFSET 121
|
||||||
#define TK_SOFFSET 122
|
#define TK_SLIMIT 122
|
||||||
#define TK_WHERE 123
|
#define TK_SOFFSET 123
|
||||||
#define TK_NOW 124
|
#define TK_WHERE 124
|
||||||
#define TK_RESET 125
|
#define TK_NOW 125
|
||||||
#define TK_QUERY 126
|
#define TK_RESET 126
|
||||||
#define TK_ADD 127
|
#define TK_QUERY 127
|
||||||
#define TK_COLUMN 128
|
#define TK_ADD 128
|
||||||
#define TK_TAG 129
|
#define TK_COLUMN 129
|
||||||
#define TK_CHANGE 130
|
#define TK_TAG 130
|
||||||
#define TK_SET 131
|
#define TK_CHANGE 131
|
||||||
#define TK_KILL 132
|
#define TK_SET 132
|
||||||
#define TK_CONNECTION 133
|
#define TK_KILL 133
|
||||||
#define TK_STREAM 134
|
#define TK_CONNECTION 134
|
||||||
#define TK_COLON 135
|
#define TK_STREAM 135
|
||||||
#define TK_ABORT 136
|
#define TK_COLON 136
|
||||||
#define TK_AFTER 137
|
#define TK_ABORT 137
|
||||||
#define TK_ATTACH 138
|
#define TK_AFTER 138
|
||||||
#define TK_BEFORE 139
|
#define TK_ATTACH 139
|
||||||
#define TK_BEGIN 140
|
#define TK_BEFORE 140
|
||||||
#define TK_CASCADE 141
|
#define TK_BEGIN 141
|
||||||
#define TK_CLUSTER 142
|
#define TK_CASCADE 142
|
||||||
#define TK_CONFLICT 143
|
#define TK_CLUSTER 143
|
||||||
#define TK_COPY 144
|
#define TK_CONFLICT 144
|
||||||
#define TK_DEFERRED 145
|
#define TK_COPY 145
|
||||||
#define TK_DELIMITERS 146
|
#define TK_DEFERRED 146
|
||||||
#define TK_DETACH 147
|
#define TK_DELIMITERS 147
|
||||||
#define TK_EACH 148
|
#define TK_DETACH 148
|
||||||
#define TK_END 149
|
#define TK_EACH 149
|
||||||
#define TK_EXPLAIN 150
|
#define TK_END 150
|
||||||
#define TK_FAIL 151
|
#define TK_EXPLAIN 151
|
||||||
#define TK_FOR 152
|
#define TK_FAIL 152
|
||||||
#define TK_IGNORE 153
|
#define TK_FOR 153
|
||||||
#define TK_IMMEDIATE 154
|
#define TK_IGNORE 154
|
||||||
#define TK_INITIALLY 155
|
#define TK_IMMEDIATE 155
|
||||||
#define TK_INSTEAD 156
|
#define TK_INITIALLY 156
|
||||||
#define TK_MATCH 157
|
#define TK_INSTEAD 157
|
||||||
#define TK_KEY 158
|
#define TK_MATCH 158
|
||||||
#define TK_OF 159
|
#define TK_KEY 159
|
||||||
#define TK_RAISE 160
|
#define TK_OF 160
|
||||||
#define TK_REPLACE 161
|
#define TK_RAISE 161
|
||||||
#define TK_RESTRICT 162
|
#define TK_REPLACE 162
|
||||||
#define TK_ROW 163
|
#define TK_RESTRICT 163
|
||||||
#define TK_STATEMENT 164
|
#define TK_ROW 164
|
||||||
#define TK_TRIGGER 165
|
#define TK_STATEMENT 165
|
||||||
#define TK_VIEW 166
|
#define TK_TRIGGER 166
|
||||||
#define TK_COUNT 167
|
#define TK_VIEW 167
|
||||||
#define TK_SUM 168
|
#define TK_COUNT 168
|
||||||
#define TK_AVG 169
|
#define TK_SUM 169
|
||||||
#define TK_MIN 170
|
#define TK_AVG 170
|
||||||
#define TK_MAX 171
|
#define TK_MIN 171
|
||||||
#define TK_FIRST 172
|
#define TK_MAX 172
|
||||||
#define TK_LAST 173
|
#define TK_FIRST 173
|
||||||
#define TK_TOP 174
|
#define TK_LAST 174
|
||||||
#define TK_BOTTOM 175
|
#define TK_TOP 175
|
||||||
#define TK_STDDEV 176
|
#define TK_BOTTOM 176
|
||||||
#define TK_PERCENTILE 177
|
#define TK_STDDEV 177
|
||||||
#define TK_APERCENTILE 178
|
#define TK_PERCENTILE 178
|
||||||
#define TK_LEASTSQUARES 179
|
#define TK_APERCENTILE 179
|
||||||
#define TK_HISTOGRAM 180
|
#define TK_LEASTSQUARES 180
|
||||||
#define TK_DIFF 181
|
#define TK_HISTOGRAM 181
|
||||||
#define TK_SPREAD 182
|
#define TK_DIFF 182
|
||||||
#define TK_TWA 183
|
#define TK_SPREAD 183
|
||||||
#define TK_INTERP 184
|
#define TK_TWA 184
|
||||||
#define TK_LAST_ROW 185
|
#define TK_INTERP 185
|
||||||
#define TK_RATE 186
|
#define TK_LAST_ROW 186
|
||||||
#define TK_IRATE 187
|
#define TK_RATE 187
|
||||||
#define TK_SUM_RATE 188
|
#define TK_IRATE 188
|
||||||
#define TK_SUM_IRATE 189
|
#define TK_SUM_RATE 189
|
||||||
#define TK_AVG_RATE 190
|
#define TK_SUM_IRATE 190
|
||||||
#define TK_AVG_IRATE 191
|
#define TK_AVG_RATE 191
|
||||||
#define TK_TBID 192
|
#define TK_AVG_IRATE 192
|
||||||
#define TK_SEMI 193
|
#define TK_TBID 193
|
||||||
#define TK_NONE 194
|
#define TK_SEMI 194
|
||||||
#define TK_PREV 195
|
#define TK_NONE 195
|
||||||
#define TK_LINEAR 196
|
#define TK_PREV 196
|
||||||
#define TK_IMPORT 197
|
#define TK_LINEAR 197
|
||||||
#define TK_METRIC 198
|
#define TK_IMPORT 198
|
||||||
#define TK_TBNAME 199
|
#define TK_METRIC 199
|
||||||
#define TK_JOIN 200
|
#define TK_TBNAME 200
|
||||||
#define TK_METRICS 201
|
#define TK_JOIN 201
|
||||||
#define TK_STABLE 202
|
#define TK_METRICS 202
|
||||||
#define TK_INSERT 203
|
#define TK_STABLE 203
|
||||||
#define TK_INTO 204
|
#define TK_INSERT 204
|
||||||
#define TK_VALUES 205
|
#define TK_INTO 205
|
||||||
|
#define TK_VALUES 206
|
||||||
|
|
||||||
|
|
||||||
#define TK_SPACE 300
|
#define TK_SPACE 300
|
||||||
#define TK_COMMENT 301
|
#define TK_COMMENT 301
|
||||||
|
|
|
@ -25,9 +25,15 @@ typedef enum {
|
||||||
TAOS_WAL_FSYNC = 2
|
TAOS_WAL_FSYNC = 2
|
||||||
} EWalType;
|
} EWalType;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
TAOS_WAL_NOT_KEEP = 0,
|
||||||
|
TAOS_WAL_KEEP = 1
|
||||||
|
} EWalKeep;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int8_t msgType;
|
int8_t msgType;
|
||||||
int8_t reserved[3];
|
int8_t sver;
|
||||||
|
int8_t reserved[2];
|
||||||
int32_t len;
|
int32_t len;
|
||||||
uint64_t version;
|
uint64_t version;
|
||||||
uint32_t signature;
|
uint32_t signature;
|
||||||
|
@ -38,9 +44,8 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t vgId;
|
int32_t vgId;
|
||||||
int32_t fsyncPeriod; // millisecond
|
int32_t fsyncPeriod; // millisecond
|
||||||
int8_t walLevel; // wal level
|
EWalType walLevel; // wal level
|
||||||
int8_t wals; // number of WAL files;
|
EWalKeep keep; // keep the wal file when closed
|
||||||
int8_t keep; // keep the wal file when closed
|
|
||||||
} SWalCfg;
|
} SWalCfg;
|
||||||
|
|
||||||
typedef void * twalh; // WAL HANDLE
|
typedef void * twalh; // WAL HANDLE
|
||||||
|
@ -54,11 +59,12 @@ int32_t walAlter(twalh pWal, SWalCfg *pCfg);
|
||||||
void walStop(twalh);
|
void walStop(twalh);
|
||||||
void walClose(twalh);
|
void walClose(twalh);
|
||||||
int32_t walRenew(twalh);
|
int32_t walRenew(twalh);
|
||||||
|
void walRemoveOldFiles(twalh);
|
||||||
int32_t walWrite(twalh, SWalHead *);
|
int32_t walWrite(twalh, SWalHead *);
|
||||||
void walFsync(twalh, bool forceFsync);
|
void walFsync(twalh, bool forceFsync);
|
||||||
int32_t walRestore(twalh, void *pVnode, FWalWrite writeFp);
|
int32_t walRestore(twalh, void *pVnode, FWalWrite writeFp);
|
||||||
int32_t walGetWalFile(twalh, char *fileName, int64_t *fileId);
|
int32_t walGetWalFile(twalh, char *fileName, int64_t *fileId);
|
||||||
int64_t walGetVersion(twalh);
|
uint64_t walGetVersion(twalh);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,10 +37,15 @@ typedef struct {
|
||||||
} SRspRet;
|
} SRspRet;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SRspRet rspRet;
|
int32_t code;
|
||||||
void * pCont;
|
|
||||||
int32_t contLen;
|
int32_t contLen;
|
||||||
SRpcMsg rpcMsg;
|
void * rpcHandle;
|
||||||
|
void * rpcAhandle;
|
||||||
|
void * qhandle;
|
||||||
|
int8_t qtype;
|
||||||
|
int8_t msgType;
|
||||||
|
SRspRet rspRet;
|
||||||
|
char pCont[];
|
||||||
} SVReadMsg;
|
} SVReadMsg;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -62,13 +67,11 @@ int32_t vnodeAlter(void *pVnode, SCreateVnodeMsg *pVnodeCfg);
|
||||||
int32_t vnodeClose(int32_t vgId);
|
int32_t vnodeClose(int32_t vgId);
|
||||||
|
|
||||||
void* vnodeAcquire(int32_t vgId); // add refcount
|
void* vnodeAcquire(int32_t vgId); // add refcount
|
||||||
void* vnodeAcquireRqueue(int32_t vgId); // add refCount, get read queue
|
|
||||||
void vnodeRelease(void *pVnode); // dec refCount
|
void vnodeRelease(void *pVnode); // dec refCount
|
||||||
void* vnodeGetWal(void *pVnode);
|
void* vnodeGetWal(void *pVnode);
|
||||||
|
|
||||||
int32_t vnodeWriteToWQueue(void *vparam, void *wparam, int32_t qtype, void *rparam);
|
int32_t vnodeWriteToWQueue(void *vparam, void *wparam, int32_t qtype, void *rparam);
|
||||||
int32_t vnodeProcessWrite(void *vparam, void *wparam, int32_t qtype, void *rparam);
|
int32_t vnodeProcessWrite(void *vparam, void *wparam, int32_t qtype, void *rparam);
|
||||||
int32_t vnodeCheckWrite(void *pVnode);
|
|
||||||
int32_t vnodeGetVnodeList(int32_t vnodeList[], int32_t *numOfVnodes);
|
int32_t vnodeGetVnodeList(int32_t vnodeList[], int32_t *numOfVnodes);
|
||||||
void vnodeBuildStatusMsg(void *param);
|
void vnodeBuildStatusMsg(void *param);
|
||||||
void vnodeConfirmForward(void *param, uint64_t version, int32_t code);
|
void vnodeConfirmForward(void *param, uint64_t version, int32_t code);
|
||||||
|
@ -77,8 +80,8 @@ void vnodeSetAccess(SVgroupAccess *pAccess, int32_t numOfVnodes);
|
||||||
int32_t vnodeInitResources();
|
int32_t vnodeInitResources();
|
||||||
void vnodeCleanupResources();
|
void vnodeCleanupResources();
|
||||||
|
|
||||||
int32_t vnodeProcessRead(void *pVnode, SVReadMsg *pReadMsg);
|
int32_t vnodeWriteToRQueue(void *vparam, void *pCont, int32_t contLen, int8_t qtype, void *rparam);
|
||||||
int32_t vnodeCheckRead(void *pVnode);
|
int32_t vnodeProcessRead(void *pVnode, SVReadMsg *pRead);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ typedef struct SShellArguments {
|
||||||
extern void shellParseArgument(int argc, char* argv[], SShellArguments* arguments);
|
extern void shellParseArgument(int argc, char* argv[], SShellArguments* arguments);
|
||||||
extern TAOS* shellInit(SShellArguments* args);
|
extern TAOS* shellInit(SShellArguments* args);
|
||||||
extern void* shellLoopQuery(void* arg);
|
extern void* shellLoopQuery(void* arg);
|
||||||
extern void taos_error(TAOS_RES* tres);
|
extern void taos_error(TAOS_RES* tres, int64_t st);
|
||||||
extern int regex_match(const char* s, const char* reg, int cflags);
|
extern int regex_match(const char* s, const char* reg, int cflags);
|
||||||
void shellReadCommand(TAOS* con, char command[]);
|
void shellReadCommand(TAOS* con, char command[]);
|
||||||
int32_t shellRunCommand(TAOS* con, char* command);
|
int32_t shellRunCommand(TAOS* con, char* command);
|
||||||
|
|
|
@ -229,8 +229,8 @@ void shellReadCommand(TAOS *con, char *command) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
if (isReadyGo(&cmd)) {
|
if (isReadyGo(&cmd)) {
|
||||||
sprintf(command, "%s%s", cmd.buffer, cmd.command);
|
sprintf(command, "%s%s", cmd.buffer, cmd.command);
|
||||||
taosTFree(cmd.buffer);
|
tfree(cmd.buffer);
|
||||||
taosTFree(cmd.command);
|
tfree(cmd.command);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
updateBuffer(&cmd);
|
updateBuffer(&cmd);
|
||||||
|
|
|
@ -193,7 +193,7 @@ int32_t shellRunCommand(TAOS* con, char* command) {
|
||||||
history.hist[(history.hend + MAX_HISTORY_SIZE - 1) % MAX_HISTORY_SIZE] == NULL ||
|
history.hist[(history.hend + MAX_HISTORY_SIZE - 1) % MAX_HISTORY_SIZE] == NULL ||
|
||||||
strcmp(command, history.hist[(history.hend + MAX_HISTORY_SIZE - 1) % MAX_HISTORY_SIZE]) != 0) {
|
strcmp(command, history.hist[(history.hend + MAX_HISTORY_SIZE - 1) % MAX_HISTORY_SIZE]) != 0) {
|
||||||
if (history.hist[history.hend] != NULL) {
|
if (history.hist[history.hend] != NULL) {
|
||||||
taosTFree(history.hist[history.hend]);
|
tfree(history.hist[history.hend]);
|
||||||
}
|
}
|
||||||
history.hist[history.hend] = strdup(command);
|
history.hist[history.hend] = strdup(command);
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ void shellRunCommandOnServer(TAOS *con, char command[]) {
|
||||||
|
|
||||||
TAOS_RES* pSql = taos_query_h(con, command, &result);
|
TAOS_RES* pSql = taos_query_h(con, command, &result);
|
||||||
if (taos_errno(pSql)) {
|
if (taos_errno(pSql)) {
|
||||||
taos_error(pSql);
|
taos_error(pSql, st);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -770,7 +770,7 @@ void read_history() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((read_size = taosGetline(&line, &line_size, f)) != -1) {
|
while ((read_size = tgetline(&line, &line_size, f)) != -1) {
|
||||||
line[read_size - 1] = '\0';
|
line[read_size - 1] = '\0';
|
||||||
history.hist[history.hend] = strdup(line);
|
history.hist[history.hend] = strdup(line);
|
||||||
|
|
||||||
|
@ -800,16 +800,17 @@ void write_history() {
|
||||||
for (int i = history.hstart; i != history.hend;) {
|
for (int i = history.hstart; i != history.hend;) {
|
||||||
if (history.hist[i] != NULL) {
|
if (history.hist[i] != NULL) {
|
||||||
fprintf(f, "%s\n", history.hist[i]);
|
fprintf(f, "%s\n", history.hist[i]);
|
||||||
taosTFree(history.hist[i]);
|
tfree(history.hist[i]);
|
||||||
}
|
}
|
||||||
i = (i + 1) % MAX_HISTORY_SIZE;
|
i = (i + 1) % MAX_HISTORY_SIZE;
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_error(TAOS_RES *tres) {
|
void taos_error(TAOS_RES *tres, int64_t st) {
|
||||||
|
int64_t et = taosGetTimestampUs();
|
||||||
atomic_store_ptr(&result, 0);
|
atomic_store_ptr(&result, 0);
|
||||||
fprintf(stderr, "\nDB error: %s\n", taos_errstr(tres));
|
fprintf(stderr, "\nDB error: %s (%.6fs)\n", taos_errstr(tres), (et - st) / 1E6);
|
||||||
taos_free_result(tres);
|
taos_free_result(tres);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -853,7 +854,7 @@ void source_file(TAOS *con, char *fptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((read_len = taosGetline(&line, &line_len, f)) != -1) {
|
while ((read_len = tgetline(&line, &line_len, f)) != -1) {
|
||||||
if (read_len >= tsMaxSQLStringLen) continue;
|
if (read_len >= tsMaxSQLStringLen) continue;
|
||||||
line[--read_len] = '\0';
|
line[--read_len] = '\0';
|
||||||
|
|
||||||
|
|
|
@ -232,8 +232,8 @@ void shellReadCommand(TAOS *con, char *command) {
|
||||||
printf("\n");
|
printf("\n");
|
||||||
if (isReadyGo(&cmd)) {
|
if (isReadyGo(&cmd)) {
|
||||||
sprintf(command, "%s%s", cmd.buffer, cmd.command);
|
sprintf(command, "%s%s", cmd.buffer, cmd.command);
|
||||||
taosTFree(cmd.buffer);
|
tfree(cmd.buffer);
|
||||||
taosTFree(cmd.command);
|
tfree(cmd.command);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
updateBuffer(&cmd);
|
updateBuffer(&cmd);
|
||||||
|
@ -351,7 +351,7 @@ void *shellLoopQuery(void *arg) {
|
||||||
reset_terminal_mode();
|
reset_terminal_mode();
|
||||||
} while (shellRunCommand(con, command) == 0);
|
} while (shellRunCommand(con, command) == 0);
|
||||||
|
|
||||||
taosTFree(command);
|
tfree(command);
|
||||||
exitShell();
|
exitShell();
|
||||||
|
|
||||||
pthread_cleanup_pop(1);
|
pthread_cleanup_pop(1);
|
||||||
|
|
|
@ -793,9 +793,9 @@ int main(int argc, char *argv[]) {
|
||||||
(ntables * nrecords_per_table) / (t * nrecords_per_request),
|
(ntables * nrecords_per_table) / (t * nrecords_per_request),
|
||||||
t * 1000);
|
t * 1000);
|
||||||
|
|
||||||
printf("Spent %.4f seconds to insert %d records with %d record(s) per request: %.2f records/second\n",
|
printf("Spent %.4f seconds to insert %lld records with %d record(s) per request: %.2f records/second\n",
|
||||||
t, ntables * nrecords_per_table, nrecords_per_request,
|
t, (long long int)ntables * nrecords_per_table, nrecords_per_request,
|
||||||
ntables * nrecords_per_table / t);
|
((long long int)ntables * nrecords_per_table) / t);
|
||||||
|
|
||||||
for (int i = 0; i < threads; i++) {
|
for (int i = 0; i < threads; i++) {
|
||||||
info *t_info = infos + i;
|
info *t_info = infos + i;
|
||||||
|
@ -955,7 +955,7 @@ void querySqlFile(TAOS* taos, char* sqlFile)
|
||||||
|
|
||||||
double t = getCurrentTime();
|
double t = getCurrentTime();
|
||||||
|
|
||||||
while ((read_len = taosGetline(&line, &line_len, fp)) != -1) {
|
while ((read_len = tgetline(&line, &line_len, fp)) != -1) {
|
||||||
if (read_len >= MAX_SQL_SIZE) continue;
|
if (read_len >= MAX_SQL_SIZE) continue;
|
||||||
line[--read_len] = '\0';
|
line[--read_len] = '\0';
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ typedef struct STableObj {
|
||||||
int8_t type;
|
int8_t type;
|
||||||
} STableObj;
|
} STableObj;
|
||||||
|
|
||||||
typedef struct SSuperTableObj {
|
typedef struct SSTableObj {
|
||||||
STableObj info;
|
STableObj info;
|
||||||
int8_t reserved0[9]; // for fill struct STableObj to 4byte align
|
int8_t reserved0[9]; // for fill struct STableObj to 4byte align
|
||||||
int16_t nextColId;
|
int16_t nextColId;
|
||||||
|
@ -104,7 +104,7 @@ typedef struct SSuperTableObj {
|
||||||
int32_t numOfTables;
|
int32_t numOfTables;
|
||||||
SSchema * schema;
|
SSchema * schema;
|
||||||
void * vgHash;
|
void * vgHash;
|
||||||
} SSuperTableObj;
|
} SSTableObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
STableObj info;
|
STableObj info;
|
||||||
|
@ -122,8 +122,8 @@ typedef struct {
|
||||||
int32_t refCount;
|
int32_t refCount;
|
||||||
char* sql; //used by normal table
|
char* sql; //used by normal table
|
||||||
SSchema* schema; //used by normal table
|
SSchema* schema; //used by normal table
|
||||||
SSuperTableObj *superTable;
|
SSTableObj*superTable;
|
||||||
} SChildTableObj;
|
} SCTableObj;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int32_t dnodeId;
|
int32_t dnodeId;
|
||||||
|
@ -172,7 +172,8 @@ typedef struct {
|
||||||
int8_t walLevel;
|
int8_t walLevel;
|
||||||
int8_t replications;
|
int8_t replications;
|
||||||
int8_t quorum;
|
int8_t quorum;
|
||||||
int8_t reserved[12];
|
int8_t update;
|
||||||
|
int8_t reserved[11];
|
||||||
} SDbCfg;
|
} SDbCfg;
|
||||||
|
|
||||||
typedef struct SDbObj {
|
typedef struct SDbObj {
|
||||||
|
|
|
@ -29,8 +29,8 @@ int64_t mnodeGetChildTableNum();
|
||||||
void * mnodeGetTable(char *tableId);
|
void * mnodeGetTable(char *tableId);
|
||||||
void mnodeIncTableRef(void *pTable);
|
void mnodeIncTableRef(void *pTable);
|
||||||
void mnodeDecTableRef(void *pTable);
|
void mnodeDecTableRef(void *pTable);
|
||||||
void * mnodeGetNextChildTable(void *pIter, SChildTableObj **pTable);
|
void * mnodeGetNextChildTable(void *pIter, SCTableObj **pTable);
|
||||||
void * mnodeGetNextSuperTable(void *pIter, SSuperTableObj **pTable);
|
void * mnodeGetNextSuperTable(void *pIter, SSTableObj **pTable);
|
||||||
void mnodeDropAllChildTables(SDbObj *pDropDb);
|
void mnodeDropAllChildTables(SDbObj *pDropDb);
|
||||||
void mnodeDropAllSuperTables(SDbObj *pDropDb);
|
void mnodeDropAllSuperTables(SDbObj *pDropDb);
|
||||||
void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup);
|
void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup);
|
||||||
|
|
|
@ -43,8 +43,8 @@ void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle);
|
||||||
void mnodeAlterVgroup(SVgObj *pVgroup, void *ahandle);
|
void mnodeAlterVgroup(SVgObj *pVgroup, void *ahandle);
|
||||||
int32_t mnodeGetAvailableVgroup(struct SMnodeMsg *pMsg, SVgObj **pVgroup, int32_t *sid);
|
int32_t mnodeGetAvailableVgroup(struct SMnodeMsg *pMsg, SVgObj **pVgroup, int32_t *sid);
|
||||||
|
|
||||||
void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable);
|
void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SCTableObj *pTable);
|
||||||
void mnodeRemoveTableFromVgroup(SVgObj *pVgroup, SChildTableObj *pTable);
|
void mnodeRemoveTableFromVgroup(SVgObj *pVgroup, SCTableObj *pTable);
|
||||||
void mnodeSendDropVnodeMsg(int32_t vgId, SRpcEpSet *epSet, void *ahandle);
|
void mnodeSendDropVnodeMsg(int32_t vgId, SRpcEpSet *epSet, void *ahandle);
|
||||||
void mnodeSendCreateVgroupMsg(SVgObj *pVgroup, void *ahandle);
|
void mnodeSendCreateVgroupMsg(SVgObj *pVgroup, void *ahandle);
|
||||||
void mnodeSendAlterVgroupMsg(SVgObj *pVgroup);
|
void mnodeSendAlterVgroupMsg(SVgObj *pVgroup);
|
||||||
|
|
|
@ -34,7 +34,7 @@ static int32_t mnodeCreateRootAcct();
|
||||||
static int32_t mnodeAcctActionDestroy(SSdbOper *pOper) {
|
static int32_t mnodeAcctActionDestroy(SSdbOper *pOper) {
|
||||||
SAcctObj *pAcct = pOper->pObj;
|
SAcctObj *pAcct = pOper->pObj;
|
||||||
pthread_mutex_destroy(&pAcct->mutex);
|
pthread_mutex_destroy(&pAcct->mutex);
|
||||||
taosTFree(pOper->pObj);
|
tfree(pOper->pObj);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ static int32_t mnodeGetClusterMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *
|
||||||
static int32_t mnodeRetrieveClusters(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
static int32_t mnodeRetrieveClusters(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
|
||||||
static int32_t mnodeClusterActionDestroy(SSdbOper *pOper) {
|
static int32_t mnodeClusterActionDestroy(SSdbOper *pOper) {
|
||||||
taosTFree(pOper->pObj);
|
tfree(pOper->pObj);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,8 +52,8 @@ static int32_t mnodeProcessDropDbMsg(SMnodeMsg *pMsg);
|
||||||
|
|
||||||
static void mnodeDestroyDb(SDbObj *pDb) {
|
static void mnodeDestroyDb(SDbObj *pDb) {
|
||||||
pthread_mutex_destroy(&pDb->mutex);
|
pthread_mutex_destroy(&pDb->mutex);
|
||||||
taosTFree(pDb->vgList);
|
tfree(pDb->vgList);
|
||||||
taosTFree(pDb);
|
tfree(pDb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeDbActionDestroy(SSdbOper *pOper) {
|
static int32_t mnodeDbActionDestroy(SSdbOper *pOper) {
|
||||||
|
@ -319,6 +319,11 @@ static int32_t mnodeCheckDbCfg(SDbCfg *pCfg) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (pCfg->update < TSDB_MIN_DB_UPDATE || pCfg->update > TSDB_MAX_DB_UPDATE) {
|
||||||
|
mError("invalid db option update:%d valid range: [%d, %d]", pCfg->update, TSDB_MIN_DB_UPDATE, TSDB_MAX_DB_UPDATE);
|
||||||
|
return TSDB_CODE_MND_INVALID_DB_OPTION;
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,6 +344,7 @@ static void mnodeSetDefaultDbCfg(SDbCfg *pCfg) {
|
||||||
if (pCfg->walLevel < 0) pCfg->walLevel = tsWAL;
|
if (pCfg->walLevel < 0) pCfg->walLevel = tsWAL;
|
||||||
if (pCfg->replications < 0) pCfg->replications = tsReplications;
|
if (pCfg->replications < 0) pCfg->replications = tsReplications;
|
||||||
if (pCfg->quorum < 0) pCfg->quorum = tsQuorum;
|
if (pCfg->quorum < 0) pCfg->quorum = tsQuorum;
|
||||||
|
if (pCfg->update < 0) pCfg->update = tsUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeCreateDbCb(SMnodeMsg *pMsg, int32_t code) {
|
static int32_t mnodeCreateDbCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
|
@ -391,14 +397,15 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
|
||||||
.compression = pCreate->compression,
|
.compression = pCreate->compression,
|
||||||
.walLevel = pCreate->walLevel,
|
.walLevel = pCreate->walLevel,
|
||||||
.replications = pCreate->replications,
|
.replications = pCreate->replications,
|
||||||
.quorum = pCreate->quorum
|
.quorum = pCreate->quorum,
|
||||||
|
.update = pCreate->update
|
||||||
};
|
};
|
||||||
|
|
||||||
mnodeSetDefaultDbCfg(&pDb->cfg);
|
mnodeSetDefaultDbCfg(&pDb->cfg);
|
||||||
|
|
||||||
code = mnodeCheckDbCfg(&pDb->cfg);
|
code = mnodeCheckDbCfg(&pDb->cfg);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
taosTFree(pDb);
|
tfree(pDb);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -610,6 +617,12 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn
|
||||||
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
|
pShow->bytes[cols] = 1;
|
||||||
|
pSchema[cols].type = TSDB_DATA_TYPE_TINYINT;
|
||||||
|
strcpy(pSchema[cols].name, "update");
|
||||||
|
pSchema[cols].bytes = htons(pShow->bytes[cols]);
|
||||||
|
cols++;
|
||||||
|
|
||||||
pShow->bytes[cols] = 10 + VARSTR_HEADER_SIZE;
|
pShow->bytes[cols] = 10 + VARSTR_HEADER_SIZE;
|
||||||
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
pSchema[cols].type = TSDB_DATA_TYPE_BINARY;
|
||||||
strcpy(pSchema[cols].name, "status");
|
strcpy(pSchema[cols].name, "status");
|
||||||
|
@ -749,6 +762,10 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void
|
||||||
STR_WITH_SIZE_TO_VARSTR(pWrite, prec, 2);
|
STR_WITH_SIZE_TO_VARSTR(pWrite, prec, 2);
|
||||||
cols++;
|
cols++;
|
||||||
|
|
||||||
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
|
*(int8_t *)pWrite = pDb->cfg.update;
|
||||||
|
cols++;
|
||||||
|
|
||||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||||
if (pDb->status == TSDB_DB_STATUS_READY) {
|
if (pDb->status == TSDB_DB_STATUS_READY) {
|
||||||
const char *src = "ready";
|
const char *src = "ready";
|
||||||
|
@ -848,6 +865,7 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
|
||||||
int8_t replications = pAlter->replications;
|
int8_t replications = pAlter->replications;
|
||||||
int8_t quorum = pAlter->quorum;
|
int8_t quorum = pAlter->quorum;
|
||||||
int8_t precision = pAlter->precision;
|
int8_t precision = pAlter->precision;
|
||||||
|
int8_t update = pAlter->update;
|
||||||
|
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
terrno = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
@ -950,6 +968,16 @@ static SDbCfg mnodeGetAlterDbOption(SDbObj *pDb, SAlterDbMsg *pAlter) {
|
||||||
newCfg.quorum = quorum;
|
newCfg.quorum = quorum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (update >= 0 && update != pDb->cfg.update) {
|
||||||
|
#if 0
|
||||||
|
mDebug("db:%s, update:%d change to %d", pDb->name, pDb->cfg.update, update);
|
||||||
|
newCfg.update = update;
|
||||||
|
#else
|
||||||
|
mError("db:%s, can't alter update option", pDb->name);
|
||||||
|
terrno = TSDB_CODE_MND_INVALID_DB_OPTION;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return newCfg;
|
return newCfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ static char* offlineReason[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static int32_t mnodeDnodeActionDestroy(SSdbOper *pOper) {
|
static int32_t mnodeDnodeActionDestroy(SSdbOper *pOper) {
|
||||||
taosTFree(pOper->pObj);
|
tfree(pOper->pObj);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,7 +655,7 @@ static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) {
|
||||||
int32_t code = sdbInsertRow(&oper);
|
int32_t code = sdbInsertRow(&oper);
|
||||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
int dnodeId = pDnode->dnodeId;
|
int dnodeId = pDnode->dnodeId;
|
||||||
taosTFree(pDnode);
|
tfree(pDnode);
|
||||||
mError("failed to create dnode:%d, reason:%s", dnodeId, tstrerror(code));
|
mError("failed to create dnode:%d, reason:%s", dnodeId, tstrerror(code));
|
||||||
} else {
|
} else {
|
||||||
mLInfo("dnode:%d is created", pDnode->dnodeId);
|
mLInfo("dnode:%d is created", pDnode->dnodeId);
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
#include "taosmsg.h"
|
#include "taosmsg.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
#include "trpc.h"
|
#include "trpc.h"
|
||||||
#include "tcache.h"
|
#include "tqueue.h"
|
||||||
#include "mnode.h"
|
#include "mnode.h"
|
||||||
#include "dnode.h"
|
#include "dnode.h"
|
||||||
#include "mnodeDef.h"
|
#include "mnodeDef.h"
|
||||||
|
@ -34,8 +34,16 @@
|
||||||
#include "mnodeUser.h"
|
#include "mnodeUser.h"
|
||||||
#include "mnodeVgroup.h"
|
#include "mnodeVgroup.h"
|
||||||
|
|
||||||
void mnodeCreateMsg(SMnodeMsg *pMsg, SRpcMsg *rpcMsg) {
|
void *mnodeCreateMsg(SRpcMsg *pRpcMsg) {
|
||||||
pMsg->rpcMsg = *rpcMsg;
|
int32_t size = sizeof(SMnodeMsg) + pRpcMsg->contLen;
|
||||||
|
SMnodeMsg *pMsg = taosAllocateQitem(size);
|
||||||
|
|
||||||
|
pMsg->rpcMsg = *pRpcMsg;
|
||||||
|
pMsg->rpcMsg.pCont = pMsg->pCont;
|
||||||
|
pMsg->incomingTs = taosGetTimestampSec();
|
||||||
|
memcpy(pMsg->pCont, pRpcMsg->pCont, pRpcMsg->contLen);
|
||||||
|
|
||||||
|
return pMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t mnodeInitMsg(SMnodeMsg *pMsg) {
|
int32_t mnodeInitMsg(SMnodeMsg *pMsg) {
|
||||||
|
@ -54,7 +62,9 @@ int32_t mnodeInitMsg(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
void mnodeCleanupMsg(SMnodeMsg *pMsg) {
|
void mnodeCleanupMsg(SMnodeMsg *pMsg) {
|
||||||
if (pMsg != NULL) {
|
if (pMsg != NULL) {
|
||||||
if (pMsg->rpcMsg.pCont) rpcFreeCont(pMsg->rpcMsg.pCont);
|
if (pMsg->rpcMsg.pCont != pMsg->pCont) {
|
||||||
|
tfree(pMsg->rpcMsg.pCont);
|
||||||
|
}
|
||||||
if (pMsg->pUser) mnodeDecUserRef(pMsg->pUser);
|
if (pMsg->pUser) mnodeDecUserRef(pMsg->pUser);
|
||||||
if (pMsg->pDb) mnodeDecDbRef(pMsg->pDb);
|
if (pMsg->pDb) mnodeDecDbRef(pMsg->pDb);
|
||||||
if (pMsg->pVgroup) mnodeDecVgroupRef(pMsg->pVgroup);
|
if (pMsg->pVgroup) mnodeDecVgroupRef(pMsg->pVgroup);
|
||||||
|
|
|
@ -96,9 +96,9 @@ int32_t mnodeStartSystem() {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dnodeAllocateMnodeWqueue();
|
dnodeAllocMWritequeue();
|
||||||
dnodeAllocateMnodeRqueue();
|
dnodeAllocMReadQueue();
|
||||||
dnodeAllocateMnodePqueue();
|
dnodeAllocateMPeerQueue();
|
||||||
|
|
||||||
if (mnodeInitComponents() != 0) {
|
if (mnodeInitComponents() != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -127,9 +127,9 @@ void mnodeCleanupSystem() {
|
||||||
mInfo("starting to clean up mnode");
|
mInfo("starting to clean up mnode");
|
||||||
tsMgmtIsRunning = false;
|
tsMgmtIsRunning = false;
|
||||||
|
|
||||||
dnodeFreeMnodeWqueue();
|
dnodeFreeMWritequeue();
|
||||||
dnodeFreeMnodeRqueue();
|
dnodeFreeMReadQueue();
|
||||||
dnodeFreeMnodePqueue();
|
dnodeFreeMPeerQueue();
|
||||||
mnodeCleanupTimer();
|
mnodeCleanupTimer();
|
||||||
mnodeCleanupComponents(sizeof(tsMnodeComponents) / sizeof(tsMnodeComponents[0]) - 1);
|
mnodeCleanupComponents(sizeof(tsMnodeComponents) / sizeof(tsMnodeComponents[0]) - 1);
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ static int32_t mnodeRetrieveMnodes(SShowObj *pShow, char *data, int32_t rows, vo
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int32_t mnodeMnodeActionDestroy(SSdbOper *pOper) {
|
static int32_t mnodeMnodeActionDestroy(SSdbOper *pOper) {
|
||||||
taosTFree(pOper->pObj);
|
tfree(pOper->pObj);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,14 +342,14 @@ void mnodeCreateMnode(int32_t dnodeId, char *dnodeEp, bool needConfirm) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
taosTFree(pMnode);
|
tfree(pMnode);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = sdbInsertRow(&oper);
|
code = sdbInsertRow(&oper);
|
||||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
mError("dnode:%d, failed to create mnode, ep:%s reason:%s", dnodeId, dnodeEp, tstrerror(code));
|
mError("dnode:%d, failed to create mnode, ep:%s reason:%s", dnodeId, dnodeEp, tstrerror(code));
|
||||||
taosTFree(pMnode);
|
tfree(pMnode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,8 +131,8 @@ SConnObj *mnodeAccquireConn(int32_t connId, char *user, uint32_t ip, uint16_t po
|
||||||
|
|
||||||
static void mnodeFreeConn(void *data) {
|
static void mnodeFreeConn(void *data) {
|
||||||
SConnObj *pConn = data;
|
SConnObj *pConn = data;
|
||||||
taosTFree(pConn->pQueries);
|
tfree(pConn->pQueries);
|
||||||
taosTFree(pConn->pStreams);
|
tfree(pConn->pStreams);
|
||||||
|
|
||||||
mDebug("connId:%d, is destroyed", pConn->connId);
|
mDebug("connId:%d, is destroyed", pConn->connId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ typedef struct {
|
||||||
ESyncRole role;
|
ESyncRole role;
|
||||||
ESdbStatus status;
|
ESdbStatus status;
|
||||||
int64_t version;
|
int64_t version;
|
||||||
void * sync;
|
int64_t sync;
|
||||||
void * wal;
|
void * wal;
|
||||||
SSyncCfg cfg;
|
SSyncCfg cfg;
|
||||||
int32_t numOfTables;
|
int32_t numOfTables;
|
||||||
|
@ -175,7 +175,7 @@ static void *sdbGetTableFromId(int32_t tableId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t sdbInitWal() {
|
static int32_t sdbInitWal() {
|
||||||
SWalCfg walCfg = {.vgId = 1, .walLevel = 2, .wals = 2, .keep = 1, .fsyncPeriod = 0};
|
SWalCfg walCfg = {.vgId = 1, .walLevel = TAOS_WAL_FSYNC, .keep = TAOS_WAL_KEEP, .fsyncPeriod = 0};
|
||||||
char temp[TSDB_FILENAME_LEN];
|
char temp[TSDB_FILENAME_LEN];
|
||||||
sprintf(temp, "%s/wal", tsMnodeDir);
|
sprintf(temp, "%s/wal", tsMnodeDir);
|
||||||
tsSdbObj.wal = walOpen(temp, &walCfg);
|
tsSdbObj.wal = walOpen(temp, &walCfg);
|
||||||
|
@ -212,7 +212,7 @@ static void sdbRestoreTables() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdbUpdateMnodeRoles() {
|
void sdbUpdateMnodeRoles() {
|
||||||
if (tsSdbObj.sync == NULL) return;
|
if (tsSdbObj.sync <= 0) return;
|
||||||
|
|
||||||
SNodesRole roles = {0};
|
SNodesRole roles = {0};
|
||||||
syncGetNodesRole(tsSdbObj.sync, &roles);
|
syncGetNodesRole(tsSdbObj.sync, &roles);
|
||||||
|
@ -295,7 +295,7 @@ static void sdbConfirmForward(void *ahandle, void *param, int32_t code) {
|
||||||
if (pOper->writeCb != NULL) {
|
if (pOper->writeCb != NULL) {
|
||||||
pOper->retCode = (*pOper->writeCb)(pMsg, pOper->retCode);
|
pOper->retCode = (*pOper->writeCb)(pMsg, pOper->retCode);
|
||||||
}
|
}
|
||||||
dnodeSendRpcMnodeWriteRsp(pMsg, pOper->retCode);
|
dnodeSendRpcMWriteRsp(pMsg, pOper->retCode);
|
||||||
|
|
||||||
// if ahandle, means this func is called by sdb write
|
// if ahandle, means this func is called by sdb write
|
||||||
if (ahandle == NULL) {
|
if (ahandle == NULL) {
|
||||||
|
@ -433,7 +433,7 @@ void sdbCleanUp() {
|
||||||
|
|
||||||
if (tsSdbObj.sync) {
|
if (tsSdbObj.sync) {
|
||||||
syncStop(tsSdbObj.sync);
|
syncStop(tsSdbObj.sync);
|
||||||
tsSdbObj.sync = NULL;
|
tsSdbObj.sync = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tsSdbObj.wal) {
|
if (tsSdbObj.wal) {
|
||||||
|
@ -984,7 +984,7 @@ void sdbCleanupWriteWorker() {
|
||||||
}
|
}
|
||||||
|
|
||||||
sdbFreeWritequeue();
|
sdbFreeWritequeue();
|
||||||
taosTFree(tsSdbPool.writeWorker);
|
tfree(tsSdbPool.writeWorker);
|
||||||
|
|
||||||
mInfo("sdb write is closed");
|
mInfo("sdb write is closed");
|
||||||
}
|
}
|
||||||
|
@ -1043,7 +1043,7 @@ void sdbFreeWritequeue() {
|
||||||
int32_t sdbWriteToQueue(void *param, void *data, int32_t qtype, void *pMsg) {
|
int32_t sdbWriteToQueue(void *param, void *data, int32_t qtype, void *pMsg) {
|
||||||
SWalHead *pHead = data;
|
SWalHead *pHead = data;
|
||||||
int32_t size = sizeof(SWalHead) + pHead->len;
|
int32_t size = sizeof(SWalHead) + pHead->len;
|
||||||
SWalHead *pWal = (SWalHead *)taosAllocateQitem(size);
|
SWalHead *pWal = taosAllocateQitem(size);
|
||||||
memcpy(pWal, pHead, size);
|
memcpy(pWal, pHead, size);
|
||||||
|
|
||||||
taosWriteQitem(tsSdbWriteQueue, qtype, pWal);
|
taosWriteQitem(tsSdbWriteQueue, qtype, pWal);
|
||||||
|
|
|
@ -415,7 +415,7 @@ static void mnodeFreeShowObj(void *data) {
|
||||||
sdbFreeIter(pShow->pIter);
|
sdbFreeIter(pShow->pIter);
|
||||||
|
|
||||||
mDebug("%p, show is destroyed, data:%p index:%d", pShow, data, pShow->index);
|
mDebug("%p, show is destroyed, data:%p index:%d", pShow, data, pShow->index);
|
||||||
taosTFree(pShow);
|
tfree(pShow);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mnodeReleaseShowObj(SShowObj *pShow, bool forceRemove) {
|
static void mnodeReleaseShowObj(SShowObj *pShow, bool forceRemove) {
|
||||||
|
|
|
@ -45,6 +45,10 @@
|
||||||
#include "mnodeRead.h"
|
#include "mnodeRead.h"
|
||||||
#include "mnodePeer.h"
|
#include "mnodePeer.h"
|
||||||
|
|
||||||
|
#define ALTER_CTABLE_RETRY_TIMES 3
|
||||||
|
#define CREATE_CTABLE_RETRY_TIMES 10
|
||||||
|
#define CREATE_CTABLE_RETRY_SEC 14
|
||||||
|
|
||||||
static void * tsChildTableSdb;
|
static void * tsChildTableSdb;
|
||||||
static void * tsSuperTableSdb;
|
static void * tsSuperTableSdb;
|
||||||
static int32_t tsChildTableUpdateSize;
|
static int32_t tsChildTableUpdateSize;
|
||||||
|
@ -52,9 +56,9 @@ static int32_t tsSuperTableUpdateSize;
|
||||||
static void * mnodeGetChildTable(char *tableId);
|
static void * mnodeGetChildTable(char *tableId);
|
||||||
static void * mnodeGetSuperTable(char *tableId);
|
static void * mnodeGetSuperTable(char *tableId);
|
||||||
static void * mnodeGetSuperTableByUid(uint64_t uid);
|
static void * mnodeGetSuperTableByUid(uint64_t uid);
|
||||||
static void mnodeDropAllChildTablesInStable(SSuperTableObj *pStable);
|
static void mnodeDropAllChildTablesInStable(SSTableObj *pStable);
|
||||||
static void mnodeAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCtable);
|
static void mnodeAddTableIntoStable(SSTableObj *pStable, SCTableObj *pCtable);
|
||||||
static void mnodeRemoveTableFromStable(SSuperTableObj *pStable, SChildTableObj *pCtable);
|
static void mnodeRemoveTableFromStable(SSTableObj *pStable, SCTableObj *pCtable);
|
||||||
|
|
||||||
static int32_t mnodeGetShowTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
static int32_t mnodeGetShowTableMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn);
|
||||||
static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows, void *pConn);
|
||||||
|
@ -86,13 +90,13 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg);
|
||||||
static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg);
|
static int32_t mnodeProcessAlterTableMsg(SMnodeMsg *pMsg);
|
||||||
static void mnodeProcessAlterTableRsp(SRpcMsg *rpcMsg);
|
static void mnodeProcessAlterTableRsp(SRpcMsg *rpcMsg);
|
||||||
|
|
||||||
static int32_t mnodeFindSuperTableColumnIndex(SSuperTableObj *pStable, char *colName);
|
static int32_t mnodeFindSuperTableColumnIndex(SSTableObj *pStable, char *colName);
|
||||||
|
|
||||||
static void mnodeDestroyChildTable(SChildTableObj *pTable) {
|
static void mnodeDestroyChildTable(SCTableObj *pTable) {
|
||||||
taosTFree(pTable->info.tableId);
|
tfree(pTable->info.tableId);
|
||||||
taosTFree(pTable->schema);
|
tfree(pTable->schema);
|
||||||
taosTFree(pTable->sql);
|
tfree(pTable->sql);
|
||||||
taosTFree(pTable);
|
tfree(pTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeChildTableActionDestroy(SSdbOper *pOper) {
|
static int32_t mnodeChildTableActionDestroy(SSdbOper *pOper) {
|
||||||
|
@ -101,7 +105,7 @@ static int32_t mnodeChildTableActionDestroy(SSdbOper *pOper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeChildTableActionInsert(SSdbOper *pOper) {
|
static int32_t mnodeChildTableActionInsert(SSdbOper *pOper) {
|
||||||
SChildTableObj *pTable = pOper->pObj;
|
SCTableObj *pTable = pOper->pObj;
|
||||||
|
|
||||||
SVgObj *pVgroup = mnodeGetVgroup(pTable->vgId);
|
SVgObj *pVgroup = mnodeGetVgroup(pTable->vgId);
|
||||||
if (pVgroup == NULL) {
|
if (pVgroup == NULL) {
|
||||||
|
@ -150,7 +154,7 @@ static int32_t mnodeChildTableActionInsert(SSdbOper *pOper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeChildTableActionDelete(SSdbOper *pOper) {
|
static int32_t mnodeChildTableActionDelete(SSdbOper *pOper) {
|
||||||
SChildTableObj *pTable = pOper->pObj;
|
SCTableObj *pTable = pOper->pObj;
|
||||||
if (pTable->vgId == 0) {
|
if (pTable->vgId == 0) {
|
||||||
return TSDB_CODE_MND_VGROUP_NOT_EXIST;
|
return TSDB_CODE_MND_VGROUP_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
@ -186,8 +190,8 @@ static int32_t mnodeChildTableActionDelete(SSdbOper *pOper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeChildTableActionUpdate(SSdbOper *pOper) {
|
static int32_t mnodeChildTableActionUpdate(SSdbOper *pOper) {
|
||||||
SChildTableObj *pNew = pOper->pObj;
|
SCTableObj *pNew = pOper->pObj;
|
||||||
SChildTableObj *pTable = mnodeGetChildTable(pNew->info.tableId);
|
SCTableObj *pTable = mnodeGetChildTable(pNew->info.tableId);
|
||||||
if (pTable != pNew) {
|
if (pTable != pNew) {
|
||||||
void *oldTableId = pTable->info.tableId;
|
void *oldTableId = pTable->info.tableId;
|
||||||
void *oldSql = pTable->sql;
|
void *oldSql = pTable->sql;
|
||||||
|
@ -195,7 +199,7 @@ static int32_t mnodeChildTableActionUpdate(SSdbOper *pOper) {
|
||||||
void *oldSTable = pTable->superTable;
|
void *oldSTable = pTable->superTable;
|
||||||
int32_t oldRefCount = pTable->refCount;
|
int32_t oldRefCount = pTable->refCount;
|
||||||
|
|
||||||
memcpy(pTable, pNew, sizeof(SChildTableObj));
|
memcpy(pTable, pNew, sizeof(SCTableObj));
|
||||||
|
|
||||||
pTable->refCount = oldRefCount;
|
pTable->refCount = oldRefCount;
|
||||||
pTable->sql = pNew->sql;
|
pTable->sql = pNew->sql;
|
||||||
|
@ -213,7 +217,7 @@ static int32_t mnodeChildTableActionUpdate(SSdbOper *pOper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeChildTableActionEncode(SSdbOper *pOper) {
|
static int32_t mnodeChildTableActionEncode(SSdbOper *pOper) {
|
||||||
SChildTableObj *pTable = pOper->pObj;
|
SCTableObj *pTable = pOper->pObj;
|
||||||
assert(pTable != NULL && pOper->rowData != NULL);
|
assert(pTable != NULL && pOper->rowData != NULL);
|
||||||
|
|
||||||
int32_t len = strlen(pTable->info.tableId);
|
int32_t len = strlen(pTable->info.tableId);
|
||||||
|
@ -244,7 +248,7 @@ static int32_t mnodeChildTableActionEncode(SSdbOper *pOper) {
|
||||||
|
|
||||||
static int32_t mnodeChildTableActionDecode(SSdbOper *pOper) {
|
static int32_t mnodeChildTableActionDecode(SSdbOper *pOper) {
|
||||||
assert(pOper->rowData != NULL);
|
assert(pOper->rowData != NULL);
|
||||||
SChildTableObj *pTable = calloc(1, sizeof(SChildTableObj));
|
SCTableObj *pTable = calloc(1, sizeof(SCTableObj));
|
||||||
if (pTable == NULL) return TSDB_CODE_MND_OUT_OF_MEMORY;
|
if (pTable == NULL) return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
|
|
||||||
int32_t len = strlen(pOper->rowData);
|
int32_t len = strlen(pOper->rowData);
|
||||||
|
@ -284,7 +288,7 @@ static int32_t mnodeChildTableActionDecode(SSdbOper *pOper) {
|
||||||
|
|
||||||
static int32_t mnodeChildTableActionRestored() {
|
static int32_t mnodeChildTableActionRestored() {
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
SChildTableObj *pTable = NULL;
|
SCTableObj *pTable = NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
pIter = mnodeGetNextChildTable(pIter, &pTable);
|
pIter = mnodeGetNextChildTable(pIter, &pTable);
|
||||||
|
@ -323,7 +327,7 @@ static int32_t mnodeChildTableActionRestored() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTable->info.type == TSDB_CHILD_TABLE) {
|
if (pTable->info.type == TSDB_CHILD_TABLE) {
|
||||||
SSuperTableObj *pSuperTable = mnodeGetSuperTableByUid(pTable->suid);
|
SSTableObj *pSuperTable = mnodeGetSuperTableByUid(pTable->suid);
|
||||||
if (pSuperTable == NULL) {
|
if (pSuperTable == NULL) {
|
||||||
mError("ctable:%s, stable:%" PRIu64 " not exist", pTable->info.tableId, pTable->suid);
|
mError("ctable:%s, stable:%" PRIu64 " not exist", pTable->info.tableId, pTable->suid);
|
||||||
pTable->vgId = 0;
|
pTable->vgId = 0;
|
||||||
|
@ -344,14 +348,14 @@ static int32_t mnodeChildTableActionRestored() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeInitChildTables() {
|
static int32_t mnodeInitChildTables() {
|
||||||
SChildTableObj tObj;
|
SCTableObj tObj;
|
||||||
tsChildTableUpdateSize = (int8_t *)tObj.updateEnd - (int8_t *)&tObj.info.type;
|
tsChildTableUpdateSize = (int8_t *)tObj.updateEnd - (int8_t *)&tObj.info.type;
|
||||||
|
|
||||||
SSdbTableDesc tableDesc = {
|
SSdbTableDesc tableDesc = {
|
||||||
.tableId = SDB_TABLE_CTABLE,
|
.tableId = SDB_TABLE_CTABLE,
|
||||||
.tableName = "ctables",
|
.tableName = "ctables",
|
||||||
.hashSessions = TSDB_DEFAULT_CTABLES_HASH_SIZE,
|
.hashSessions = TSDB_DEFAULT_CTABLES_HASH_SIZE,
|
||||||
.maxRowSize = sizeof(SChildTableObj) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16) + TSDB_TABLE_FNAME_LEN + TSDB_CQ_SQL_SIZE,
|
.maxRowSize = sizeof(SCTableObj) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16) + TSDB_TABLE_FNAME_LEN + TSDB_CQ_SQL_SIZE,
|
||||||
.refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj,
|
.refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj,
|
||||||
.keyType = SDB_KEY_VAR_STRING,
|
.keyType = SDB_KEY_VAR_STRING,
|
||||||
.insertFp = mnodeChildTableActionInsert,
|
.insertFp = mnodeChildTableActionInsert,
|
||||||
|
@ -386,7 +390,7 @@ int64_t mnodeGetChildTableNum() {
|
||||||
return sdbGetNumOfRows(tsChildTableSdb);
|
return sdbGetNumOfRows(tsChildTableSdb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mnodeAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCtable) {
|
static void mnodeAddTableIntoStable(SSTableObj *pStable, SCTableObj *pCtable) {
|
||||||
atomic_add_fetch_32(&pStable->numOfTables, 1);
|
atomic_add_fetch_32(&pStable->numOfTables, 1);
|
||||||
|
|
||||||
if (pStable->vgHash == NULL) {
|
if (pStable->vgHash == NULL) {
|
||||||
|
@ -402,7 +406,7 @@ static void mnodeAddTableIntoStable(SSuperTableObj *pStable, SChildTableObj *pCt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mnodeRemoveTableFromStable(SSuperTableObj *pStable, SChildTableObj *pCtable) {
|
static void mnodeRemoveTableFromStable(SSTableObj *pStable, SCTableObj *pCtable) {
|
||||||
atomic_sub_fetch_32(&pStable->numOfTables, 1);
|
atomic_sub_fetch_32(&pStable->numOfTables, 1);
|
||||||
|
|
||||||
if (pStable->vgHash == NULL) return;
|
if (pStable->vgHash == NULL) return;
|
||||||
|
@ -416,14 +420,14 @@ static void mnodeRemoveTableFromStable(SSuperTableObj *pStable, SChildTableObj *
|
||||||
mnodeDecVgroupRef(pVgroup);
|
mnodeDecVgroupRef(pVgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mnodeDestroySuperTable(SSuperTableObj *pStable) {
|
static void mnodeDestroySuperTable(SSTableObj *pStable) {
|
||||||
if (pStable->vgHash != NULL) {
|
if (pStable->vgHash != NULL) {
|
||||||
taosHashCleanup(pStable->vgHash);
|
taosHashCleanup(pStable->vgHash);
|
||||||
pStable->vgHash = NULL;
|
pStable->vgHash = NULL;
|
||||||
}
|
}
|
||||||
taosTFree(pStable->info.tableId);
|
tfree(pStable->info.tableId);
|
||||||
taosTFree(pStable->schema);
|
tfree(pStable->schema);
|
||||||
taosTFree(pStable);
|
tfree(pStable);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeSuperTableActionDestroy(SSdbOper *pOper) {
|
static int32_t mnodeSuperTableActionDestroy(SSdbOper *pOper) {
|
||||||
|
@ -432,7 +436,7 @@ static int32_t mnodeSuperTableActionDestroy(SSdbOper *pOper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeSuperTableActionInsert(SSdbOper *pOper) {
|
static int32_t mnodeSuperTableActionInsert(SSdbOper *pOper) {
|
||||||
SSuperTableObj *pStable = pOper->pObj;
|
SSTableObj *pStable = pOper->pObj;
|
||||||
SDbObj *pDb = mnodeGetDbByTableId(pStable->info.tableId);
|
SDbObj *pDb = mnodeGetDbByTableId(pStable->info.tableId);
|
||||||
if (pDb != NULL && pDb->status == TSDB_DB_STATUS_READY) {
|
if (pDb != NULL && pDb->status == TSDB_DB_STATUS_READY) {
|
||||||
mnodeAddSuperTableIntoDb(pDb);
|
mnodeAddSuperTableIntoDb(pDb);
|
||||||
|
@ -443,11 +447,11 @@ static int32_t mnodeSuperTableActionInsert(SSdbOper *pOper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeSuperTableActionDelete(SSdbOper *pOper) {
|
static int32_t mnodeSuperTableActionDelete(SSdbOper *pOper) {
|
||||||
SSuperTableObj *pStable = pOper->pObj;
|
SSTableObj *pStable = pOper->pObj;
|
||||||
SDbObj *pDb = mnodeGetDbByTableId(pStable->info.tableId);
|
SDbObj *pDb = mnodeGetDbByTableId(pStable->info.tableId);
|
||||||
if (pDb != NULL) {
|
if (pDb != NULL) {
|
||||||
mnodeRemoveSuperTableFromDb(pDb);
|
mnodeRemoveSuperTableFromDb(pDb);
|
||||||
mnodeDropAllChildTablesInStable((SSuperTableObj *)pStable);
|
mnodeDropAllChildTablesInStable((SSTableObj *)pStable);
|
||||||
}
|
}
|
||||||
mnodeDecDbRef(pDb);
|
mnodeDecDbRef(pDb);
|
||||||
|
|
||||||
|
@ -455,8 +459,8 @@ static int32_t mnodeSuperTableActionDelete(SSdbOper *pOper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeSuperTableActionUpdate(SSdbOper *pOper) {
|
static int32_t mnodeSuperTableActionUpdate(SSdbOper *pOper) {
|
||||||
SSuperTableObj *pNew = pOper->pObj;
|
SSTableObj *pNew = pOper->pObj;
|
||||||
SSuperTableObj *pTable = mnodeGetSuperTable(pNew->info.tableId);
|
SSTableObj *pTable = mnodeGetSuperTable(pNew->info.tableId);
|
||||||
if (pTable != NULL && pTable != pNew) {
|
if (pTable != NULL && pTable != pNew) {
|
||||||
void *oldTableId = pTable->info.tableId;
|
void *oldTableId = pTable->info.tableId;
|
||||||
void *oldSchema = pTable->schema;
|
void *oldSchema = pTable->schema;
|
||||||
|
@ -464,7 +468,7 @@ static int32_t mnodeSuperTableActionUpdate(SSdbOper *pOper) {
|
||||||
int32_t oldRefCount = pTable->refCount;
|
int32_t oldRefCount = pTable->refCount;
|
||||||
int32_t oldNumOfTables = pTable->numOfTables;
|
int32_t oldNumOfTables = pTable->numOfTables;
|
||||||
|
|
||||||
memcpy(pTable, pNew, sizeof(SSuperTableObj));
|
memcpy(pTable, pNew, sizeof(SSTableObj));
|
||||||
|
|
||||||
pTable->vgHash = oldVgHash;
|
pTable->vgHash = oldVgHash;
|
||||||
pTable->refCount = oldRefCount;
|
pTable->refCount = oldRefCount;
|
||||||
|
@ -480,7 +484,7 @@ static int32_t mnodeSuperTableActionUpdate(SSdbOper *pOper) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeSuperTableActionEncode(SSdbOper *pOper) {
|
static int32_t mnodeSuperTableActionEncode(SSdbOper *pOper) {
|
||||||
SSuperTableObj *pStable = pOper->pObj;
|
SSTableObj *pStable = pOper->pObj;
|
||||||
assert(pOper->pObj != NULL && pOper->rowData != NULL);
|
assert(pOper->pObj != NULL && pOper->rowData != NULL);
|
||||||
|
|
||||||
int32_t len = strlen(pStable->info.tableId);
|
int32_t len = strlen(pStable->info.tableId);
|
||||||
|
@ -504,7 +508,7 @@ static int32_t mnodeSuperTableActionEncode(SSdbOper *pOper) {
|
||||||
|
|
||||||
static int32_t mnodeSuperTableActionDecode(SSdbOper *pOper) {
|
static int32_t mnodeSuperTableActionDecode(SSdbOper *pOper) {
|
||||||
assert(pOper->rowData != NULL);
|
assert(pOper->rowData != NULL);
|
||||||
SSuperTableObj *pStable = (SSuperTableObj *) calloc(1, sizeof(SSuperTableObj));
|
SSTableObj *pStable = (SSTableObj *) calloc(1, sizeof(SSTableObj));
|
||||||
if (pStable == NULL) return TSDB_CODE_MND_OUT_OF_MEMORY;
|
if (pStable == NULL) return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
|
|
||||||
int32_t len = strlen(pOper->rowData);
|
int32_t len = strlen(pOper->rowData);
|
||||||
|
@ -537,14 +541,14 @@ static int32_t mnodeSuperTableActionRestored() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeInitSuperTables() {
|
static int32_t mnodeInitSuperTables() {
|
||||||
SSuperTableObj tObj;
|
SSTableObj tObj;
|
||||||
tsSuperTableUpdateSize = (int8_t *)tObj.updateEnd - (int8_t *)&tObj.info.type;
|
tsSuperTableUpdateSize = (int8_t *)tObj.updateEnd - (int8_t *)&tObj.info.type;
|
||||||
|
|
||||||
SSdbTableDesc tableDesc = {
|
SSdbTableDesc tableDesc = {
|
||||||
.tableId = SDB_TABLE_STABLE,
|
.tableId = SDB_TABLE_STABLE,
|
||||||
.tableName = "stables",
|
.tableName = "stables",
|
||||||
.hashSessions = TSDB_DEFAULT_STABLES_HASH_SIZE,
|
.hashSessions = TSDB_DEFAULT_STABLES_HASH_SIZE,
|
||||||
.maxRowSize = sizeof(SSuperTableObj) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16) + TSDB_TABLE_FNAME_LEN,
|
.maxRowSize = sizeof(SSTableObj) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16) + TSDB_TABLE_FNAME_LEN,
|
||||||
.refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj,
|
.refCountPos = (int8_t *)(&tObj.refCount) - (int8_t *)&tObj,
|
||||||
.keyType = SDB_KEY_VAR_STRING,
|
.keyType = SDB_KEY_VAR_STRING,
|
||||||
.insertFp = mnodeSuperTableActionInsert,
|
.insertFp = mnodeSuperTableActionInsert,
|
||||||
|
@ -615,7 +619,7 @@ static void *mnodeGetSuperTable(char *tableId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *mnodeGetSuperTableByUid(uint64_t uid) {
|
static void *mnodeGetSuperTableByUid(uint64_t uid) {
|
||||||
SSuperTableObj *pStable = NULL;
|
SSTableObj *pStable = NULL;
|
||||||
void *pIter = NULL;
|
void *pIter = NULL;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -647,11 +651,11 @@ void *mnodeGetTable(char *tableId) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *mnodeGetNextChildTable(void *pIter, SChildTableObj **pTable) {
|
void *mnodeGetNextChildTable(void *pIter, SCTableObj **pTable) {
|
||||||
return sdbFetchRow(tsChildTableSdb, pIter, (void **)pTable);
|
return sdbFetchRow(tsChildTableSdb, pIter, (void **)pTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *mnodeGetNextSuperTable(void *pIter, SSuperTableObj **pTable) {
|
void *mnodeGetNextSuperTable(void *pIter, SSTableObj **pTable) {
|
||||||
return sdbFetchRow(tsSuperTableSdb, pIter, (void **)pTable);
|
return sdbFetchRow(tsSuperTableSdb, pIter, (void **)pTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -765,12 +769,12 @@ static int32_t mnodeProcessDropTableMsg(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pMsg->pTable->type == TSDB_SUPER_TABLE) {
|
if (pMsg->pTable->type == TSDB_SUPER_TABLE) {
|
||||||
SSuperTableObj *pSTable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pSTable = (SSTableObj *)pMsg->pTable;
|
||||||
mInfo("app:%p:%p, table:%s, start to drop stable, uid:%" PRIu64 ", numOfChildTables:%d, sizeOfVgList:%d",
|
mInfo("app:%p:%p, table:%s, start to drop stable, uid:%" PRIu64 ", numOfChildTables:%d, sizeOfVgList:%d",
|
||||||
pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId, pSTable->uid, pSTable->numOfTables, (int32_t)taosHashGetSize(pSTable->vgHash));
|
pMsg->rpcMsg.ahandle, pMsg, pDrop->tableId, pSTable->uid, pSTable->numOfTables, (int32_t)taosHashGetSize(pSTable->vgHash));
|
||||||
return mnodeProcessDropSuperTableMsg(pMsg);
|
return mnodeProcessDropSuperTableMsg(pMsg);
|
||||||
} else {
|
} else {
|
||||||
SChildTableObj *pCTable = (SChildTableObj *)pMsg->pTable;
|
SCTableObj *pCTable = (SCTableObj *)pMsg->pTable;
|
||||||
mInfo("app:%p:%p, table:%s, start to drop ctable, vgId:%d tid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg,
|
mInfo("app:%p:%p, table:%s, start to drop ctable, vgId:%d tid:%d uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg,
|
||||||
pDrop->tableId, pCTable->vgId, pCTable->tid, pCTable->uid);
|
pDrop->tableId, pCTable->vgId, pCTable->tid, pCTable->uid);
|
||||||
return mnodeProcessDropChildTableMsg(pMsg);
|
return mnodeProcessDropChildTableMsg(pMsg);
|
||||||
|
@ -816,7 +820,7 @@ static int32_t mnodeProcessTableMetaMsg(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
|
static int32_t mnodeCreateSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
SSuperTableObj *pTable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pTable = (SSTableObj *)pMsg->pTable;
|
||||||
assert(pTable);
|
assert(pTable);
|
||||||
|
|
||||||
if (code == TSDB_CODE_SUCCESS) {
|
if (code == TSDB_CODE_SUCCESS) {
|
||||||
|
@ -835,7 +839,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
|
||||||
if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR;
|
if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR;
|
||||||
|
|
||||||
SCMCreateTableMsg *pCreate = pMsg->rpcMsg.pCont;
|
SCMCreateTableMsg *pCreate = pMsg->rpcMsg.pCont;
|
||||||
SSuperTableObj * pStable = calloc(1, sizeof(SSuperTableObj));
|
SSTableObj * pStable = calloc(1, sizeof(SSTableObj));
|
||||||
if (pStable == NULL) {
|
if (pStable == NULL) {
|
||||||
mError("app:%p:%p, table:%s, failed to create, no enough memory", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId);
|
mError("app:%p:%p, table:%s, failed to create, no enough memory", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId);
|
||||||
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
|
@ -878,7 +882,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
|
||||||
.type = SDB_OPER_GLOBAL,
|
.type = SDB_OPER_GLOBAL,
|
||||||
.table = tsSuperTableSdb,
|
.table = tsSuperTableSdb,
|
||||||
.pObj = pStable,
|
.pObj = pStable,
|
||||||
.rowSize = sizeof(SSuperTableObj) + schemaSize,
|
.rowSize = sizeof(SSTableObj) + schemaSize,
|
||||||
.pMsg = pMsg,
|
.pMsg = pMsg,
|
||||||
.writeCb = mnodeCreateSuperTableCb
|
.writeCb = mnodeCreateSuperTableCb
|
||||||
};
|
};
|
||||||
|
@ -894,7 +898,7 @@ static int32_t mnodeProcessCreateSuperTableMsg(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeDropSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
|
static int32_t mnodeDropSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
SSuperTableObj *pTable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pTable = (SSTableObj *)pMsg->pTable;
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
mError("app:%p:%p, stable:%s, failed to drop, sdb error", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId);
|
mError("app:%p:%p, stable:%s, failed to drop, sdb error", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId);
|
||||||
} else {
|
} else {
|
||||||
|
@ -907,7 +911,7 @@ static int32_t mnodeDropSuperTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
|
static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
|
||||||
if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR;
|
if (pMsg == NULL) return TSDB_CODE_MND_APP_ERROR;
|
||||||
|
|
||||||
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pStable = (SSTableObj *)pMsg->pTable;
|
||||||
if (pStable->vgHash != NULL /*pStable->numOfTables != 0*/) {
|
if (pStable->vgHash != NULL /*pStable->numOfTables != 0*/) {
|
||||||
SHashMutableIterator *pIter = taosHashCreateIter(pStable->vgHash);
|
SHashMutableIterator *pIter = taosHashCreateIter(pStable->vgHash);
|
||||||
while (taosHashIterNext(pIter)) {
|
while (taosHashIterNext(pIter)) {
|
||||||
|
@ -950,7 +954,7 @@ static int32_t mnodeProcessDropSuperTableMsg(SMnodeMsg *pMsg) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeFindSuperTableTagIndex(SSuperTableObj *pStable, const char *tagName) {
|
static int32_t mnodeFindSuperTableTagIndex(SSTableObj *pStable, const char *tagName) {
|
||||||
SSchema *schema = (SSchema *) pStable->schema;
|
SSchema *schema = (SSchema *) pStable->schema;
|
||||||
for (int32_t tag = 0; tag < pStable->numOfTags; tag++) {
|
for (int32_t tag = 0; tag < pStable->numOfTags; tag++) {
|
||||||
if (strcasecmp(schema[pStable->numOfColumns + tag].name, tagName) == 0) {
|
if (strcasecmp(schema[pStable->numOfColumns + tag].name, tagName) == 0) {
|
||||||
|
@ -962,7 +966,7 @@ static int32_t mnodeFindSuperTableTagIndex(SSuperTableObj *pStable, const char *
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeAddSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) {
|
static int32_t mnodeAddSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pStable = (SSTableObj *)pMsg->pTable;
|
||||||
mLInfo("app:%p:%p, stable %s, add tag result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
mLInfo("app:%p:%p, stable %s, add tag result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
|
|
||||||
|
@ -970,7 +974,7 @@ static int32_t mnodeAddSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeAddSuperTableTag(SMnodeMsg *pMsg, SSchema schema[], int32_t ntags) {
|
static int32_t mnodeAddSuperTableTag(SMnodeMsg *pMsg, SSchema schema[], int32_t ntags) {
|
||||||
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pStable = (SSTableObj *)pMsg->pTable;
|
||||||
if (pStable->numOfTags + ntags > TSDB_MAX_TAGS) {
|
if (pStable->numOfTags + ntags > TSDB_MAX_TAGS) {
|
||||||
mError("app:%p:%p, stable:%s, add tag, too many tags", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId);
|
mError("app:%p:%p, stable:%s, add tag, too many tags", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId);
|
||||||
return TSDB_CODE_MND_TOO_MANY_TAGS;
|
return TSDB_CODE_MND_TOO_MANY_TAGS;
|
||||||
|
@ -1018,14 +1022,14 @@ static int32_t mnodeAddSuperTableTag(SMnodeMsg *pMsg, SSchema schema[], int32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeDropSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) {
|
static int32_t mnodeDropSuperTableTagCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pStable = (SSTableObj *)pMsg->pTable;
|
||||||
mLInfo("app:%p:%p, stable %s, drop tag result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
mLInfo("app:%p:%p, stable %s, drop tag result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeDropSuperTableTag(SMnodeMsg *pMsg, char *tagName) {
|
static int32_t mnodeDropSuperTableTag(SMnodeMsg *pMsg, char *tagName) {
|
||||||
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pStable = (SSTableObj *)pMsg->pTable;
|
||||||
int32_t col = mnodeFindSuperTableTagIndex(pStable, tagName);
|
int32_t col = mnodeFindSuperTableTagIndex(pStable, tagName);
|
||||||
if (col < 0) {
|
if (col < 0) {
|
||||||
mError("app:%p:%p, stable:%s, drop tag, tag:%s not exist", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
mError("app:%p:%p, stable:%s, drop tag, tag:%s not exist", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
||||||
|
@ -1052,14 +1056,14 @@ static int32_t mnodeDropSuperTableTag(SMnodeMsg *pMsg, char *tagName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeModifySuperTableTagNameCb(SMnodeMsg *pMsg, int32_t code) {
|
static int32_t mnodeModifySuperTableTagNameCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pStable = (SSTableObj *)pMsg->pTable;
|
||||||
mLInfo("app:%p:%p, stable %s, modify tag result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
mLInfo("app:%p:%p, stable %s, modify tag result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeModifySuperTableTagName(SMnodeMsg *pMsg, char *oldTagName, char *newTagName) {
|
static int32_t mnodeModifySuperTableTagName(SMnodeMsg *pMsg, char *oldTagName, char *newTagName) {
|
||||||
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pStable = (SSTableObj *)pMsg->pTable;
|
||||||
int32_t col = mnodeFindSuperTableTagIndex(pStable, oldTagName);
|
int32_t col = mnodeFindSuperTableTagIndex(pStable, oldTagName);
|
||||||
if (col < 0) {
|
if (col < 0) {
|
||||||
mError("app:%p:%p, stable:%s, failed to modify table tag, oldName: %s, newName: %s", pMsg->rpcMsg.ahandle, pMsg,
|
mError("app:%p:%p, stable:%s, failed to modify table tag, oldName: %s, newName: %s", pMsg->rpcMsg.ahandle, pMsg,
|
||||||
|
@ -1095,7 +1099,7 @@ static int32_t mnodeModifySuperTableTagName(SMnodeMsg *pMsg, char *oldTagName, c
|
||||||
return sdbUpdateRow(&oper);
|
return sdbUpdateRow(&oper);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeFindSuperTableColumnIndex(SSuperTableObj *pStable, char *colName) {
|
static int32_t mnodeFindSuperTableColumnIndex(SSTableObj *pStable, char *colName) {
|
||||||
SSchema *schema = (SSchema *) pStable->schema;
|
SSchema *schema = (SSchema *) pStable->schema;
|
||||||
for (int32_t col = 0; col < pStable->numOfColumns; col++) {
|
for (int32_t col = 0; col < pStable->numOfColumns; col++) {
|
||||||
if (strcasecmp(schema[col].name, colName) == 0) {
|
if (strcasecmp(schema[col].name, colName) == 0) {
|
||||||
|
@ -1107,7 +1111,7 @@ static int32_t mnodeFindSuperTableColumnIndex(SSuperTableObj *pStable, char *col
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeAddSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
|
static int32_t mnodeAddSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pStable = (SSTableObj *)pMsg->pTable;
|
||||||
mLInfo("app:%p:%p, stable %s, add column result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
mLInfo("app:%p:%p, stable %s, add column result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
|
@ -1115,7 +1119,7 @@ static int32_t mnodeAddSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
|
|
||||||
static int32_t mnodeAddSuperTableColumn(SMnodeMsg *pMsg, SSchema schema[], int32_t ncols) {
|
static int32_t mnodeAddSuperTableColumn(SMnodeMsg *pMsg, SSchema schema[], int32_t ncols) {
|
||||||
SDbObj *pDb = pMsg->pDb;
|
SDbObj *pDb = pMsg->pDb;
|
||||||
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pStable = (SSTableObj *)pMsg->pTable;
|
||||||
if (ncols <= 0) {
|
if (ncols <= 0) {
|
||||||
mError("app:%p:%p, stable:%s, add column, ncols:%d <= 0", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId, ncols);
|
mError("app:%p:%p, stable:%s, add column, ncols:%d <= 0", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId, ncols);
|
||||||
return TSDB_CODE_MND_APP_ERROR;
|
return TSDB_CODE_MND_APP_ERROR;
|
||||||
|
@ -1170,7 +1174,7 @@ static int32_t mnodeAddSuperTableColumn(SMnodeMsg *pMsg, SSchema schema[], int32
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeDropSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
|
static int32_t mnodeDropSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pStable = (SSTableObj *)pMsg->pTable;
|
||||||
mLInfo("app:%p:%p, stable %s, delete column result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
mLInfo("app:%p:%p, stable %s, delete column result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
|
@ -1178,7 +1182,7 @@ static int32_t mnodeDropSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
|
|
||||||
static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, char *colName) {
|
static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, char *colName) {
|
||||||
SDbObj *pDb = pMsg->pDb;
|
SDbObj *pDb = pMsg->pDb;
|
||||||
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pStable = (SSTableObj *)pMsg->pTable;
|
||||||
int32_t col = mnodeFindSuperTableColumnIndex(pStable, colName);
|
int32_t col = mnodeFindSuperTableColumnIndex(pStable, colName);
|
||||||
if (col <= 0) {
|
if (col <= 0) {
|
||||||
mError("app:%p:%p, stable:%s, drop column, column:%s not exist", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
mError("app:%p:%p, stable:%s, drop column, column:%s not exist", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
||||||
|
@ -1215,14 +1219,14 @@ static int32_t mnodeDropSuperTableColumn(SMnodeMsg *pMsg, char *colName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeChangeSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
|
static int32_t mnodeChangeSuperTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pStable = (SSTableObj *)pMsg->pTable;
|
||||||
mLInfo("app:%p:%p, stable %s, change column result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
mLInfo("app:%p:%p, stable %s, change column result:%s", pMsg->rpcMsg.ahandle, pMsg, pStable->info.tableId,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeChangeSuperTableColumn(SMnodeMsg *pMsg, char *oldName, char *newName) {
|
static int32_t mnodeChangeSuperTableColumn(SMnodeMsg *pMsg, char *oldName, char *newName) {
|
||||||
SSuperTableObj *pStable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pStable = (SSTableObj *)pMsg->pTable;
|
||||||
int32_t col = mnodeFindSuperTableColumnIndex(pStable, oldName);
|
int32_t col = mnodeFindSuperTableColumnIndex(pStable, oldName);
|
||||||
if (col < 0) {
|
if (col < 0) {
|
||||||
mError("app:%p:%p, stable:%s, change column, oldName: %s, newName: %s", pMsg->rpcMsg.ahandle, pMsg,
|
mError("app:%p:%p, stable:%s, change column, oldName: %s, newName: %s", pMsg->rpcMsg.ahandle, pMsg,
|
||||||
|
@ -1321,7 +1325,7 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows,
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
char * pWrite;
|
char * pWrite;
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
SSuperTableObj *pTable = NULL;
|
SSTableObj *pTable = NULL;
|
||||||
char prefix[64] = {0};
|
char prefix[64] = {0};
|
||||||
int32_t prefixLen;
|
int32_t prefixLen;
|
||||||
|
|
||||||
|
@ -1399,7 +1403,7 @@ int32_t mnodeRetrieveShowSuperTables(SShowObj *pShow, char *data, int32_t rows,
|
||||||
void mnodeDropAllSuperTables(SDbObj *pDropDb) {
|
void mnodeDropAllSuperTables(SDbObj *pDropDb) {
|
||||||
void * pIter= NULL;
|
void * pIter= NULL;
|
||||||
int32_t numOfTables = 0;
|
int32_t numOfTables = 0;
|
||||||
SSuperTableObj *pTable = NULL;
|
SSTableObj *pTable = NULL;
|
||||||
|
|
||||||
char prefix[64] = {0};
|
char prefix[64] = {0};
|
||||||
tstrncpy(prefix, pDropDb->name, 64);
|
tstrncpy(prefix, pDropDb->name, 64);
|
||||||
|
@ -1430,7 +1434,7 @@ void mnodeDropAllSuperTables(SDbObj *pDropDb) {
|
||||||
mInfo("db:%s, all super tables:%d is dropped from sdb", pDropDb->name, numOfTables);
|
mInfo("db:%s, all super tables:%d is dropped from sdb", pDropDb->name, numOfTables);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pTable) {
|
static int32_t mnodeSetSchemaFromSuperTable(SSchema *pSchema, SSTableObj *pTable) {
|
||||||
int32_t numOfCols = pTable->numOfColumns + pTable->numOfTags;
|
int32_t numOfCols = pTable->numOfColumns + pTable->numOfTags;
|
||||||
assert(numOfCols <= TSDB_MAX_COLUMNS);
|
assert(numOfCols <= TSDB_MAX_COLUMNS);
|
||||||
|
|
||||||
|
@ -1446,7 +1450,7 @@ static int32_t mnodeSetSchemaFromSuperTable(SSchema *pSchema, SSuperTableObj *pT
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeGetSuperTableMeta(SMnodeMsg *pMsg) {
|
static int32_t mnodeGetSuperTableMeta(SMnodeMsg *pMsg) {
|
||||||
SSuperTableObj *pTable = (SSuperTableObj *)pMsg->pTable;
|
SSTableObj *pTable = (SSTableObj *)pMsg->pTable;
|
||||||
STableMetaMsg *pMeta = rpcMallocCont(sizeof(STableMetaMsg) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16));
|
STableMetaMsg *pMeta = rpcMallocCont(sizeof(STableMetaMsg) + sizeof(SSchema) * (TSDB_MAX_TAGS + TSDB_MAX_COLUMNS + 16));
|
||||||
if (pMeta == NULL) {
|
if (pMeta == NULL) {
|
||||||
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
|
@ -1479,7 +1483,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
|
||||||
int32_t contLen = sizeof(SSTableVgroupRspMsg) + 32 * sizeof(SVgroupMsg) + sizeof(SVgroupsMsg);
|
int32_t contLen = sizeof(SSTableVgroupRspMsg) + 32 * sizeof(SVgroupMsg) + sizeof(SVgroupsMsg);
|
||||||
for (int32_t i = 0; i < numOfTable; ++i) {
|
for (int32_t i = 0; i < numOfTable; ++i) {
|
||||||
char *stableName = (char *)pInfo + sizeof(SSTableVgroupMsg) + (TSDB_TABLE_FNAME_LEN)*i;
|
char *stableName = (char *)pInfo + sizeof(SSTableVgroupMsg) + (TSDB_TABLE_FNAME_LEN)*i;
|
||||||
SSuperTableObj *pTable = mnodeGetSuperTable(stableName);
|
SSTableObj *pTable = mnodeGetSuperTable(stableName);
|
||||||
if (pTable != NULL && pTable->vgHash != NULL) {
|
if (pTable != NULL && pTable->vgHash != NULL) {
|
||||||
contLen += (taosHashGetSize(pTable->vgHash) * sizeof(SVgroupMsg) + sizeof(SVgroupsMsg));
|
contLen += (taosHashGetSize(pTable->vgHash) * sizeof(SVgroupMsg) + sizeof(SVgroupsMsg));
|
||||||
}
|
}
|
||||||
|
@ -1497,7 +1501,7 @@ static int32_t mnodeProcessSuperTableVgroupMsg(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTable; ++i) {
|
for (int32_t i = 0; i < numOfTable; ++i) {
|
||||||
char * stableName = (char *)pInfo + sizeof(SSTableVgroupMsg) + (TSDB_TABLE_FNAME_LEN)*i;
|
char * stableName = (char *)pInfo + sizeof(SSTableVgroupMsg) + (TSDB_TABLE_FNAME_LEN)*i;
|
||||||
SSuperTableObj *pTable = mnodeGetSuperTable(stableName);
|
SSTableObj *pTable = mnodeGetSuperTable(stableName);
|
||||||
if (pTable == NULL) {
|
if (pTable == NULL) {
|
||||||
mError("app:%p:%p, stable:%s, not exist while get stable vgroup info", pMsg->rpcMsg.ahandle, pMsg, stableName);
|
mError("app:%p:%p, stable:%s, not exist while get stable vgroup info", pMsg->rpcMsg.ahandle, pMsg, stableName);
|
||||||
mnodeDecTableRef(pTable);
|
mnodeDecTableRef(pTable);
|
||||||
|
@ -1569,7 +1573,7 @@ static void mnodeProcessDropSuperTableRsp(SRpcMsg *rpcMsg) {
|
||||||
mInfo("drop stable rsp received, result:%s", tstrerror(rpcMsg->code));
|
mInfo("drop stable rsp received, result:%s", tstrerror(rpcMsg->code));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *mnodeBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableObj *pTable) {
|
static void *mnodeBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SCTableObj *pTable) {
|
||||||
STagData * pTagData = NULL;
|
STagData * pTagData = NULL;
|
||||||
int32_t tagDataLen = 0;
|
int32_t tagDataLen = 0;
|
||||||
int32_t totalCols = 0;
|
int32_t totalCols = 0;
|
||||||
|
@ -1643,7 +1647,7 @@ static void *mnodeBuildCreateChildTableMsg(SCMCreateTableMsg *pMsg, SChildTableO
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeDoCreateChildTableFp(SMnodeMsg *pMsg) {
|
static int32_t mnodeDoCreateChildTableFp(SMnodeMsg *pMsg) {
|
||||||
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
|
SCTableObj *pTable = (SCTableObj *)pMsg->pTable;
|
||||||
assert(pTable);
|
assert(pTable);
|
||||||
|
|
||||||
mDebug("app:%p:%p, table:%s, created in mnode, vgId:%d sid:%d, uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg,
|
mDebug("app:%p:%p, table:%s, created in mnode, vgId:%d sid:%d, uid:%" PRIu64, pMsg->rpcMsg.ahandle, pMsg,
|
||||||
|
@ -1669,7 +1673,7 @@ static int32_t mnodeDoCreateChildTableFp(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
|
static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
|
SCTableObj *pTable = (SCTableObj *)pMsg->pTable;
|
||||||
SCMCreateTableMsg *pCreate = pMsg->rpcMsg.pCont;
|
SCMCreateTableMsg *pCreate = pMsg->rpcMsg.pCont;
|
||||||
assert(pTable);
|
assert(pTable);
|
||||||
|
|
||||||
|
@ -1679,12 +1683,12 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
pTable->info.tableId, pMsg->rpcMsg.handle);
|
pTable->info.tableId, pMsg->rpcMsg.handle);
|
||||||
|
|
||||||
pMsg->retry = 0;
|
pMsg->retry = 0;
|
||||||
dnodeReprocessMnodeWriteMsg(pMsg);
|
dnodeReprocessMWriteMsg(pMsg);
|
||||||
} else {
|
} else {
|
||||||
mDebug("app:%p:%p, table:%s, created in dnode, thandle:%p", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
|
mDebug("app:%p:%p, table:%s, created in dnode, thandle:%p", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
|
||||||
pMsg->rpcMsg.handle);
|
pMsg->rpcMsg.handle);
|
||||||
|
|
||||||
dnodeSendRpcMnodeWriteRsp(pMsg, TSDB_CODE_SUCCESS);
|
dnodeSendRpcMWriteRsp(pMsg, TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1699,7 +1703,7 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
static int32_t mnodeDoCreateChildTable(SMnodeMsg *pMsg, int32_t tid) {
|
||||||
SVgObj *pVgroup = pMsg->pVgroup;
|
SVgObj *pVgroup = pMsg->pVgroup;
|
||||||
SCMCreateTableMsg *pCreate = pMsg->rpcMsg.pCont;
|
SCMCreateTableMsg *pCreate = pMsg->rpcMsg.pCont;
|
||||||
SChildTableObj *pTable = calloc(1, sizeof(SChildTableObj));
|
SCTableObj *pTable = calloc(1, sizeof(SCTableObj));
|
||||||
if (pTable == NULL) {
|
if (pTable == NULL) {
|
||||||
mError("app:%p:%p, table:%s, failed to alloc memory", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId);
|
mError("app:%p:%p, table:%s, failed to alloc memory", pMsg->rpcMsg.ahandle, pMsg, pCreate->tableId);
|
||||||
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
return TSDB_CODE_MND_OUT_OF_MEMORY;
|
||||||
|
@ -1842,7 +1846,7 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeSendDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) {
|
static int32_t mnodeSendDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) {
|
||||||
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
|
SCTableObj *pTable = (SCTableObj *)pMsg->pTable;
|
||||||
mLInfo("app:%p:%p, ctable:%s, is dropped from sdb", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId);
|
mLInfo("app:%p:%p, ctable:%s, is dropped from sdb", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId);
|
||||||
|
|
||||||
SMDDropTableMsg *pDrop = rpcMallocCont(sizeof(SMDDropTableMsg));
|
SMDDropTableMsg *pDrop = rpcMallocCont(sizeof(SMDDropTableMsg));
|
||||||
|
@ -1880,7 +1884,7 @@ static int32_t mnodeSendDropChildTableMsg(SMnodeMsg *pMsg, bool needReturn) {
|
||||||
|
|
||||||
static int32_t mnodeDropChildTableCb(SMnodeMsg *pMsg, int32_t code) {
|
static int32_t mnodeDropChildTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
|
SCTableObj *pTable = (SCTableObj *)pMsg->pTable;
|
||||||
mError("app:%p:%p, ctable:%s, failed to drop, sdb error", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId);
|
mError("app:%p:%p, ctable:%s, failed to drop, sdb error", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -1889,7 +1893,7 @@ static int32_t mnodeDropChildTableCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
|
static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
|
||||||
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
|
SCTableObj *pTable = (SCTableObj *)pMsg->pTable;
|
||||||
if (pMsg->pVgroup == NULL) pMsg->pVgroup = mnodeGetVgroup(pTable->vgId);
|
if (pMsg->pVgroup == NULL) pMsg->pVgroup = mnodeGetVgroup(pTable->vgId);
|
||||||
if (pMsg->pVgroup == NULL) {
|
if (pMsg->pVgroup == NULL) {
|
||||||
mError("app:%p:%p, table:%s, failed to drop ctable, vgroup not exist", pMsg->rpcMsg.ahandle, pMsg,
|
mError("app:%p:%p, table:%s, failed to drop ctable, vgroup not exist", pMsg->rpcMsg.ahandle, pMsg,
|
||||||
|
@ -1914,7 +1918,7 @@ static int32_t mnodeProcessDropChildTableMsg(SMnodeMsg *pMsg) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeFindNormalTableColumnIndex(SChildTableObj *pTable, char *colName) {
|
static int32_t mnodeFindNormalTableColumnIndex(SCTableObj *pTable, char *colName) {
|
||||||
SSchema *schema = (SSchema *) pTable->schema;
|
SSchema *schema = (SSchema *) pTable->schema;
|
||||||
for (int32_t col = 0; col < pTable->numOfColumns; col++) {
|
for (int32_t col = 0; col < pTable->numOfColumns; col++) {
|
||||||
if (strcasecmp(schema[col].name, colName) == 0) {
|
if (strcasecmp(schema[col].name, colName) == 0) {
|
||||||
|
@ -1926,7 +1930,7 @@ static int32_t mnodeFindNormalTableColumnIndex(SChildTableObj *pTable, char *col
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeAlterNormalTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
|
static int32_t mnodeAlterNormalTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
|
SCTableObj *pTable = (SCTableObj *)pMsg->pTable;
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
mError("app:%p:%p, ctable %s, failed to alter column, reason:%s", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
|
mError("app:%p:%p, ctable %s, failed to alter column, reason:%s", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
|
||||||
tstrerror(code));
|
tstrerror(code));
|
||||||
|
@ -1965,7 +1969,7 @@ static int32_t mnodeAlterNormalTableColumnCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int32_t ncols) {
|
static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int32_t ncols) {
|
||||||
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
|
SCTableObj *pTable = (SCTableObj *)pMsg->pTable;
|
||||||
SDbObj *pDb = pMsg->pDb;
|
SDbObj *pDb = pMsg->pDb;
|
||||||
if (ncols <= 0) {
|
if (ncols <= 0) {
|
||||||
mError("app:%p:%p, ctable:%s, add column, ncols:%d <= 0", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId, ncols);
|
mError("app:%p:%p, ctable:%s, add column, ncols:%d <= 0", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId, ncols);
|
||||||
|
@ -2014,7 +2018,7 @@ static int32_t mnodeAddNormalTableColumn(SMnodeMsg *pMsg, SSchema schema[], int3
|
||||||
|
|
||||||
static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) {
|
static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) {
|
||||||
SDbObj *pDb = pMsg->pDb;
|
SDbObj *pDb = pMsg->pDb;
|
||||||
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
|
SCTableObj *pTable = (SCTableObj *)pMsg->pTable;
|
||||||
int32_t col = mnodeFindNormalTableColumnIndex(pTable, colName);
|
int32_t col = mnodeFindNormalTableColumnIndex(pTable, colName);
|
||||||
if (col <= 0) {
|
if (col <= 0) {
|
||||||
mError("app:%p:%p, ctable:%s, drop column, column:%s not exist", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
|
mError("app:%p:%p, ctable:%s, drop column, column:%s not exist", pMsg->rpcMsg.ahandle, pMsg, pTable->info.tableId,
|
||||||
|
@ -2046,7 +2050,7 @@ static int32_t mnodeDropNormalTableColumn(SMnodeMsg *pMsg, char *colName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeChangeNormalTableColumn(SMnodeMsg *pMsg, char *oldName, char *newName) {
|
static int32_t mnodeChangeNormalTableColumn(SMnodeMsg *pMsg, char *oldName, char *newName) {
|
||||||
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
|
SCTableObj *pTable = (SCTableObj *)pMsg->pTable;
|
||||||
int32_t col = mnodeFindNormalTableColumnIndex(pTable, oldName);
|
int32_t col = mnodeFindNormalTableColumnIndex(pTable, oldName);
|
||||||
if (col < 0) {
|
if (col < 0) {
|
||||||
mError("app:%p:%p, ctable:%s, change column, oldName: %s, newName: %s", pMsg->rpcMsg.ahandle, pMsg,
|
mError("app:%p:%p, ctable:%s, change column, oldName: %s, newName: %s", pMsg->rpcMsg.ahandle, pMsg,
|
||||||
|
@ -2082,7 +2086,7 @@ static int32_t mnodeChangeNormalTableColumn(SMnodeMsg *pMsg, char *oldName, char
|
||||||
return sdbUpdateRow(&oper);
|
return sdbUpdateRow(&oper);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeSetSchemaFromNormalTable(SSchema *pSchema, SChildTableObj *pTable) {
|
static int32_t mnodeSetSchemaFromNormalTable(SSchema *pSchema, SCTableObj *pTable) {
|
||||||
int32_t numOfCols = pTable->numOfColumns;
|
int32_t numOfCols = pTable->numOfColumns;
|
||||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||||
strcpy(pSchema->name, pTable->schema[i].name);
|
strcpy(pSchema->name, pTable->schema[i].name);
|
||||||
|
@ -2097,7 +2101,7 @@ static int32_t mnodeSetSchemaFromNormalTable(SSchema *pSchema, SChildTableObj *p
|
||||||
|
|
||||||
static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) {
|
static int32_t mnodeDoGetChildTableMeta(SMnodeMsg *pMsg, STableMetaMsg *pMeta) {
|
||||||
SDbObj *pDb = pMsg->pDb;
|
SDbObj *pDb = pMsg->pDb;
|
||||||
SChildTableObj *pTable = (SChildTableObj *)pMsg->pTable;
|
SCTableObj *pTable = (SCTableObj *)pMsg->pTable;
|
||||||
|
|
||||||
pMeta->uid = htobe64(pTable->uid);
|
pMeta->uid = htobe64(pTable->uid);
|
||||||
pMeta->tid = htonl(pTable->tid);
|
pMeta->tid = htonl(pTable->tid);
|
||||||
|
@ -2156,7 +2160,7 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t contLen = sizeof(SCMCreateTableMsg) + offsetof(STagData, data) + tagLen;
|
int32_t contLen = sizeof(SCMCreateTableMsg) + offsetof(STagData, data) + tagLen;
|
||||||
SCMCreateTableMsg *pCreateMsg = rpcMallocCont(contLen);
|
SCMCreateTableMsg *pCreateMsg = calloc(1, contLen);
|
||||||
if (pCreateMsg == NULL) {
|
if (pCreateMsg == NULL) {
|
||||||
mError("app:%p:%p, table:%s, failed to create table while get meta info, no enough memory", pMsg->rpcMsg.ahandle,
|
mError("app:%p:%p, table:%s, failed to create table while get meta info, no enough memory", pMsg->rpcMsg.ahandle,
|
||||||
pMsg, pInfo->tableId);
|
pMsg, pInfo->tableId);
|
||||||
|
@ -2174,7 +2178,9 @@ static int32_t mnodeAutoCreateChildTable(SMnodeMsg *pMsg) {
|
||||||
mDebug("app:%p:%p, table:%s, start to create on demand, tagLen:%d stable:%s",
|
mDebug("app:%p:%p, table:%s, start to create on demand, tagLen:%d stable:%s",
|
||||||
pMsg->rpcMsg.ahandle, pMsg, pInfo->tableId, tagLen, pTags->name);
|
pMsg->rpcMsg.ahandle, pMsg, pInfo->tableId, tagLen, pTags->name);
|
||||||
|
|
||||||
rpcFreeCont(pMsg->rpcMsg.pCont);
|
if (pMsg->rpcMsg.pCont != pMsg->pCont) {
|
||||||
|
tfree(pMsg->rpcMsg.pCont);
|
||||||
|
}
|
||||||
pMsg->rpcMsg.msgType = TSDB_MSG_TYPE_CM_CREATE_TABLE;
|
pMsg->rpcMsg.msgType = TSDB_MSG_TYPE_CM_CREATE_TABLE;
|
||||||
pMsg->rpcMsg.pCont = pCreateMsg;
|
pMsg->rpcMsg.pCont = pCreateMsg;
|
||||||
pMsg->rpcMsg.contLen = contLen;
|
pMsg->rpcMsg.contLen = contLen;
|
||||||
|
@ -2203,7 +2209,7 @@ static int32_t mnodeGetChildTableMeta(SMnodeMsg *pMsg) {
|
||||||
void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup) {
|
void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup) {
|
||||||
void * pIter = NULL;
|
void * pIter = NULL;
|
||||||
int32_t numOfTables = 0;
|
int32_t numOfTables = 0;
|
||||||
SChildTableObj *pTable = NULL;
|
SCTableObj *pTable = NULL;
|
||||||
|
|
||||||
mInfo("vgId:%d, all child tables will be dropped from sdb", pVgroup->vgId);
|
mInfo("vgId:%d, all child tables will be dropped from sdb", pVgroup->vgId);
|
||||||
|
|
||||||
|
@ -2231,7 +2237,7 @@ void mnodeDropAllChildTablesInVgroups(SVgObj *pVgroup) {
|
||||||
void mnodeDropAllChildTables(SDbObj *pDropDb) {
|
void mnodeDropAllChildTables(SDbObj *pDropDb) {
|
||||||
void * pIter = NULL;
|
void * pIter = NULL;
|
||||||
int32_t numOfTables = 0;
|
int32_t numOfTables = 0;
|
||||||
SChildTableObj *pTable = NULL;
|
SCTableObj *pTable = NULL;
|
||||||
|
|
||||||
char prefix[64] = {0};
|
char prefix[64] = {0};
|
||||||
tstrncpy(prefix, pDropDb->name, 64);
|
tstrncpy(prefix, pDropDb->name, 64);
|
||||||
|
@ -2261,10 +2267,10 @@ void mnodeDropAllChildTables(SDbObj *pDropDb) {
|
||||||
mInfo("db:%s, all child tables:%d is dropped from sdb", pDropDb->name, numOfTables);
|
mInfo("db:%s, all child tables:%d is dropped from sdb", pDropDb->name, numOfTables);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mnodeDropAllChildTablesInStable(SSuperTableObj *pStable) {
|
static void mnodeDropAllChildTablesInStable(SSTableObj *pStable) {
|
||||||
void * pIter = NULL;
|
void * pIter = NULL;
|
||||||
int32_t numOfTables = 0;
|
int32_t numOfTables = 0;
|
||||||
SChildTableObj *pTable = NULL;
|
SCTableObj *pTable = NULL;
|
||||||
|
|
||||||
mInfo("stable:%s uid:%" PRIu64 ", all child tables:%d will be dropped from sdb", pStable->info.tableId, pStable->uid,
|
mInfo("stable:%s uid:%" PRIu64 ", all child tables:%d will be dropped from sdb", pStable->info.tableId, pStable->uid,
|
||||||
pStable->numOfTables);
|
pStable->numOfTables);
|
||||||
|
@ -2292,11 +2298,11 @@ static void mnodeDropAllChildTablesInStable(SSuperTableObj *pStable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static SChildTableObj* mnodeGetTableByPos(int32_t vnode, int32_t tid) {
|
static SCTableObj* mnodeGetTableByPos(int32_t vnode, int32_t tid) {
|
||||||
SVgObj *pVgroup = mnodeGetVgroup(vnode);
|
SVgObj *pVgroup = mnodeGetVgroup(vnode);
|
||||||
if (pVgroup == NULL) return NULL;
|
if (pVgroup == NULL) return NULL;
|
||||||
|
|
||||||
SChildTableObj *pTable = pVgroup->tableList[tid - 1];
|
SCTableObj *pTable = pVgroup->tableList[tid - 1];
|
||||||
mnodeIncTableRef((STableObj *)pTable);
|
mnodeIncTableRef((STableObj *)pTable);
|
||||||
|
|
||||||
mnodeDecVgroupRef(pVgroup);
|
mnodeDecVgroupRef(pVgroup);
|
||||||
|
@ -2314,7 +2320,7 @@ static int32_t mnodeProcessTableCfgMsg(SMnodeMsg *pMsg) {
|
||||||
mDebug("app:%p:%p, dnode:%d, vgId:%d sid:%d, receive table config msg", pMsg->rpcMsg.ahandle, pMsg, pCfg->dnodeId,
|
mDebug("app:%p:%p, dnode:%d, vgId:%d sid:%d, receive table config msg", pMsg->rpcMsg.ahandle, pMsg, pCfg->dnodeId,
|
||||||
pCfg->vgId, pCfg->sid);
|
pCfg->vgId, pCfg->sid);
|
||||||
|
|
||||||
SChildTableObj *pTable = mnodeGetTableByPos(pCfg->vgId, pCfg->sid);
|
SCTableObj *pTable = mnodeGetTableByPos(pCfg->vgId, pCfg->sid);
|
||||||
if (pTable == NULL) {
|
if (pTable == NULL) {
|
||||||
mError("app:%p:%p, dnode:%d, vgId:%d sid:%d, table not found", pMsg->rpcMsg.ahandle, pMsg, pCfg->dnodeId,
|
mError("app:%p:%p, dnode:%d, vgId:%d sid:%d, table not found", pMsg->rpcMsg.ahandle, pMsg, pCfg->dnodeId,
|
||||||
pCfg->vgId, pCfg->sid);
|
pCfg->vgId, pCfg->sid);
|
||||||
|
@ -2322,7 +2328,7 @@ static int32_t mnodeProcessTableCfgMsg(SMnodeMsg *pMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
SMDCreateTableMsg *pCreate = NULL;
|
SMDCreateTableMsg *pCreate = NULL;
|
||||||
pCreate = mnodeBuildCreateChildTableMsg(NULL, (SChildTableObj *)pTable);
|
pCreate = mnodeBuildCreateChildTableMsg(NULL, (SCTableObj *)pTable);
|
||||||
mnodeDecTableRef(pTable);
|
mnodeDecTableRef(pTable);
|
||||||
|
|
||||||
if (pCreate == NULL) return terrno;
|
if (pCreate == NULL) return terrno;
|
||||||
|
@ -2340,7 +2346,7 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
|
||||||
SMnodeMsg *mnodeMsg = rpcMsg->ahandle;
|
SMnodeMsg *mnodeMsg = rpcMsg->ahandle;
|
||||||
mnodeMsg->received++;
|
mnodeMsg->received++;
|
||||||
|
|
||||||
SChildTableObj *pTable = (SChildTableObj *)mnodeMsg->pTable;
|
SCTableObj *pTable = (SCTableObj *)mnodeMsg->pTable;
|
||||||
assert(pTable);
|
assert(pTable);
|
||||||
|
|
||||||
mInfo("app:%p:%p, table:%s, drop table rsp received, vgId:%d sid:%d uid:%" PRIu64 ", thandle:%p result:%s",
|
mInfo("app:%p:%p, table:%s, drop table rsp received, vgId:%d sid:%d uid:%" PRIu64 ", thandle:%p result:%s",
|
||||||
|
@ -2351,14 +2357,14 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
|
||||||
mError("app:%p:%p, table:%s, failed to drop in dnode, vgId:%d sid:%d uid:%" PRIu64 ", reason:%s",
|
mError("app:%p:%p, table:%s, failed to drop in dnode, vgId:%d sid:%d uid:%" PRIu64 ", reason:%s",
|
||||||
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid,
|
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid,
|
||||||
tstrerror(rpcMsg->code));
|
tstrerror(rpcMsg->code));
|
||||||
dnodeSendRpcMnodeWriteRsp(mnodeMsg, rpcMsg->code);
|
dnodeSendRpcMWriteRsp(mnodeMsg, rpcMsg->code);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mnodeMsg->pVgroup == NULL) mnodeMsg->pVgroup = mnodeGetVgroup(pTable->vgId);
|
if (mnodeMsg->pVgroup == NULL) mnodeMsg->pVgroup = mnodeGetVgroup(pTable->vgId);
|
||||||
if (mnodeMsg->pVgroup == NULL) {
|
if (mnodeMsg->pVgroup == NULL) {
|
||||||
mError("app:%p:%p, table:%s, failed to get vgroup", mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId);
|
mError("app:%p:%p, table:%s, failed to get vgroup", mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId);
|
||||||
dnodeSendRpcMnodeWriteRsp(mnodeMsg, TSDB_CODE_MND_VGROUP_NOT_EXIST);
|
dnodeSendRpcMWriteRsp(mnodeMsg, TSDB_CODE_MND_VGROUP_NOT_EXIST);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2368,7 +2374,7 @@ static void mnodeProcessDropChildTableRsp(SRpcMsg *rpcMsg) {
|
||||||
mnodeDropVgroup(mnodeMsg->pVgroup, NULL);
|
mnodeDropVgroup(mnodeMsg->pVgroup, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
dnodeSendRpcMnodeWriteRsp(mnodeMsg, TSDB_CODE_SUCCESS);
|
dnodeSendRpcMWriteRsp(mnodeMsg, TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2381,7 +2387,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
|
||||||
SMnodeMsg *mnodeMsg = rpcMsg->ahandle;
|
SMnodeMsg *mnodeMsg = rpcMsg->ahandle;
|
||||||
mnodeMsg->received++;
|
mnodeMsg->received++;
|
||||||
|
|
||||||
SChildTableObj *pTable = (SChildTableObj *)mnodeMsg->pTable;
|
SCTableObj *pTable = (SCTableObj *)mnodeMsg->pTable;
|
||||||
assert(pTable);
|
assert(pTable);
|
||||||
|
|
||||||
// If the table is deleted by another thread during creation, stop creating and send drop msg to vnode
|
// If the table is deleted by another thread during creation, stop creating and send drop msg to vnode
|
||||||
|
@ -2399,7 +2405,7 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
|
||||||
|
|
||||||
mnodeSendDropChildTableMsg(mnodeMsg, false);
|
mnodeSendDropChildTableMsg(mnodeMsg, false);
|
||||||
rpcMsg->code = TSDB_CODE_SUCCESS;
|
rpcMsg->code = TSDB_CODE_SUCCESS;
|
||||||
dnodeSendRpcMnodeWriteRsp(mnodeMsg, rpcMsg->code);
|
dnodeSendRpcMWriteRsp(mnodeMsg, rpcMsg->code);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2416,25 +2422,32 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) {
|
||||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
mnodeMsg->pTable = NULL;
|
mnodeMsg->pTable = NULL;
|
||||||
mnodeDestroyChildTable(pTable);
|
mnodeDestroyChildTable(pTable);
|
||||||
dnodeSendRpcMnodeWriteRsp(mnodeMsg, code);
|
dnodeSendRpcMWriteRsp(mnodeMsg, code);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mnodeMsg->retry++ < 10) {
|
mnodeMsg->retry++;
|
||||||
|
int32_t sec = taosGetTimestampSec();
|
||||||
|
if (mnodeMsg->retry < CREATE_CTABLE_RETRY_TIMES && ABS(sec - mnodeMsg->incomingTs) < CREATE_CTABLE_RETRY_SEC) {
|
||||||
mDebug("app:%p:%p, table:%s, create table rsp received, need retry, times:%d vgId:%d sid:%d uid:%" PRIu64
|
mDebug("app:%p:%p, table:%s, create table rsp received, need retry, times:%d vgId:%d sid:%d uid:%" PRIu64
|
||||||
" result:%s thandle:%p",
|
" result:%s thandle:%p",
|
||||||
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, mnodeMsg->retry, pTable->vgId, pTable->tid,
|
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, mnodeMsg->retry, pTable->vgId, pTable->tid,
|
||||||
pTable->uid, tstrerror(rpcMsg->code), mnodeMsg->rpcMsg.handle);
|
pTable->uid, tstrerror(rpcMsg->code), mnodeMsg->rpcMsg.handle);
|
||||||
|
|
||||||
dnodeDelayReprocessMnodeWriteMsg(mnodeMsg);
|
dnodeDelayReprocessMWriteMsg(mnodeMsg);
|
||||||
} else {
|
} else {
|
||||||
mError("app:%p:%p, table:%s, failed to create in dnode, vgId:%d sid:%d uid:%" PRIu64 ", result:%s thandle:%p",
|
mError("app:%p:%p, table:%s, failed to create in dnode, vgId:%d sid:%d uid:%" PRIu64
|
||||||
|
", result:%s thandle:%p incomingTs:%d curTs:%d retryTimes:%d",
|
||||||
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid,
|
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid,
|
||||||
tstrerror(rpcMsg->code), mnodeMsg->rpcMsg.handle);
|
tstrerror(rpcMsg->code), mnodeMsg->rpcMsg.handle, mnodeMsg->incomingTs, sec, mnodeMsg->retry);
|
||||||
|
|
||||||
SSdbOper oper = {.type = SDB_OPER_GLOBAL, .table = tsChildTableSdb, .pObj = pTable};
|
SSdbOper oper = {.type = SDB_OPER_GLOBAL, .table = tsChildTableSdb, .pObj = pTable};
|
||||||
sdbDeleteRow(&oper);
|
sdbDeleteRow(&oper);
|
||||||
|
|
||||||
dnodeSendRpcMnodeWriteRsp(mnodeMsg, rpcMsg->code);
|
if (rpcMsg->code == TSDB_CODE_APP_NOT_READY) {
|
||||||
|
//Avoid retry again in client
|
||||||
|
rpcMsg->code = TSDB_CODE_MND_VGROUP_NOT_READY;
|
||||||
|
}
|
||||||
|
dnodeSendRpcMWriteRsp(mnodeMsg, rpcMsg->code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2445,25 +2458,25 @@ static void mnodeProcessAlterTableRsp(SRpcMsg *rpcMsg) {
|
||||||
SMnodeMsg *mnodeMsg = rpcMsg->ahandle;
|
SMnodeMsg *mnodeMsg = rpcMsg->ahandle;
|
||||||
mnodeMsg->received++;
|
mnodeMsg->received++;
|
||||||
|
|
||||||
SChildTableObj *pTable = (SChildTableObj *)mnodeMsg->pTable;
|
SCTableObj *pTable = (SCTableObj *)mnodeMsg->pTable;
|
||||||
assert(pTable);
|
assert(pTable);
|
||||||
|
|
||||||
if (rpcMsg->code == TSDB_CODE_SUCCESS || rpcMsg->code == TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
|
if (rpcMsg->code == TSDB_CODE_SUCCESS || rpcMsg->code == TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
|
||||||
mDebug("app:%p:%p, ctable:%s, altered in dnode, thandle:%p result:%s", mnodeMsg->rpcMsg.ahandle, mnodeMsg,
|
mDebug("app:%p:%p, ctable:%s, altered in dnode, thandle:%p result:%s", mnodeMsg->rpcMsg.ahandle, mnodeMsg,
|
||||||
pTable->info.tableId, mnodeMsg->rpcMsg.handle, tstrerror(rpcMsg->code));
|
pTable->info.tableId, mnodeMsg->rpcMsg.handle, tstrerror(rpcMsg->code));
|
||||||
|
|
||||||
dnodeSendRpcMnodeWriteRsp(mnodeMsg, TSDB_CODE_SUCCESS);
|
dnodeSendRpcMWriteRsp(mnodeMsg, TSDB_CODE_SUCCESS);
|
||||||
} else {
|
} else {
|
||||||
if (mnodeMsg->retry++ < 3) {
|
if (mnodeMsg->retry++ < ALTER_CTABLE_RETRY_TIMES) {
|
||||||
mDebug("app:%p:%p, table:%s, alter table rsp received, need retry, times:%d result:%s thandle:%p",
|
mDebug("app:%p:%p, table:%s, alter table rsp received, need retry, times:%d result:%s thandle:%p",
|
||||||
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, mnodeMsg->retry, tstrerror(rpcMsg->code),
|
mnodeMsg->rpcMsg.ahandle, mnodeMsg, pTable->info.tableId, mnodeMsg->retry, tstrerror(rpcMsg->code),
|
||||||
mnodeMsg->rpcMsg.handle);
|
mnodeMsg->rpcMsg.handle);
|
||||||
|
|
||||||
dnodeDelayReprocessMnodeWriteMsg(mnodeMsg);
|
dnodeDelayReprocessMWriteMsg(mnodeMsg);
|
||||||
} else {
|
} else {
|
||||||
mError("app:%p:%p, table:%s, failed to alter in dnode, result:%s thandle:%p", mnodeMsg->rpcMsg.ahandle, mnodeMsg,
|
mError("app:%p:%p, table:%s, failed to alter in dnode, result:%s thandle:%p", mnodeMsg->rpcMsg.ahandle, mnodeMsg,
|
||||||
pTable->info.tableId, tstrerror(rpcMsg->code), mnodeMsg->rpcMsg.handle);
|
pTable->info.tableId, tstrerror(rpcMsg->code), mnodeMsg->rpcMsg.handle);
|
||||||
dnodeSendRpcMnodeWriteRsp(mnodeMsg, rpcMsg->code);
|
dnodeSendRpcMWriteRsp(mnodeMsg, rpcMsg->code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2483,7 +2496,7 @@ static int32_t mnodeProcessMultiTableMetaMsg(SMnodeMsg *pMsg) {
|
||||||
|
|
||||||
for (int32_t t = 0; t < pInfo->numOfTables; ++t) {
|
for (int32_t t = 0; t < pInfo->numOfTables; ++t) {
|
||||||
char * tableId = (char *)(pInfo->tableIds + t * TSDB_TABLE_FNAME_LEN);
|
char * tableId = (char *)(pInfo->tableIds + t * TSDB_TABLE_FNAME_LEN);
|
||||||
SChildTableObj *pTable = mnodeGetChildTable(tableId);
|
SCTableObj *pTable = mnodeGetChildTable(tableId);
|
||||||
if (pTable == NULL) continue;
|
if (pTable == NULL) continue;
|
||||||
|
|
||||||
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableId(tableId);
|
if (pMsg->pDb == NULL) pMsg->pDb = mnodeGetDbByTableId(tableId);
|
||||||
|
@ -2607,7 +2620,7 @@ static int32_t mnodeRetrieveShowTables(SShowObj *pShow, char *data, int32_t rows
|
||||||
|
|
||||||
int32_t cols = 0;
|
int32_t cols = 0;
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SChildTableObj *pTable = NULL;
|
SCTableObj *pTable = NULL;
|
||||||
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
||||||
|
|
||||||
char prefix[64] = {0};
|
char prefix[64] = {0};
|
||||||
|
@ -2843,7 +2856,7 @@ static int32_t mnodeRetrieveStreamTables(SShowObj *pShow, char *data, int32_t ro
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t numOfRows = 0;
|
int32_t numOfRows = 0;
|
||||||
SChildTableObj *pTable = NULL;
|
SCTableObj *pTable = NULL;
|
||||||
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
SPatternCompareInfo info = PATTERN_COMPARE_INFO_INITIALIZER;
|
||||||
|
|
||||||
char prefix[64] = {0};
|
char prefix[64] = {0};
|
||||||
|
|
|
@ -43,7 +43,7 @@ static int32_t mnodeProcessDropUserMsg(SMnodeMsg *pMsg);
|
||||||
static int32_t mnodeProcessAuthMsg(SMnodeMsg *pMsg);
|
static int32_t mnodeProcessAuthMsg(SMnodeMsg *pMsg);
|
||||||
|
|
||||||
static int32_t mnodeUserActionDestroy(SSdbOper *pOper) {
|
static int32_t mnodeUserActionDestroy(SSdbOper *pOper) {
|
||||||
taosTFree(pOper->pObj);
|
tfree(pOper->pObj);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) {
|
||||||
code = sdbInsertRow(&oper);
|
code = sdbInsertRow(&oper);
|
||||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
mError("user:%s, failed to create by %s, reason:%s", pUser->user, mnodeGetUserFromMsg(pMsg), tstrerror(code));
|
mError("user:%s, failed to create by %s, reason:%s", pUser->user, mnodeGetUserFromMsg(pMsg), tstrerror(code));
|
||||||
taosTFree(pUser);
|
tfree(pUser);
|
||||||
} else {
|
} else {
|
||||||
mLInfo("user:%s, is created by %s", pUser->user, mnodeGetUserFromMsg(pMsg));
|
mLInfo("user:%s, is created by %s", pUser->user, mnodeGetUserFromMsg(pMsg));
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ static void mnodeDestroyVgroup(SVgObj *pVgroup) {
|
||||||
pVgroup->idPool = NULL;
|
pVgroup->idPool = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pVgroup);
|
tfree(pVgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeVgroupActionDestroy(SSdbOper *pOper) {
|
static int32_t mnodeVgroupActionDestroy(SSdbOper *pOper) {
|
||||||
|
@ -529,7 +529,7 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .table = tsVgroupSdb};
|
SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .table = tsVgroupSdb};
|
||||||
(void)sdbUpdateRow(&desc);
|
(void)sdbUpdateRow(&desc);
|
||||||
|
|
||||||
dnodeReprocessMnodeWriteMsg(pMsg);
|
dnodeReprocessMWriteMsg(pMsg);
|
||||||
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
// if (pVgroup->status == TAOS_VG_STATUS_CREATING || pVgroup->status == TAOS_VG_STATUS_READY) {
|
// if (pVgroup->status == TAOS_VG_STATUS_CREATING || pVgroup->status == TAOS_VG_STATUS_READY) {
|
||||||
// mInfo("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d", pMsg->rpcMsg.ahandle, pMsg, pVgroup->vgId,
|
// mInfo("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d", pMsg->rpcMsg.ahandle, pMsg, pVgroup->vgId,
|
||||||
|
@ -537,7 +537,7 @@ static int32_t mnodeCreateVgroupCb(SMnodeMsg *pMsg, int32_t code) {
|
||||||
// pVgroup->status = TAOS_VG_STATUS_READY;
|
// pVgroup->status = TAOS_VG_STATUS_READY;
|
||||||
// SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .table = tsVgroupSdb};
|
// SSdbOper desc = {.type = SDB_OPER_GLOBAL, .pObj = pVgroup, .table = tsVgroupSdb};
|
||||||
// (void)sdbUpdateRow(&desc);
|
// (void)sdbUpdateRow(&desc);
|
||||||
// dnodeReprocessMnodeWriteMsg(pMsg);
|
// dnodeReprocessMWriteMsg(pMsg);
|
||||||
// return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
// return TSDB_CODE_MND_ACTION_IN_PROGRESS;
|
||||||
// } else {
|
// } else {
|
||||||
// mError("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d, but vgroup is dropping", pMsg->rpcMsg.ahandle,
|
// mError("app:%p:%p, vgId:%d, is created in sdb, db:%s replica:%d, but vgroup is dropping", pMsg->rpcMsg.ahandle,
|
||||||
|
@ -694,7 +694,7 @@ static bool mnodeFilterVgroups(SVgObj *pVgroup, STableObj *pTable) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SChildTableObj *pCTable = (SChildTableObj *)pTable;
|
SCTableObj *pCTable = (SCTableObj *)pTable;
|
||||||
if (pVgroup->vgId == pCTable->vgId) {
|
if (pVgroup->vgId == pCTable->vgId) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -791,7 +791,7 @@ static int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, v
|
||||||
return numOfRows;
|
return numOfRows;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable) {
|
void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SCTableObj *pTable) {
|
||||||
int32_t idPoolSize = taosIdPoolMaxSize(pVgroup->idPool);
|
int32_t idPoolSize = taosIdPoolMaxSize(pVgroup->idPool);
|
||||||
if (pTable->tid > idPoolSize) {
|
if (pTable->tid > idPoolSize) {
|
||||||
mnodeAllocVgroupIdPool(pVgroup);
|
mnodeAllocVgroupIdPool(pVgroup);
|
||||||
|
@ -807,7 +807,7 @@ void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SChildTableObj *pTable) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void mnodeRemoveTableFromVgroup(SVgObj *pVgroup, SChildTableObj *pTable) {
|
void mnodeRemoveTableFromVgroup(SVgObj *pVgroup, SCTableObj *pTable) {
|
||||||
if (pTable->tid >= 1) {
|
if (pTable->tid >= 1) {
|
||||||
taosFreeId(pVgroup->idPool, pTable->tid);
|
taosFreeId(pVgroup->idPool, pTable->tid);
|
||||||
pVgroup->numOfTables--;
|
pVgroup->numOfTables--;
|
||||||
|
@ -850,6 +850,7 @@ static SCreateVnodeMsg *mnodeBuildVnodeMsg(SVgObj *pVgroup) {
|
||||||
pCfg->replications = (int8_t) pVgroup->numOfVnodes;
|
pCfg->replications = (int8_t) pVgroup->numOfVnodes;
|
||||||
pCfg->wals = 3;
|
pCfg->wals = 3;
|
||||||
pCfg->quorum = pDb->cfg.quorum;
|
pCfg->quorum = pDb->cfg.quorum;
|
||||||
|
pCfg->update = pDb->cfg.update;
|
||||||
|
|
||||||
SVnodeDesc *pNodes = pVnode->nodes;
|
SVnodeDesc *pNodes = pVnode->nodes;
|
||||||
for (int32_t j = 0; j < pVgroup->numOfVnodes; ++j) {
|
for (int32_t j = 0; j < pVgroup->numOfVnodes; ++j) {
|
||||||
|
@ -969,7 +970,7 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
|
||||||
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_MND_ACTION_IN_PROGRESS) {
|
||||||
mnodeMsg->pVgroup = NULL;
|
mnodeMsg->pVgroup = NULL;
|
||||||
mnodeDestroyVgroup(pVgroup);
|
mnodeDestroyVgroup(pVgroup);
|
||||||
dnodeSendRpcMnodeWriteRsp(mnodeMsg, code);
|
dnodeSendRpcMWriteRsp(mnodeMsg, code);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SSdbOper oper = {
|
SSdbOper oper = {
|
||||||
|
@ -978,7 +979,7 @@ static void mnodeProcessCreateVnodeRsp(SRpcMsg *rpcMsg) {
|
||||||
.pObj = pVgroup
|
.pObj = pVgroup
|
||||||
};
|
};
|
||||||
sdbDeleteRow(&oper);
|
sdbDeleteRow(&oper);
|
||||||
dnodeSendRpcMnodeWriteRsp(mnodeMsg, mnodeMsg->code);
|
dnodeSendRpcMWriteRsp(mnodeMsg, mnodeMsg->code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1040,7 +1041,7 @@ static void mnodeProcessDropVnodeRsp(SRpcMsg *rpcMsg) {
|
||||||
code = TSDB_CODE_MND_SDB_ERROR;
|
code = TSDB_CODE_MND_SDB_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
dnodeReprocessMnodeWriteMsg(mnodeMsg);
|
dnodeReprocessMWriteMsg(mnodeMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t mnodeProcessVnodeCfgMsg(SMnodeMsg *pMsg) {
|
static int32_t mnodeProcessVnodeCfgMsg(SMnodeMsg *pMsg) {
|
||||||
|
|
|
@ -53,7 +53,6 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "osDef.h"
|
#include "osDef.h"
|
||||||
#include "osAlloc.h"
|
|
||||||
#include "osAtomic.h"
|
#include "osAtomic.h"
|
||||||
#include "osCommon.h"
|
#include "osCommon.h"
|
||||||
#include "osDir.h"
|
#include "osDir.h"
|
||||||
|
|
|
@ -31,6 +31,7 @@ typedef enum {
|
||||||
void taosSetAllocMode(int mode, const char *path, bool autoDump);
|
void taosSetAllocMode(int mode, const char *path, bool autoDump);
|
||||||
void taosDumpMemoryLeak();
|
void taosDumpMemoryLeak();
|
||||||
|
|
||||||
|
// used in tsdb module
|
||||||
void * taosTMalloc(size_t size);
|
void * taosTMalloc(size_t size);
|
||||||
void * taosTCalloc(size_t nmemb, size_t size);
|
void * taosTCalloc(size_t nmemb, size_t size);
|
||||||
void * taosTRealloc(void *ptr, size_t size);
|
void * taosTRealloc(void *ptr, size_t size);
|
||||||
|
@ -38,7 +39,14 @@ void taosTZfree(void *ptr);
|
||||||
size_t taosTSizeof(void *ptr);
|
size_t taosTSizeof(void *ptr);
|
||||||
void taosTMemset(void *ptr, int c);
|
void taosTMemset(void *ptr, int c);
|
||||||
|
|
||||||
#define taosTFree(x) \
|
// used in other module
|
||||||
|
#define tmalloc(size) malloc(size)
|
||||||
|
#define tcalloc(num, size) calloc(num, size)
|
||||||
|
#define trealloc(ptr, size) realloc(ptr, size)
|
||||||
|
#define tstrdup(str) taosStrdupImp(str)
|
||||||
|
#define tstrndup(str, size) taosStrndupImp(str, size)
|
||||||
|
#define tgetline(lineptr, n, stream) taosGetlineImp(lineptr, n, stream)
|
||||||
|
#define tfree(x) \
|
||||||
do { \
|
do { \
|
||||||
if (x) { \
|
if (x) { \
|
||||||
free((void *)(x)); \
|
free((void *)(x)); \
|
||||||
|
@ -46,37 +54,30 @@ void taosTMemset(void *ptr, int c);
|
||||||
} \
|
} \
|
||||||
} while (0);
|
} while (0);
|
||||||
|
|
||||||
#define taosMalloc(size) malloc(size)
|
|
||||||
#define taosCalloc(num, size) calloc(num, size)
|
|
||||||
#define taosRealloc(ptr, size) realloc(ptr, size)
|
|
||||||
#define taosFree(ptr) free(ptr)
|
|
||||||
#define taosStrdup(str) taosStrdupImp(str)
|
|
||||||
#define taosStrndup(str, size) taosStrndupImp(str, size)
|
|
||||||
#define taosGetline(lineptr, n, stream) taosGetlineImp(lineptr, n, stream)
|
|
||||||
|
|
||||||
#ifdef TAOS_MEM_CHECK
|
#ifdef TAOS_MEM_CHECK
|
||||||
#ifdef TAOS_MEM_CHECK_TEST
|
#ifdef TAOS_MEM_CHECK_TEST
|
||||||
void * taos_malloc(size_t size, const char *file, uint32_t line);
|
void * taosMallocMem(size_t size, const char *file, uint32_t line);
|
||||||
void * taos_calloc(size_t num, size_t size, const char *file, uint32_t line);
|
void * taosCallocMem(size_t num, size_t size, const char *file, uint32_t line);
|
||||||
void * taos_realloc(void *ptr, size_t size, const char *file, uint32_t line);
|
void * taosReallocMem(void *ptr, size_t size, const char *file, uint32_t line);
|
||||||
void taos_free(void *ptr, const char *file, uint32_t line);
|
void taosFreeMem(void *ptr, const char *file, uint32_t line);
|
||||||
char * taos_strdup(const char *str, const char *file, uint32_t line);
|
char * taosStrdupMem(const char *str, const char *file, uint32_t line);
|
||||||
char * taos_strndup(const char *str, size_t size, const char *file, uint32_t line);
|
char * taosStrndupMem(const char *str, size_t size, const char *file, uint32_t line);
|
||||||
ssize_t taos_getline(char **lineptr, size_t *n, FILE *stream, const char *file, uint32_t line);
|
ssize_t taosGetlineMem(char **lineptr, size_t *n, FILE *stream, const char *file, uint32_t line);
|
||||||
#undef taosMalloc
|
#undef tmalloc
|
||||||
#undef taosCalloc
|
#undef tcalloc
|
||||||
#undef taosRealloc
|
#undef trealloc
|
||||||
#undef taosFree
|
#undef tfree
|
||||||
#undef taosStrdup
|
#define tmalloc(size) taosMallocMem(size, __FILE__, __LINE__)
|
||||||
#undef taosStrndup
|
#define tcalloc(num, size) taosCallocMem(num, size, __FILE__, __LINE__)
|
||||||
#undef taosGetline
|
#define trealloc(ptr, size) taosReallocMem(ptr, size, __FILE__, __LINE__)
|
||||||
#define taosMalloc(size) taos_malloc(size, __FILE__, __LINE__)
|
#define tfree(ptr) taosFreeMem(ptr, __FILE__, __LINE__)
|
||||||
#define taosCalloc(num, size) taos_calloc(num, size, __FILE__, __LINE__)
|
|
||||||
#define taosRealloc(ptr, size) taos_realloc(ptr, size, __FILE__, __LINE__)
|
// #undef tstrdup
|
||||||
#define taosFree(ptr) taos_free(ptr, __FILE__, __LINE__)
|
// #undef tstrndup
|
||||||
//#define taosStrdup(str) taos_strdup(str, __FILE__, __LINE__)
|
// #undef tgetline
|
||||||
//#define taosStrndup(str, size) taos_strndup(str, size, __FILE__, __LINE__)
|
// #define taosStrdup(str) taos_strdup(str, __FILE__, __LINE__)
|
||||||
//#define taosGetline(lineptr, n, stream) taos_getline(lineptr, n, stream, __FILE__, __LINE__)
|
// #define taosStrndup(str, size) taos_strndup(str, size, __FILE__, __LINE__)
|
||||||
|
// #define tgetline(lineptr, n, stream) taos_getline(lineptr, n, stream, __FILE__, __LINE__)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1,79 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define _DEFAULT_SOURCE
|
|
||||||
#include "os.h"
|
|
||||||
#include "taoserror.h"
|
|
||||||
#include "tulog.h"
|
|
||||||
#include "osAlloc.h"
|
|
||||||
|
|
||||||
#define TSDB_HAVE_MEMALIGN
|
|
||||||
#ifdef TAOS_OS_FUNC_ALLOC
|
|
||||||
|
|
||||||
void *tmalloc(int32_t size) {
|
|
||||||
void *p = malloc(size);
|
|
||||||
if (p == NULL) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
uError("failed to malloc memory, size:%d reason:%s", size, strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *tcalloc(int32_t nmemb, int32_t size) {
|
|
||||||
void *p = calloc(nmemb, size);
|
|
||||||
if (p == NULL) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
uError("failed to calloc memory, nmemb:%d size:%d reason:%s", nmemb, size, strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *trealloc(void *p, int32_t size) {
|
|
||||||
p = realloc(p, size);
|
|
||||||
if (p == NULL) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
uError("failed to realloc memory, size:%d reason:%s", size, strerror(errno));
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void tfree(void *p) { free(p); }
|
|
||||||
|
|
||||||
void tmemzero(void *p, int32_t size) { memset(p, 0, size); }
|
|
||||||
|
|
||||||
#ifdef TSDB_HAVE_MEMALIGN
|
|
||||||
|
|
||||||
void *tmemalign(int32_t alignment, int32_t size) {
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
int err = posix_memalign(&p, alignment, size);
|
|
||||||
if (err) {
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
uError("failed to memalign memory, alignment:%d size:%d reason:%s", alignment, size, strerror(err));
|
|
||||||
p = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
void *tmemalign(int32_t alignment, int32_t size) { return tmalloc(size); }
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
|
@ -28,7 +28,7 @@ static FILE* fpAllocLog = NULL;
|
||||||
extern int32_t taosGetTimestampSec();
|
extern int32_t taosGetTimestampSec();
|
||||||
static int32_t startTime = INT32_MAX;
|
static int32_t startTime = INT32_MAX;
|
||||||
|
|
||||||
static bool random_alloc_fail(size_t size, const char* file, uint32_t line) {
|
static bool taosRandomAllocFail(size_t size, const char* file, uint32_t line) {
|
||||||
if (taosGetTimestampSec() < startTime) {
|
if (taosGetTimestampSec() < startTime) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -48,33 +48,33 @@ static bool random_alloc_fail(size_t size, const char* file, uint32_t line) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* malloc_random(size_t size, const char* file, uint32_t line) {
|
static void* taosRandmoMalloc(size_t size, const char* file, uint32_t line) {
|
||||||
return random_alloc_fail(size, file, line) ? NULL : malloc(size);
|
return taosRandomAllocFail(size, file, line) ? NULL : malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* calloc_random(size_t num, size_t size, const char* file, uint32_t line) {
|
static void* taosRandomCalloc(size_t num, size_t size, const char* file, uint32_t line) {
|
||||||
return random_alloc_fail(num * size, file, line) ? NULL : calloc(num, size);
|
return taosRandomAllocFail(num * size, file, line) ? NULL : calloc(num, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* realloc_random(void* ptr, size_t size, const char* file, uint32_t line) {
|
static void* taosRandomRealloc(void* ptr, size_t size, const char* file, uint32_t line) {
|
||||||
return random_alloc_fail(size, file, line) ? NULL : realloc(ptr, size);
|
return taosRandomAllocFail(size, file, line) ? NULL : realloc(ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* strdup_random(const char* str, const char* file, uint32_t line) {
|
static char* taosRandomStrdup(const char* str, const char* file, uint32_t line) {
|
||||||
size_t len = strlen(str);
|
size_t len = strlen(str);
|
||||||
return random_alloc_fail(len + 1, file, line) ? NULL : taosStrdupImp(str);
|
return taosRandomAllocFail(len + 1, file, line) ? NULL : taosStrdupImp(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* strndup_random(const char* str, size_t size, const char* file, uint32_t line) {
|
static char* taosRandomStrndup(const char* str, size_t size, const char* file, uint32_t line) {
|
||||||
size_t len = strlen(str);
|
size_t len = strlen(str);
|
||||||
if (len > size) {
|
if (len > size) {
|
||||||
len = size;
|
len = size;
|
||||||
}
|
}
|
||||||
return random_alloc_fail(len + 1, file, line) ? NULL : taosStrndupImp(str, len);
|
return taosRandomAllocFail(len + 1, file, line) ? NULL : taosStrndupImp(str, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t getline_random(char **lineptr, size_t *n, FILE *stream, const char* file, uint32_t line) {
|
static ssize_t taosRandomGetline(char **lineptr, size_t *n, FILE *stream, const char* file, uint32_t line) {
|
||||||
return random_alloc_fail(*n, file, line) ? -1 : taosGetlineImp(lineptr, n, stream);
|
return taosRandomAllocFail(*n, file, line) ? -1 : taosGetlineImp(lineptr, n, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -96,7 +96,7 @@ typedef struct SMemBlock {
|
||||||
static SMemBlock *blocks = NULL;
|
static SMemBlock *blocks = NULL;
|
||||||
static uintptr_t lock = 0;
|
static uintptr_t lock = 0;
|
||||||
|
|
||||||
static void add_mem_block(SMemBlock* blk) {
|
static void taosAddMemBlock(SMemBlock* blk) {
|
||||||
blk->prev = NULL;
|
blk->prev = NULL;
|
||||||
while (atomic_val_compare_exchange_ptr(&lock, 0, 1) != 0);
|
while (atomic_val_compare_exchange_ptr(&lock, 0, 1) != 0);
|
||||||
blk->next = blocks;
|
blk->next = blocks;
|
||||||
|
@ -107,7 +107,7 @@ static void add_mem_block(SMemBlock* blk) {
|
||||||
atomic_store_ptr(&lock, 0);
|
atomic_store_ptr(&lock, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remove_mem_block(SMemBlock* blk) {
|
static void taosRemoveMemBlock(SMemBlock* blk) {
|
||||||
while (atomic_val_compare_exchange_ptr(&lock, 0, 1) != 0);
|
while (atomic_val_compare_exchange_ptr(&lock, 0, 1) != 0);
|
||||||
|
|
||||||
if (blocks == blk) {
|
if (blocks == blk) {
|
||||||
|
@ -126,7 +126,7 @@ static void remove_mem_block(SMemBlock* blk) {
|
||||||
blk->next = NULL;
|
blk->next = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_detect_leak(void* ptr, const char* file, uint32_t line) {
|
static void taosFreeDetectLeak(void* ptr, const char* file, uint32_t line) {
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -140,11 +140,11 @@ static void free_detect_leak(void* ptr, const char* file, uint32_t line) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_mem_block(blk);
|
taosRemoveMemBlock(blk);
|
||||||
free(blk);
|
free(blk);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* malloc_detect_leak(size_t size, const char* file, uint32_t line) {
|
static void* taosMallocDetectLeak(size_t size, const char* file, uint32_t line) {
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -166,28 +166,28 @@ static void* malloc_detect_leak(size_t size, const char* file, uint32_t line) {
|
||||||
blk->line = (uint16_t)line;
|
blk->line = (uint16_t)line;
|
||||||
blk->magic = MEMBLK_MAGIC;
|
blk->magic = MEMBLK_MAGIC;
|
||||||
blk->size = size;
|
blk->size = size;
|
||||||
add_mem_block(blk);
|
taosAddMemBlock(blk);
|
||||||
|
|
||||||
return blk->data;
|
return blk->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* calloc_detect_leak(size_t num, size_t size, const char* file, uint32_t line) {
|
static void* taosCallocDetectLeak(size_t num, size_t size, const char* file, uint32_t line) {
|
||||||
size *= num;
|
size *= num;
|
||||||
void* p = malloc_detect_leak(size, file, line);
|
void* p = taosMallocDetectLeak(size, file, line);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
memset(p, 0, size);
|
memset(p, 0, size);
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* realloc_detect_leak(void* ptr, size_t size, const char* file, uint32_t line) {
|
static void* taosReallocDetectLeak(void* ptr, size_t size, const char* file, uint32_t line) {
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
free_detect_leak(ptr, file, line);
|
taosFreeDetectLeak(ptr, file, line);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
return malloc_detect_leak(size, file, line);
|
return taosMallocDetectLeak(size, file, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
SMemBlock* blk = (SMemBlock *)((char*)ptr) - sizeof(SMemBlock);
|
SMemBlock* blk = (SMemBlock *)((char*)ptr) - sizeof(SMemBlock);
|
||||||
|
@ -198,11 +198,11 @@ static void* realloc_detect_leak(void* ptr, size_t size, const char* file, uint3
|
||||||
return realloc(ptr, size);
|
return realloc(ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_mem_block(blk);
|
taosRemoveMemBlock(blk);
|
||||||
|
|
||||||
void* p = realloc(blk, size + sizeof(SMemBlock));
|
void* p = realloc(blk, size + sizeof(SMemBlock));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
add_mem_block(blk);
|
taosAddMemBlock(blk);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,13 +212,13 @@ static void* realloc_detect_leak(void* ptr, size_t size, const char* file, uint3
|
||||||
|
|
||||||
blk = (SMemBlock*)p;
|
blk = (SMemBlock*)p;
|
||||||
blk->size = size;
|
blk->size = size;
|
||||||
add_mem_block(blk);
|
taosAddMemBlock(blk);
|
||||||
return blk->data;
|
return blk->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* strdup_detect_leak(const char* str, const char* file, uint32_t line) {
|
static char* taosStrdupDetectLeak(const char* str, const char* file, uint32_t line) {
|
||||||
size_t len = strlen(str);
|
size_t len = strlen(str);
|
||||||
char *p = malloc_detect_leak(len + 1, file, line);
|
char *p = taosMallocDetectLeak(len + 1, file, line);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
memcpy(p, str, len);
|
memcpy(p, str, len);
|
||||||
p[len] = 0;
|
p[len] = 0;
|
||||||
|
@ -226,12 +226,12 @@ static char* strdup_detect_leak(const char* str, const char* file, uint32_t line
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* strndup_detect_leak(const char* str, size_t size, const char* file, uint32_t line) {
|
static char* taosStrndupDetectLeak(const char* str, size_t size, const char* file, uint32_t line) {
|
||||||
size_t len = strlen(str);
|
size_t len = strlen(str);
|
||||||
if (len > size) {
|
if (len > size) {
|
||||||
len = size;
|
len = size;
|
||||||
}
|
}
|
||||||
char *p = malloc_detect_leak(len + 1, file, line);
|
char *p = taosMallocDetectLeak(len + 1, file, line);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
memcpy(p, str, len);
|
memcpy(p, str, len);
|
||||||
p[len] = 0;
|
p[len] = 0;
|
||||||
|
@ -239,13 +239,13 @@ static char* strndup_detect_leak(const char* str, size_t size, const char* file,
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t getline_detect_leak(char **lineptr, size_t *n, FILE *stream, const char* file, uint32_t line) {
|
static ssize_t taosGetlineDetectLeak(char **lineptr, size_t *n, FILE *stream, const char* file, uint32_t line) {
|
||||||
char* buf = NULL;
|
char* buf = NULL;
|
||||||
size_t bufSize = 0;
|
size_t bufSize = 0;
|
||||||
ssize_t size = taosGetlineImp(&buf, &bufSize, stream);
|
ssize_t size = taosGetlineImp(&buf, &bufSize, stream);
|
||||||
if (size != -1) {
|
if (size != -1) {
|
||||||
if (*n < size + 1) {
|
if (*n < size + 1) {
|
||||||
void* p = realloc_detect_leak(*lineptr, size + 1, file, line);
|
void* p = taosReallocDetectLeak(*lineptr, size + 1, file, line);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
free(buf);
|
free(buf);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -260,7 +260,7 @@ static ssize_t getline_detect_leak(char **lineptr, size_t *n, FILE *stream, cons
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dump_memory_leak() {
|
static void taosDumpMemoryLeakImp() {
|
||||||
const char* hex = "0123456789ABCDEF";
|
const char* hex = "0123456789ABCDEF";
|
||||||
const char* fmt = ":%d: addr=%p, size=%d, content(first 16 bytes)=";
|
const char* fmt = ":%d: addr=%p, size=%d, content(first 16 bytes)=";
|
||||||
size_t numOfBlk = 0, totalSize = 0;
|
size_t numOfBlk = 0, totalSize = 0;
|
||||||
|
@ -299,7 +299,7 @@ static void dump_memory_leak() {
|
||||||
fflush(fpAllocLog);
|
fflush(fpAllocLog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dump_memory_leak_on_sig(int sig) {
|
static void taosDumpMemoryLeakOnSig(int sig) {
|
||||||
fprintf(fpAllocLog, "signal %d received.\n", sig);
|
fprintf(fpAllocLog, "signal %d received.\n", sig);
|
||||||
|
|
||||||
// restore default signal handler
|
// restore default signal handler
|
||||||
|
@ -307,55 +307,55 @@ static void dump_memory_leak_on_sig(int sig) {
|
||||||
act.sa_handler = SIG_DFL;
|
act.sa_handler = SIG_DFL;
|
||||||
sigaction(sig, &act, NULL);
|
sigaction(sig, &act, NULL);
|
||||||
|
|
||||||
dump_memory_leak();
|
taosDumpMemoryLeakImp();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// interface functions
|
// interface functions
|
||||||
|
|
||||||
void* taos_malloc(size_t size, const char* file, uint32_t line) {
|
void* taosMallocMem(size_t size, const char* file, uint32_t line) {
|
||||||
switch (allocMode) {
|
switch (allocMode) {
|
||||||
case TAOS_ALLOC_MODE_DEFAULT:
|
case TAOS_ALLOC_MODE_DEFAULT:
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
|
|
||||||
case TAOS_ALLOC_MODE_RANDOM_FAIL:
|
case TAOS_ALLOC_MODE_RANDOM_FAIL:
|
||||||
return malloc_random(size, file, line);
|
return taosRandmoMalloc(size, file, line);
|
||||||
|
|
||||||
case TAOS_ALLOC_MODE_DETECT_LEAK:
|
case TAOS_ALLOC_MODE_DETECT_LEAK:
|
||||||
return malloc_detect_leak(size, file, line);
|
return taosMallocDetectLeak(size, file, line);
|
||||||
}
|
}
|
||||||
return malloc(size);
|
return malloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* taos_calloc(size_t num, size_t size, const char* file, uint32_t line) {
|
void* taosCallocMem(size_t num, size_t size, const char* file, uint32_t line) {
|
||||||
switch (allocMode) {
|
switch (allocMode) {
|
||||||
case TAOS_ALLOC_MODE_DEFAULT:
|
case TAOS_ALLOC_MODE_DEFAULT:
|
||||||
return calloc(num, size);
|
return calloc(num, size);
|
||||||
|
|
||||||
case TAOS_ALLOC_MODE_RANDOM_FAIL:
|
case TAOS_ALLOC_MODE_RANDOM_FAIL:
|
||||||
return calloc_random(num, size, file, line);
|
return taosRandomCalloc(num, size, file, line);
|
||||||
|
|
||||||
case TAOS_ALLOC_MODE_DETECT_LEAK:
|
case TAOS_ALLOC_MODE_DETECT_LEAK:
|
||||||
return calloc_detect_leak(num, size, file, line);
|
return taosCallocDetectLeak(num, size, file, line);
|
||||||
}
|
}
|
||||||
return calloc(num, size);
|
return calloc(num, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* taos_realloc(void* ptr, size_t size, const char* file, uint32_t line) {
|
void* taosReallocMem(void* ptr, size_t size, const char* file, uint32_t line) {
|
||||||
switch (allocMode) {
|
switch (allocMode) {
|
||||||
case TAOS_ALLOC_MODE_DEFAULT:
|
case TAOS_ALLOC_MODE_DEFAULT:
|
||||||
return realloc(ptr, size);
|
return realloc(ptr, size);
|
||||||
|
|
||||||
case TAOS_ALLOC_MODE_RANDOM_FAIL:
|
case TAOS_ALLOC_MODE_RANDOM_FAIL:
|
||||||
return realloc_random(ptr, size, file, line);
|
return taosRandomRealloc(ptr, size, file, line);
|
||||||
|
|
||||||
case TAOS_ALLOC_MODE_DETECT_LEAK:
|
case TAOS_ALLOC_MODE_DETECT_LEAK:
|
||||||
return realloc_detect_leak(ptr, size, file, line);
|
return taosReallocDetectLeak(ptr, size, file, line);
|
||||||
}
|
}
|
||||||
return realloc(ptr, size);
|
return realloc(ptr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void taos_free(void* ptr, const char* file, uint32_t line) {
|
void taosFreeMem(void* ptr, const char* file, uint32_t line) {
|
||||||
switch (allocMode) {
|
switch (allocMode) {
|
||||||
case TAOS_ALLOC_MODE_DEFAULT:
|
case TAOS_ALLOC_MODE_DEFAULT:
|
||||||
return free(ptr);
|
return free(ptr);
|
||||||
|
@ -364,54 +364,54 @@ void taos_free(void* ptr, const char* file, uint32_t line) {
|
||||||
return free(ptr);
|
return free(ptr);
|
||||||
|
|
||||||
case TAOS_ALLOC_MODE_DETECT_LEAK:
|
case TAOS_ALLOC_MODE_DETECT_LEAK:
|
||||||
return free_detect_leak(ptr, file, line);
|
return taosFreeDetectLeak(ptr, file, line);
|
||||||
}
|
}
|
||||||
return free(ptr);
|
return free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* taos_strdup(const char* str, const char* file, uint32_t line) {
|
char* taosStrdupMem(const char* str, const char* file, uint32_t line) {
|
||||||
switch (allocMode) {
|
switch (allocMode) {
|
||||||
case TAOS_ALLOC_MODE_DEFAULT:
|
case TAOS_ALLOC_MODE_DEFAULT:
|
||||||
return taosStrdupImp(str);
|
return taosStrdupImp(str);
|
||||||
|
|
||||||
case TAOS_ALLOC_MODE_RANDOM_FAIL:
|
case TAOS_ALLOC_MODE_RANDOM_FAIL:
|
||||||
return strdup_random(str, file, line);
|
return taosRandomStrdup(str, file, line);
|
||||||
|
|
||||||
case TAOS_ALLOC_MODE_DETECT_LEAK:
|
case TAOS_ALLOC_MODE_DETECT_LEAK:
|
||||||
return strdup_detect_leak(str, file, line);
|
return taosStrdupDetectLeak(str, file, line);
|
||||||
}
|
}
|
||||||
return taosStrdupImp(str);
|
return taosStrdupImp(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* taos_strndup(const char* str, size_t size, const char* file, uint32_t line) {
|
char* taosStrndupMem(const char* str, size_t size, const char* file, uint32_t line) {
|
||||||
switch (allocMode) {
|
switch (allocMode) {
|
||||||
case TAOS_ALLOC_MODE_DEFAULT:
|
case TAOS_ALLOC_MODE_DEFAULT:
|
||||||
return taosStrndupImp(str, size);
|
return taosStrndupImp(str, size);
|
||||||
|
|
||||||
case TAOS_ALLOC_MODE_RANDOM_FAIL:
|
case TAOS_ALLOC_MODE_RANDOM_FAIL:
|
||||||
return strndup_random(str, size, file, line);
|
return taosRandomStrndup(str, size, file, line);
|
||||||
|
|
||||||
case TAOS_ALLOC_MODE_DETECT_LEAK:
|
case TAOS_ALLOC_MODE_DETECT_LEAK:
|
||||||
return strndup_detect_leak(str, size, file, line);
|
return taosStrndupDetectLeak(str, size, file, line);
|
||||||
}
|
}
|
||||||
return taosStrndupImp(str, size);
|
return taosStrndupImp(str, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t taos_getline(char **lineptr, size_t *n, FILE *stream, const char* file, uint32_t line) {
|
ssize_t taosGetlineMem(char **lineptr, size_t *n, FILE *stream, const char* file, uint32_t line) {
|
||||||
switch (allocMode) {
|
switch (allocMode) {
|
||||||
case TAOS_ALLOC_MODE_DEFAULT:
|
case TAOS_ALLOC_MODE_DEFAULT:
|
||||||
return taosGetlineImp(lineptr, n, stream);
|
return taosGetlineImp(lineptr, n, stream);
|
||||||
|
|
||||||
case TAOS_ALLOC_MODE_RANDOM_FAIL:
|
case TAOS_ALLOC_MODE_RANDOM_FAIL:
|
||||||
return getline_random(lineptr, n, stream, file, line);
|
return taosRandomGetline(lineptr, n, stream, file, line);
|
||||||
|
|
||||||
case TAOS_ALLOC_MODE_DETECT_LEAK:
|
case TAOS_ALLOC_MODE_DETECT_LEAK:
|
||||||
return getline_detect_leak(lineptr, n, stream, file, line);
|
return taosGetlineDetectLeak(lineptr, n, stream, file, line);
|
||||||
}
|
}
|
||||||
return taosGetlineImp(lineptr, n, stream);
|
return taosGetlineImp(lineptr, n, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close_alloc_log() {
|
static void taosCloseAllocLog() {
|
||||||
if (fpAllocLog != NULL) {
|
if (fpAllocLog != NULL) {
|
||||||
if (fpAllocLog != stdout) {
|
if (fpAllocLog != stdout) {
|
||||||
fclose(fpAllocLog);
|
fclose(fpAllocLog);
|
||||||
|
@ -432,7 +432,7 @@ void taosSetAllocMode(int mode, const char* path, bool autoDump) {
|
||||||
if (path == NULL || path[0] == 0) {
|
if (path == NULL || path[0] == 0) {
|
||||||
fpAllocLog = stdout;
|
fpAllocLog = stdout;
|
||||||
} else if ((fpAllocLog = fopen(path, "w")) != NULL) {
|
} else if ((fpAllocLog = fopen(path, "w")) != NULL) {
|
||||||
atexit(close_alloc_log);
|
atexit(taosCloseAllocLog);
|
||||||
} else {
|
} else {
|
||||||
printf("failed to open memory allocation log file '%s', errno=%d\n", path, errno);
|
printf("failed to open memory allocation log file '%s', errno=%d\n", path, errno);
|
||||||
return;
|
return;
|
||||||
|
@ -446,10 +446,10 @@ void taosSetAllocMode(int mode, const char* path, bool autoDump) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (autoDump && mode == TAOS_ALLOC_MODE_DETECT_LEAK) {
|
if (autoDump && mode == TAOS_ALLOC_MODE_DETECT_LEAK) {
|
||||||
atexit(dump_memory_leak);
|
atexit(taosDumpMemoryLeakImp);
|
||||||
|
|
||||||
struct sigaction act = {0};
|
struct sigaction act = {0};
|
||||||
act.sa_handler = dump_memory_leak_on_sig;
|
act.sa_handler = taosDumpMemoryLeakOnSig;
|
||||||
sigaction(SIGFPE, &act, NULL);
|
sigaction(SIGFPE, &act, NULL);
|
||||||
sigaction(SIGSEGV, &act, NULL);
|
sigaction(SIGSEGV, &act, NULL);
|
||||||
sigaction(SIGILL, &act, NULL);
|
sigaction(SIGILL, &act, NULL);
|
||||||
|
@ -457,8 +457,8 @@ void taosSetAllocMode(int mode, const char* path, bool autoDump) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void taosDumpMemoryLeak() {
|
void taosDumpMemoryLeak() {
|
||||||
dump_memory_leak();
|
taosDumpMemoryLeakImp();
|
||||||
close_alloc_log();
|
taosCloseAllocLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // 'TAOS_MEM_CHECK' not defined
|
#else // 'TAOS_MEM_CHECK' not defined
|
||||||
|
|
|
@ -61,7 +61,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
|
||||||
size_t len;
|
size_t len;
|
||||||
char * line = NULL;
|
char * line = NULL;
|
||||||
while (!feof(fp)) {
|
while (!feof(fp)) {
|
||||||
taosTFree(line);
|
tfree(line);
|
||||||
len = 0;
|
len = 0;
|
||||||
getline(&line, &len, fp);
|
getline(&line, &len, fp);
|
||||||
if (line == NULL) {
|
if (line == NULL) {
|
||||||
|
@ -83,7 +83,7 @@ bool taosGetProcMemory(float *memoryUsedMB) {
|
||||||
sscanf(line, "%s %" PRId64, tmp, &memKB);
|
sscanf(line, "%s %" PRId64, tmp, &memKB);
|
||||||
*memoryUsedMB = (float)((double)memKB / 1024);
|
*memoryUsedMB = (float)((double)memKB / 1024);
|
||||||
|
|
||||||
taosTFree(line);
|
tfree(line);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ static bool taosGetSysCpuInfo(SysCpuInfo *cpuInfo) {
|
||||||
char cpu[10] = {0};
|
char cpu[10] = {0};
|
||||||
sscanf(line, "%s %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64, cpu, &cpuInfo->user, &cpuInfo->nice, &cpuInfo->system, &cpuInfo->idle);
|
sscanf(line, "%s %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64, cpu, &cpuInfo->user, &cpuInfo->nice, &cpuInfo->system, &cpuInfo->idle);
|
||||||
|
|
||||||
taosTFree(line);
|
tfree(line);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ static bool taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(line);
|
tfree(line);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -377,7 +377,7 @@ static bool taosGetCardInfo(int64_t *bytes) {
|
||||||
*bytes += (rbytes + tbytes);
|
*bytes += (rbytes + tbytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(line);
|
tfree(line);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -432,7 +432,7 @@ static bool taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
|
||||||
int readIndex = 0;
|
int readIndex = 0;
|
||||||
|
|
||||||
while (!feof(fp)) {
|
while (!feof(fp)) {
|
||||||
taosTFree(line);
|
tfree(line);
|
||||||
len = 0;
|
len = 0;
|
||||||
getline(&line, &len, fp);
|
getline(&line, &len, fp);
|
||||||
if (line == NULL) {
|
if (line == NULL) {
|
||||||
|
@ -450,7 +450,7 @@ static bool taosReadProcIO(int64_t *readbyte, int64_t *writebyte) {
|
||||||
if (readIndex >= 2) break;
|
if (readIndex >= 2) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(line);
|
tfree(line);
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
if (readIndex < 2) {
|
if (readIndex < 2) {
|
||||||
|
|
|
@ -22,9 +22,11 @@ extern "C" {
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
typedef void (*FHttpResultFp)(void *param, void *result, int32_t code, int32_t rows);
|
||||||
|
|
||||||
bool httpInitResultQueue();
|
bool httpInitResultQueue();
|
||||||
void httpCleanupResultQueue();
|
void httpCleanupResultQueue();
|
||||||
void httpDispatchToResultQueue();
|
void httpDispatchToResultQueue(void *param, TAOS_RES *result, int32_t code, int32_t rows, FHttpResultFp fp);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ static void httpDestroyContext(void *data) {
|
||||||
pContext->parser = NULL;
|
pContext->parser = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pContext);
|
tfree(pContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool httpInitContexts() {
|
bool httpInitContexts() {
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "httpResp.h"
|
#include "httpResp.h"
|
||||||
#include "httpAuth.h"
|
#include "httpAuth.h"
|
||||||
#include "httpSession.h"
|
#include "httpSession.h"
|
||||||
|
#include "httpQueue.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
pthread_t thread;
|
pthread_t thread;
|
||||||
|
@ -37,33 +38,35 @@ typedef struct {
|
||||||
} SHttpWorkerPool;
|
} SHttpWorkerPool;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void *param;
|
void * param;
|
||||||
void *result;
|
void * result;
|
||||||
int32_t numOfRows;
|
int32_t code;
|
||||||
void (*fp)(void *param, void *result, int32_t numOfRows);
|
int32_t rows;
|
||||||
|
FHttpResultFp fp;
|
||||||
} SHttpResult;
|
} SHttpResult;
|
||||||
|
|
||||||
static SHttpWorkerPool tsHttpPool;
|
static SHttpWorkerPool tsHttpPool;
|
||||||
static taos_qset tsHttpQset;
|
static taos_qset tsHttpQset;
|
||||||
static taos_queue tsHttpQueue;
|
static taos_queue tsHttpQueue;
|
||||||
|
|
||||||
void httpDispatchToResultQueue(void *param, TAOS_RES *result, int32_t numOfRows, void (*fp)(void *param, void *result, int32_t numOfRows)) {
|
void httpDispatchToResultQueue(void *param, TAOS_RES *result, int32_t code, int32_t rows, FHttpResultFp fp) {
|
||||||
if (tsHttpQueue != NULL) {
|
if (tsHttpQueue != NULL) {
|
||||||
SHttpResult *pMsg = (SHttpResult *)taosAllocateQitem(sizeof(SHttpResult));
|
SHttpResult *pMsg = taosAllocateQitem(sizeof(SHttpResult));
|
||||||
pMsg->param = param;
|
pMsg->param = param;
|
||||||
pMsg->result = result;
|
pMsg->result = result;
|
||||||
pMsg->numOfRows = numOfRows;
|
pMsg->code = code;
|
||||||
|
pMsg->rows = rows;
|
||||||
pMsg->fp = fp;
|
pMsg->fp = fp;
|
||||||
taosWriteQitem(tsHttpQueue, TAOS_QTYPE_RPC, pMsg);
|
taosWriteQitem(tsHttpQueue, TAOS_QTYPE_RPC, pMsg);
|
||||||
} else {
|
} else {
|
||||||
(*fp)(param, result, numOfRows);
|
(*fp)(param, result, code, rows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *httpProcessResultQueue(void *param) {
|
static void *httpProcessResultQueue(void *param) {
|
||||||
SHttpResult *pMsg;
|
SHttpResult *pMsg;
|
||||||
int32_t type;
|
int32_t type;
|
||||||
void *unUsed;
|
void * unUsed;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (taosReadQitemFromQset(tsHttpQset, &type, (void **)&pMsg, &unUsed) == 0) {
|
if (taosReadQitemFromQset(tsHttpQset, &type, (void **)&pMsg, &unUsed) == 0) {
|
||||||
|
@ -71,8 +74,9 @@ static void *httpProcessResultQueue(void *param) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
httpTrace("context:%p, res:%p will be processed in result queue", pMsg->param, pMsg->result);
|
httpTrace("context:%p, res:%p will be processed in result queue, code:%d rows:%d", pMsg->param, pMsg->result,
|
||||||
(*pMsg->fp)(pMsg->param, pMsg->result, pMsg->numOfRows);
|
pMsg->code, pMsg->rows);
|
||||||
|
(*pMsg->fp)(pMsg->param, pMsg->result, pMsg->code, pMsg->rows);
|
||||||
taosFreeQitem(pMsg);
|
taosFreeQitem(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,9 @@
|
||||||
|
|
||||||
void httpProcessMultiSql(HttpContext *pContext);
|
void httpProcessMultiSql(HttpContext *pContext);
|
||||||
|
|
||||||
void httpProcessMultiSqlRetrieveCallBack(void *param, TAOS_RES *result, int numOfRows);
|
void httpProcessMultiSqlRetrieveCallBack(void *param, TAOS_RES *result, int32_t numOfRows);
|
||||||
|
|
||||||
void httpProcessMultiSqlRetrieveCallBackImp(void *param, TAOS_RES *result, int numOfRows) {
|
void httpProcessMultiSqlRetrieveCallBackImp(void *param, TAOS_RES *result, int32_t code, int32_t numOfRows) {
|
||||||
HttpContext *pContext = (HttpContext *)param;
|
HttpContext *pContext = (HttpContext *)param;
|
||||||
if (pContext == NULL) return;
|
if (pContext == NULL) return;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ void httpProcessMultiSqlRetrieveCallBackImp(void *param, TAOS_RES *result, int n
|
||||||
|
|
||||||
bool isContinue = false;
|
bool isContinue = false;
|
||||||
|
|
||||||
if (numOfRows > 0) {
|
if (code == TSDB_CODE_SUCCESS && numOfRows > 0) {
|
||||||
if (singleCmd->cmdReturnType == HTTP_CMD_RETURN_TYPE_WITH_RETURN && encode->buildQueryJsonFp) {
|
if (singleCmd->cmdReturnType == HTTP_CMD_RETURN_TYPE_WITH_RETURN && encode->buildQueryJsonFp) {
|
||||||
isContinue = (encode->buildQueryJsonFp)(pContext, singleCmd, result, numOfRows);
|
isContinue = (encode->buildQueryJsonFp)(pContext, singleCmd, result, numOfRows);
|
||||||
}
|
}
|
||||||
|
@ -58,9 +58,9 @@ void httpProcessMultiSqlRetrieveCallBackImp(void *param, TAOS_RES *result, int n
|
||||||
httpDebug("context:%p, fd:%d, user:%s, process pos:%d, stop retrieve, numOfRows:%d, sql:%s", pContext, pContext->fd,
|
httpDebug("context:%p, fd:%d, user:%s, process pos:%d, stop retrieve, numOfRows:%d, sql:%s", pContext, pContext->fd,
|
||||||
pContext->user, multiCmds->pos, numOfRows, sql);
|
pContext->user, multiCmds->pos, numOfRows, sql);
|
||||||
|
|
||||||
if (numOfRows < 0) {
|
if (code < 0) {
|
||||||
httpError("context:%p, fd:%d, user:%s, process pos:%d, retrieve failed code:%s, sql:%s", pContext, pContext->fd,
|
httpError("context:%p, fd:%d, user:%s, process pos:%d, retrieve failed code:%s, sql:%s", pContext, pContext->fd,
|
||||||
pContext->user, multiCmds->pos, tstrerror(numOfRows), sql);
|
pContext->user, multiCmds->pos, tstrerror(code), sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
taos_free_result(result);
|
taos_free_result(result);
|
||||||
|
@ -73,15 +73,15 @@ void httpProcessMultiSqlRetrieveCallBackImp(void *param, TAOS_RES *result, int n
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void httpProcessMultiSqlRetrieveCallBack(void *param, TAOS_RES *result, int numOfRows) {
|
void httpProcessMultiSqlRetrieveCallBack(void *param, TAOS_RES *result, int32_t numOfRows) {
|
||||||
httpDispatchToResultQueue(param, result, numOfRows, httpProcessMultiSqlRetrieveCallBackImp);
|
int32_t code = taos_errno(result);
|
||||||
|
httpDispatchToResultQueue(param, result, code, numOfRows, httpProcessMultiSqlRetrieveCallBackImp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void httpProcessMultiSqlCallBackImp(void *param, TAOS_RES *result, int code) {
|
void httpProcessMultiSqlCallBackImp(void *param, TAOS_RES *result, int32_t code, int32_t affectRowsInput) {
|
||||||
HttpContext *pContext = (HttpContext *)param;
|
HttpContext *pContext = (HttpContext *)param;
|
||||||
if (pContext == NULL) return;
|
if (pContext == NULL) return;
|
||||||
|
|
||||||
code = taos_errno(result);
|
|
||||||
HttpSqlCmds *multiCmds = pContext->multiCmds;
|
HttpSqlCmds *multiCmds = pContext->multiCmds;
|
||||||
HttpEncodeMethod *encode = pContext->encodeMethod;
|
HttpEncodeMethod *encode = pContext->encodeMethod;
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ void httpProcessMultiSqlCallBackImp(void *param, TAOS_RES *result, int code) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code < 0) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
if (encode->checkFinishedFp != NULL && !encode->checkFinishedFp(pContext, singleCmd, code)) {
|
if (encode->checkFinishedFp != NULL && !encode->checkFinishedFp(pContext, singleCmd, code)) {
|
||||||
singleCmd->code = code;
|
singleCmd->code = code;
|
||||||
httpDebug("context:%p, fd:%d, user:%s, process pos jump to:%d, last code:%s, last sql:%s", pContext, pContext->fd,
|
httpDebug("context:%p, fd:%d, user:%s, process pos jump to:%d, last code:%s, last sql:%s", pContext, pContext->fd,
|
||||||
|
@ -119,7 +119,7 @@ void httpProcessMultiSqlCallBackImp(void *param, TAOS_RES *result, int code) {
|
||||||
bool isUpdate = tscIsUpdateQuery(result);
|
bool isUpdate = tscIsUpdateQuery(result);
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
// not select or show commands
|
// not select or show commands
|
||||||
int affectRows = taos_affected_rows(result);
|
int32_t affectRows = taos_affected_rows(result);
|
||||||
httpDebug("context:%p, fd:%d, user:%s, process pos:%d, affect rows:%d, sql:%s", pContext, pContext->fd,
|
httpDebug("context:%p, fd:%d, user:%s, process pos:%d, affect rows:%d, sql:%s", pContext, pContext->fd,
|
||||||
pContext->user, multiCmds->pos, affectRows, sql);
|
pContext->user, multiCmds->pos, affectRows, sql);
|
||||||
|
|
||||||
|
@ -156,8 +156,10 @@ void httpProcessMultiSqlCallBackImp(void *param, TAOS_RES *result, int code) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void httpProcessMultiSqlCallBack(void *param, TAOS_RES *result, int unUsedCode) {
|
void httpProcessMultiSqlCallBack(void *param, TAOS_RES *result, int32_t unUsedCode) {
|
||||||
httpDispatchToResultQueue(param, result, unUsedCode, httpProcessMultiSqlCallBackImp);
|
int32_t code = taos_errno(result);
|
||||||
|
int32_t affectRows = taos_affected_rows(result);
|
||||||
|
httpDispatchToResultQueue(param, result, code, affectRows, httpProcessMultiSqlCallBackImp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void httpProcessMultiSql(HttpContext *pContext) {
|
void httpProcessMultiSql(HttpContext *pContext) {
|
||||||
|
@ -202,9 +204,9 @@ void httpProcessMultiSqlCmd(HttpContext *pContext) {
|
||||||
httpProcessMultiSql(pContext);
|
httpProcessMultiSql(pContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
void httpProcessSingleSqlRetrieveCallBack(void *param, TAOS_RES *result, int numOfRows);
|
void httpProcessSingleSqlRetrieveCallBack(void *param, TAOS_RES *result, int32_t numOfRows);
|
||||||
|
|
||||||
void httpProcessSingleSqlRetrieveCallBackImp(void *param, TAOS_RES *result, int numOfRows) {
|
void httpProcessSingleSqlRetrieveCallBackImp(void *param, TAOS_RES *result, int32_t code, int32_t numOfRows) {
|
||||||
HttpContext *pContext = (HttpContext *)param;
|
HttpContext *pContext = (HttpContext *)param;
|
||||||
if (pContext == NULL) return;
|
if (pContext == NULL) return;
|
||||||
|
|
||||||
|
@ -212,7 +214,7 @@ void httpProcessSingleSqlRetrieveCallBackImp(void *param, TAOS_RES *result, int
|
||||||
|
|
||||||
bool isContinue = false;
|
bool isContinue = false;
|
||||||
|
|
||||||
if (numOfRows > 0) {
|
if (code == TSDB_CODE_SUCCESS && numOfRows > 0) {
|
||||||
if (encode->buildQueryJsonFp) {
|
if (encode->buildQueryJsonFp) {
|
||||||
isContinue = (encode->buildQueryJsonFp)(pContext, &pContext->singleCmd, result, numOfRows);
|
isContinue = (encode->buildQueryJsonFp)(pContext, &pContext->singleCmd, result, numOfRows);
|
||||||
}
|
}
|
||||||
|
@ -227,9 +229,9 @@ void httpProcessSingleSqlRetrieveCallBackImp(void *param, TAOS_RES *result, int
|
||||||
httpDebug("context:%p, fd:%d, user:%s, stop retrieve, numOfRows:%d", pContext, pContext->fd, pContext->user,
|
httpDebug("context:%p, fd:%d, user:%s, stop retrieve, numOfRows:%d", pContext, pContext->fd, pContext->user,
|
||||||
numOfRows);
|
numOfRows);
|
||||||
|
|
||||||
if (numOfRows < 0) {
|
if (code < 0) {
|
||||||
httpError("context:%p, fd:%d, user:%s, retrieve failed, code:%s", pContext, pContext->fd, pContext->user,
|
httpError("context:%p, fd:%d, user:%s, retrieve failed, code:%s", pContext, pContext->fd, pContext->user,
|
||||||
tstrerror(numOfRows));
|
tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
taos_free_result(result);
|
taos_free_result(result);
|
||||||
|
@ -242,30 +244,30 @@ void httpProcessSingleSqlRetrieveCallBackImp(void *param, TAOS_RES *result, int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void httpProcessSingleSqlRetrieveCallBack(void *param, TAOS_RES *result, int numOfRows) {
|
void httpProcessSingleSqlRetrieveCallBack(void *param, TAOS_RES *result, int32_t numOfRows) {
|
||||||
httpDispatchToResultQueue(param, result, numOfRows, httpProcessSingleSqlRetrieveCallBackImp);
|
int32_t code = taos_errno(result);
|
||||||
|
httpDispatchToResultQueue(param, result, code, numOfRows, httpProcessSingleSqlRetrieveCallBackImp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void httpProcessSingleSqlCallBackImp(void *param, TAOS_RES *result, int unUsedCode) {
|
void httpProcessSingleSqlCallBackImp(void *param, TAOS_RES *result, int32_t code, int32_t affectRowsInput) {
|
||||||
HttpContext *pContext = (HttpContext *)param;
|
HttpContext *pContext = (HttpContext *)param;
|
||||||
if (pContext == NULL) return;
|
if (pContext == NULL) return;
|
||||||
|
|
||||||
int32_t code = taos_errno(result);
|
|
||||||
|
|
||||||
HttpEncodeMethod *encode = pContext->encodeMethod;
|
HttpEncodeMethod *encode = pContext->encodeMethod;
|
||||||
|
|
||||||
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
|
if (code == TSDB_CODE_TSC_ACTION_IN_PROGRESS) {
|
||||||
httpError("context:%p, fd:%d, user:%s, query error, code:%s:inprogress, sqlObj:%p", pContext, pContext->fd,
|
httpError("context:%p, fd:%d, user:%s, query error, code:%s:inprogress, sqlObj:%p", pContext, pContext->fd,
|
||||||
pContext->user, tstrerror(code), (SSqlObj *)result);
|
pContext->user, tstrerror(code), result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code < 0) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
SSqlObj *pObj = (SSqlObj *)result;
|
SSqlObj *pObj = (SSqlObj *)result;
|
||||||
if (code == TSDB_CODE_TSC_INVALID_SQL) {
|
if (code == TSDB_CODE_TSC_INVALID_SQL) {
|
||||||
httpError("context:%p, fd:%d, user:%s, query error, code:%s, sqlObj:%p, error:%s", pContext,
|
terrno = code;
|
||||||
pContext->fd, pContext->user, tstrerror(code), pObj, pObj->cmd.payload);
|
httpError("context:%p, fd:%d, user:%s, query error, code:%s, sqlObj:%p, error:%s", pContext, pContext->fd,
|
||||||
httpSendTaosdInvalidSqlErrorResp(pContext, pObj->cmd.payload);
|
pContext->user, tstrerror(code), pObj, taos_errstr(pObj));
|
||||||
|
httpSendTaosdInvalidSqlErrorResp(pContext, taos_errstr(pObj));
|
||||||
} else {
|
} else {
|
||||||
httpError("context:%p, fd:%d, user:%s, query error, code:%s, sqlObj:%p", pContext, pContext->fd,
|
httpError("context:%p, fd:%d, user:%s, query error, code:%s, sqlObj:%p", pContext, pContext->fd,
|
||||||
pContext->user, tstrerror(code), pObj);
|
pContext->user, tstrerror(code), pObj);
|
||||||
|
@ -278,7 +280,8 @@ void httpProcessSingleSqlCallBackImp(void *param, TAOS_RES *result, int unUsedCo
|
||||||
bool isUpdate = tscIsUpdateQuery(result);
|
bool isUpdate = tscIsUpdateQuery(result);
|
||||||
if (isUpdate) {
|
if (isUpdate) {
|
||||||
// not select or show commands
|
// not select or show commands
|
||||||
int affectRows = taos_affected_rows(result);
|
int32_t affectRows = taos_affected_rows(result);
|
||||||
|
assert(affectRows == affectRowsInput);
|
||||||
|
|
||||||
httpDebug("context:%p, fd:%d, user:%s, affect rows:%d, stop query, sqlObj:%p", pContext, pContext->fd,
|
httpDebug("context:%p, fd:%d, user:%s, affect rows:%d, stop query, sqlObj:%p", pContext, pContext->fd,
|
||||||
pContext->user, affectRows, result);
|
pContext->user, affectRows, result);
|
||||||
|
@ -308,8 +311,10 @@ void httpProcessSingleSqlCallBackImp(void *param, TAOS_RES *result, int unUsedCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void httpProcessSingleSqlCallBack(void *param, TAOS_RES *result, int unUsedCode) {
|
void httpProcessSingleSqlCallBack(void *param, TAOS_RES *result, int32_t unUsedCode) {
|
||||||
httpDispatchToResultQueue(param, result, unUsedCode, httpProcessSingleSqlCallBackImp);
|
int32_t code = taos_errno(result);
|
||||||
|
int32_t affectRows = taos_affected_rows(result);
|
||||||
|
httpDispatchToResultQueue(param, result, code, affectRows, httpProcessSingleSqlCallBackImp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void httpProcessSingleSqlCmd(HttpContext *pContext) {
|
void httpProcessSingleSqlCmd(HttpContext *pContext) {
|
||||||
|
@ -373,7 +378,7 @@ void httpExecCmd(HttpContext *pContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void httpProcessRequestCb(void *param, TAOS_RES *result, int code) {
|
void httpProcessRequestCb(void *param, TAOS_RES *result, int32_t code) {
|
||||||
HttpContext *pContext = param;
|
HttpContext *pContext = param;
|
||||||
taos_free_result(result);
|
taos_free_result(result);
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ void httpCleanUpSystem() {
|
||||||
httpCleanupResultQueue();
|
httpCleanupResultQueue();
|
||||||
|
|
||||||
pthread_mutex_destroy(&tsHttpServer.serverMutex);
|
pthread_mutex_destroy(&tsHttpServer.serverMutex);
|
||||||
taosTFree(tsHttpServer.pThreads);
|
tfree(tsHttpServer.pThreads);
|
||||||
tsHttpServer.pThreads = NULL;
|
tsHttpServer.pThreads = NULL;
|
||||||
|
|
||||||
tsHttpServer.status = HTTP_SERVER_CLOSED;
|
tsHttpServer.status = HTTP_SERVER_CLOSED;
|
||||||
|
|
|
@ -27,12 +27,12 @@
|
||||||
#include "monitor.h"
|
#include "monitor.h"
|
||||||
#include "taoserror.h"
|
#include "taoserror.h"
|
||||||
|
|
||||||
#define monitorFatal(...) { if (monitorDebugFlag & DEBUG_FATAL) { taosPrintLog("MON FATAL ", 255, __VA_ARGS__); }}
|
#define mnFatal(...) { if (monitorDebugFlag & DEBUG_FATAL) { taosPrintLog("MON FATAL ", 255, __VA_ARGS__); }}
|
||||||
#define monitorError(...) { if (monitorDebugFlag & DEBUG_ERROR) { taosPrintLog("MON ERROR ", 255, __VA_ARGS__); }}
|
#define mnError(...) { if (monitorDebugFlag & DEBUG_ERROR) { taosPrintLog("MON ERROR ", 255, __VA_ARGS__); }}
|
||||||
#define monitorWarn(...) { if (monitorDebugFlag & DEBUG_WARN) { taosPrintLog("MON WARN ", 255, __VA_ARGS__); }}
|
#define mnWarn(...) { if (monitorDebugFlag & DEBUG_WARN) { taosPrintLog("MON WARN ", 255, __VA_ARGS__); }}
|
||||||
#define monitorInfo(...) { if (monitorDebugFlag & DEBUG_INFO) { taosPrintLog("MON ", 255, __VA_ARGS__); }}
|
#define mnInfo(...) { if (monitorDebugFlag & DEBUG_INFO) { taosPrintLog("MON ", 255, __VA_ARGS__); }}
|
||||||
#define monitorDebug(...) { if (monitorDebugFlag & DEBUG_DEBUG) { taosPrintLog("MON ", monitorDebugFlag, __VA_ARGS__); }}
|
#define mnDebug(...) { if (monitorDebugFlag & DEBUG_DEBUG) { taosPrintLog("MON ", monitorDebugFlag, __VA_ARGS__); }}
|
||||||
#define monitorTrace(...) { if (monitorDebugFlag & DEBUG_TRACE) { taosPrintLog("MON ", monitorDebugFlag, __VA_ARGS__); }}
|
#define mnTrace(...) { if (monitorDebugFlag & DEBUG_TRACE) { taosPrintLog("MON ", monitorDebugFlag, __VA_ARGS__); }}
|
||||||
|
|
||||||
#define SQL_LENGTH 1030
|
#define SQL_LENGTH 1030
|
||||||
#define LOG_LEN_STR 100
|
#define LOG_LEN_STR 100
|
||||||
|
@ -91,12 +91,12 @@ int32_t monitorInitSystem() {
|
||||||
pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE);
|
pthread_attr_setdetachstate(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||||
|
|
||||||
if (pthread_create(&tsMonitor.thread, &thAttr, monitorThreadFunc, NULL)) {
|
if (pthread_create(&tsMonitor.thread, &thAttr, monitorThreadFunc, NULL)) {
|
||||||
monitorError("failed to create thread to for monitor module, reason:%s", strerror(errno));
|
mnError("failed to create thread to for monitor module, reason:%s", strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_attr_destroy(&thAttr);
|
pthread_attr_destroy(&thAttr);
|
||||||
monitorDebug("monitor thread is launched");
|
mnDebug("monitor thread is launched");
|
||||||
|
|
||||||
monitorStartSystemFp = monitorStartSystem;
|
monitorStartSystemFp = monitorStartSystem;
|
||||||
monitorStopSystemFp = monitorStopSystem;
|
monitorStopSystemFp = monitorStopSystem;
|
||||||
|
@ -107,12 +107,12 @@ int32_t monitorStartSystem() {
|
||||||
taos_init();
|
taos_init();
|
||||||
tsMonitor.start = 1;
|
tsMonitor.start = 1;
|
||||||
monitorExecuteSQLFp = monitorExecuteSQL;
|
monitorExecuteSQLFp = monitorExecuteSQL;
|
||||||
monitorInfo("monitor module start");
|
mnInfo("monitor module start");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *monitorThreadFunc(void *param) {
|
static void *monitorThreadFunc(void *param) {
|
||||||
monitorDebug("starting to initialize monitor module ...");
|
mnDebug("starting to initialize monitor module ...");
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
static int32_t accessTimes = 0;
|
static int32_t accessTimes = 0;
|
||||||
|
@ -121,7 +121,7 @@ static void *monitorThreadFunc(void *param) {
|
||||||
|
|
||||||
if (tsMonitor.quiting) {
|
if (tsMonitor.quiting) {
|
||||||
tsMonitor.state = MON_STATE_NOT_INIT;
|
tsMonitor.state = MON_STATE_NOT_INIT;
|
||||||
monitorInfo("monitor thread will quit, for taosd is quiting");
|
mnInfo("monitor thread will quit, for taosd is quiting");
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
taosGetDisk();
|
taosGetDisk();
|
||||||
|
@ -132,7 +132,7 @@ static void *monitorThreadFunc(void *param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dnodeGetDnodeId() <= 0) {
|
if (dnodeGetDnodeId() <= 0) {
|
||||||
monitorDebug("dnode not initialized, waiting for 3000 ms to start monitor module");
|
mnDebug("dnode not initialized, waiting for 3000 ms to start monitor module");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,10 +140,10 @@ static void *monitorThreadFunc(void *param) {
|
||||||
tsMonitor.state = MON_STATE_NOT_INIT;
|
tsMonitor.state = MON_STATE_NOT_INIT;
|
||||||
tsMonitor.conn = taos_connect(NULL, "monitor", tsInternalPass, "", 0);
|
tsMonitor.conn = taos_connect(NULL, "monitor", tsInternalPass, "", 0);
|
||||||
if (tsMonitor.conn == NULL) {
|
if (tsMonitor.conn == NULL) {
|
||||||
monitorError("failed to connect to database, reason:%s", tstrerror(terrno));
|
mnError("failed to connect to database, reason:%s", tstrerror(terrno));
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
monitorDebug("connect to database success");
|
mnDebug("connect to database success");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,10 +155,10 @@ static void *monitorThreadFunc(void *param) {
|
||||||
taos_free_result(res);
|
taos_free_result(res);
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
monitorError("failed to exec sql:%s, reason:%s", tsMonitor.sql, tstrerror(code));
|
mnError("failed to exec sql:%s, reason:%s", tsMonitor.sql, tstrerror(code));
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
monitorDebug("successfully to exec sql:%s", tsMonitor.sql);
|
mnDebug("successfully to exec sql:%s", tsMonitor.sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ static void *monitorThreadFunc(void *param) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
monitorInfo("monitor thread is stopped");
|
mnInfo("monitor thread is stopped");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ void monitorStopSystem() {
|
||||||
tsMonitor.start = 0;
|
tsMonitor.start = 0;
|
||||||
tsMonitor.state = MON_STATE_NOT_INIT;
|
tsMonitor.state = MON_STATE_NOT_INIT;
|
||||||
monitorExecuteSQLFp = NULL;
|
monitorExecuteSQLFp = NULL;
|
||||||
monitorInfo("monitor module stopped");
|
mnInfo("monitor module stopped");
|
||||||
}
|
}
|
||||||
|
|
||||||
void monitorCleanUpSystem() {
|
void monitorCleanUpSystem() {
|
||||||
|
@ -249,7 +249,7 @@ void monitorCleanUpSystem() {
|
||||||
taos_close(tsMonitor.conn);
|
taos_close(tsMonitor.conn);
|
||||||
tsMonitor.conn = NULL;
|
tsMonitor.conn = NULL;
|
||||||
}
|
}
|
||||||
monitorInfo("monitor module is cleaned up");
|
mnInfo("monitor module is cleaned up");
|
||||||
}
|
}
|
||||||
|
|
||||||
// unit is MB
|
// unit is MB
|
||||||
|
@ -257,13 +257,13 @@ static int32_t monitorBuildMemorySql(char *sql) {
|
||||||
float sysMemoryUsedMB = 0;
|
float sysMemoryUsedMB = 0;
|
||||||
bool suc = taosGetSysMemory(&sysMemoryUsedMB);
|
bool suc = taosGetSysMemory(&sysMemoryUsedMB);
|
||||||
if (!suc) {
|
if (!suc) {
|
||||||
monitorDebug("failed to get sys memory info");
|
mnDebug("failed to get sys memory info");
|
||||||
}
|
}
|
||||||
|
|
||||||
float procMemoryUsedMB = 0;
|
float procMemoryUsedMB = 0;
|
||||||
suc = taosGetProcMemory(&procMemoryUsedMB);
|
suc = taosGetProcMemory(&procMemoryUsedMB);
|
||||||
if (!suc) {
|
if (!suc) {
|
||||||
monitorDebug("failed to get proc memory info");
|
mnDebug("failed to get proc memory info");
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprintf(sql, ", %f, %f, %d", procMemoryUsedMB, sysMemoryUsedMB, tsTotalMemoryMB);
|
return sprintf(sql, ", %f, %f, %d", procMemoryUsedMB, sysMemoryUsedMB, tsTotalMemoryMB);
|
||||||
|
@ -274,7 +274,7 @@ static int32_t monitorBuildCpuSql(char *sql) {
|
||||||
float sysCpuUsage = 0, procCpuUsage = 0;
|
float sysCpuUsage = 0, procCpuUsage = 0;
|
||||||
bool suc = taosGetCpuUsage(&sysCpuUsage, &procCpuUsage);
|
bool suc = taosGetCpuUsage(&sysCpuUsage, &procCpuUsage);
|
||||||
if (!suc) {
|
if (!suc) {
|
||||||
monitorDebug("failed to get cpu usage");
|
mnDebug("failed to get cpu usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sysCpuUsage <= procCpuUsage) {
|
if (sysCpuUsage <= procCpuUsage) {
|
||||||
|
@ -294,14 +294,14 @@ static int32_t monitorBuildBandSql(char *sql) {
|
||||||
float bandSpeedKb = 0;
|
float bandSpeedKb = 0;
|
||||||
bool suc = taosGetBandSpeed(&bandSpeedKb);
|
bool suc = taosGetBandSpeed(&bandSpeedKb);
|
||||||
if (!suc) {
|
if (!suc) {
|
||||||
monitorDebug("failed to get bandwidth speed");
|
mnDebug("failed to get bandwidth speed");
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprintf(sql, ", %f", bandSpeedKb);
|
return sprintf(sql, ", %f", bandSpeedKb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t monitorBuildReqSql(char *sql) {
|
static int32_t monitorBuildReqSql(char *sql) {
|
||||||
SDnodeStatisInfo info = dnodeGetStatisInfo();
|
SStatisInfo info = dnodeGetStatisInfo();
|
||||||
return sprintf(sql, ", %d, %d, %d)", info.httpReqNum, info.queryReqNum, info.submitReqNum);
|
return sprintf(sql, ", %d, %d, %d)", info.httpReqNum, info.queryReqNum, info.submitReqNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ static int32_t monitorBuildIoSql(char *sql) {
|
||||||
float readKB = 0, writeKB = 0;
|
float readKB = 0, writeKB = 0;
|
||||||
bool suc = taosGetProcIO(&readKB, &writeKB);
|
bool suc = taosGetProcIO(&readKB, &writeKB);
|
||||||
if (!suc) {
|
if (!suc) {
|
||||||
monitorDebug("failed to get io info");
|
mnDebug("failed to get io info");
|
||||||
}
|
}
|
||||||
|
|
||||||
return sprintf(sql, ", %f, %f", readKB, writeKB);
|
return sprintf(sql, ", %f, %f", readKB, writeKB);
|
||||||
|
@ -332,19 +332,19 @@ static void monitorSaveSystemInfo() {
|
||||||
taos_free_result(res);
|
taos_free_result(res);
|
||||||
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
monitorError("failed to save system info, reason:%s, sql:%s", tstrerror(code), tsMonitor.sql);
|
mnError("failed to save system info, reason:%s, sql:%s", tstrerror(code), tsMonitor.sql);
|
||||||
} else {
|
} else {
|
||||||
monitorDebug("successfully to save system info, sql:%s", tsMonitor.sql);
|
mnDebug("successfully to save system info, sql:%s", tsMonitor.sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void montiorExecSqlCb(void *param, TAOS_RES *result, int32_t code) {
|
static void montiorExecSqlCb(void *param, TAOS_RES *result, int32_t code) {
|
||||||
int32_t c = taos_errno(result);
|
int32_t c = taos_errno(result);
|
||||||
if (c != TSDB_CODE_SUCCESS) {
|
if (c != TSDB_CODE_SUCCESS) {
|
||||||
monitorError("save %s failed, reason:%s", (char *)param, tstrerror(c));
|
mnError("save %s failed, reason:%s", (char *)param, tstrerror(c));
|
||||||
} else {
|
} else {
|
||||||
int32_t rows = taos_affected_rows(result);
|
int32_t rows = taos_affected_rows(result);
|
||||||
monitorDebug("save %s succ, rows:%d", (char *)param, rows);
|
mnDebug("save %s succ, rows:%d", (char *)param, rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
taos_free_result(result);
|
taos_free_result(result);
|
||||||
|
@ -380,7 +380,7 @@ void monitorSaveAcctLog(SAcctMonitorObj *pMon) {
|
||||||
pMon->totalConns, pMon->maxConns,
|
pMon->totalConns, pMon->maxConns,
|
||||||
pMon->accessState);
|
pMon->accessState);
|
||||||
|
|
||||||
monitorDebug("save account info, sql:%s", sql);
|
mnDebug("save account info, sql:%s", sql);
|
||||||
taos_query_a(tsMonitor.conn, sql, montiorExecSqlCb, "account info");
|
taos_query_a(tsMonitor.conn, sql, montiorExecSqlCb, "account info");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -401,13 +401,13 @@ void monitorSaveLog(int32_t level, const char *const format, ...) {
|
||||||
len += sprintf(sql + len, "', '%s')", tsLocalEp);
|
len += sprintf(sql + len, "', '%s')", tsLocalEp);
|
||||||
sql[len++] = 0;
|
sql[len++] = 0;
|
||||||
|
|
||||||
monitorDebug("save log, sql: %s", sql);
|
mnDebug("save log, sql: %s", sql);
|
||||||
taos_query_a(tsMonitor.conn, sql, montiorExecSqlCb, "log");
|
taos_query_a(tsMonitor.conn, sql, montiorExecSqlCb, "log");
|
||||||
}
|
}
|
||||||
|
|
||||||
void monitorExecuteSQL(char *sql) {
|
void monitorExecuteSQL(char *sql) {
|
||||||
if (tsMonitor.state != MON_STATE_INITED) return;
|
if (tsMonitor.state != MON_STATE_INITED) return;
|
||||||
|
|
||||||
monitorDebug("execute sql:%s", sql);
|
mnDebug("execute sql:%s", sql);
|
||||||
taos_query_a(tsMonitor.conn, sql, montiorExecSqlCb, "sql");
|
taos_query_a(tsMonitor.conn, sql, montiorExecSqlCb, "sql");
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,7 @@ typedef struct SCreateDBInfo {
|
||||||
int32_t compressionLevel;
|
int32_t compressionLevel;
|
||||||
SStrToken precision;
|
SStrToken precision;
|
||||||
bool ignoreExists;
|
bool ignoreExists;
|
||||||
|
int8_t update;
|
||||||
|
|
||||||
SArray *keep;
|
SArray *keep;
|
||||||
} SCreateDBInfo;
|
} SCreateDBInfo;
|
||||||
|
|
|
@ -239,6 +239,7 @@ wal(Y) ::= WAL INTEGER(X). { Y = X; }
|
||||||
fsync(Y) ::= FSYNC INTEGER(X). { Y = X; }
|
fsync(Y) ::= FSYNC INTEGER(X). { Y = X; }
|
||||||
comp(Y) ::= COMP INTEGER(X). { Y = X; }
|
comp(Y) ::= COMP INTEGER(X). { Y = X; }
|
||||||
prec(Y) ::= PRECISION STRING(X). { Y = X; }
|
prec(Y) ::= PRECISION STRING(X). { Y = X; }
|
||||||
|
update(Y) ::= UPDATE INTEGER(X). { Y = X; }
|
||||||
|
|
||||||
%type db_optr {SCreateDBInfo}
|
%type db_optr {SCreateDBInfo}
|
||||||
db_optr(Y) ::= . {setDefaultCreateDbOption(&Y);}
|
db_optr(Y) ::= . {setDefaultCreateDbOption(&Y);}
|
||||||
|
@ -256,6 +257,7 @@ db_optr(Y) ::= db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtol(X.z
|
||||||
db_optr(Y) ::= db_optr(Z) comp(X). { Y = Z; Y.compressionLevel = strtol(X.z, NULL, 10); }
|
db_optr(Y) ::= db_optr(Z) comp(X). { Y = Z; Y.compressionLevel = strtol(X.z, NULL, 10); }
|
||||||
db_optr(Y) ::= db_optr(Z) prec(X). { Y = Z; Y.precision = X; }
|
db_optr(Y) ::= db_optr(Z) prec(X). { Y = Z; Y.precision = X; }
|
||||||
db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; }
|
db_optr(Y) ::= db_optr(Z) keep(X). { Y = Z; Y.keep = X; }
|
||||||
|
db_optr(Y) ::= db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); }
|
||||||
|
|
||||||
%type alter_db_optr {SCreateDBInfo}
|
%type alter_db_optr {SCreateDBInfo}
|
||||||
alter_db_optr(Y) ::= . { setDefaultCreateDbOption(&Y);}
|
alter_db_optr(Y) ::= . { setDefaultCreateDbOption(&Y);}
|
||||||
|
@ -267,6 +269,7 @@ alter_db_optr(Y) ::= alter_db_optr(Z) blocks(X). { Y = Z; Y.numOfBlocks = s
|
||||||
alter_db_optr(Y) ::= alter_db_optr(Z) comp(X). { Y = Z; Y.compressionLevel = strtol(X.z, NULL, 10); }
|
alter_db_optr(Y) ::= alter_db_optr(Z) comp(X). { Y = Z; Y.compressionLevel = strtol(X.z, NULL, 10); }
|
||||||
alter_db_optr(Y) ::= alter_db_optr(Z) wal(X). { Y = Z; Y.walLevel = strtol(X.z, NULL, 10); }
|
alter_db_optr(Y) ::= alter_db_optr(Z) wal(X). { Y = Z; Y.walLevel = strtol(X.z, NULL, 10); }
|
||||||
alter_db_optr(Y) ::= alter_db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtol(X.z, NULL, 10); }
|
alter_db_optr(Y) ::= alter_db_optr(Z) fsync(X). { Y = Z; Y.fsyncPeriod = strtol(X.z, NULL, 10); }
|
||||||
|
alter_db_optr(Y) ::= alter_db_optr(Z) update(X). { Y = Z; Y.update = strtol(X.z, NULL, 10); }
|
||||||
|
|
||||||
%type typename {TAOS_FIELD}
|
%type typename {TAOS_FIELD}
|
||||||
typename(A) ::= ids(X). {
|
typename(A) ::= ids(X). {
|
||||||
|
|
|
@ -121,9 +121,9 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cond.start != NULL) {
|
if (cond.start != NULL) {
|
||||||
iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->keyInfo.type, TSDB_ORDER_ASC);
|
iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->type, TSDB_ORDER_ASC);
|
||||||
} else {
|
} else {
|
||||||
iter = tSkipListCreateIterFromVal(pSkipList, (char*)(cond.end ? cond.end->v: NULL), pSkipList->keyInfo.type, TSDB_ORDER_DESC);
|
iter = tSkipListCreateIterFromVal(pSkipList, (char*)(cond.end ? cond.end->v: NULL), pSkipList->type, TSDB_ORDER_DESC);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cond.start != NULL) {
|
if (cond.start != NULL) {
|
||||||
|
@ -138,7 +138,7 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableKeyInfo info = {.pTable = *(void**)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
|
STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
|
||||||
taosArrayPush(result, &info);
|
taosArrayPush(result, &info);
|
||||||
}
|
}
|
||||||
} else if (optr == TSDB_RELATION_GREATER || optr == TSDB_RELATION_GREATER_EQUAL) { // greater equal
|
} else if (optr == TSDB_RELATION_GREATER || optr == TSDB_RELATION_GREATER_EQUAL) { // greater equal
|
||||||
|
@ -156,7 +156,7 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
|
||||||
if (ret == 0 && optr == TSDB_RELATION_GREATER) {
|
if (ret == 0 && optr == TSDB_RELATION_GREATER) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
STableKeyInfo info = {.pTable = *(void**)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
|
STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
|
||||||
taosArrayPush(result, &info);
|
taosArrayPush(result, &info);
|
||||||
comp = false;
|
comp = false;
|
||||||
}
|
}
|
||||||
|
@ -171,14 +171,14 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableKeyInfo info = {.pTable = *(void**)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
|
STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
|
||||||
taosArrayPush(result, &info);
|
taosArrayPush(result, &info);
|
||||||
}
|
}
|
||||||
|
|
||||||
tSkipListDestroyIter(iter);
|
tSkipListDestroyIter(iter);
|
||||||
|
|
||||||
comp = true;
|
comp = true;
|
||||||
iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->keyInfo.type, TSDB_ORDER_DESC);
|
iter = tSkipListCreateIterFromVal(pSkipList, (char*) cond.start->v, pSkipList->type, TSDB_ORDER_DESC);
|
||||||
while(tSkipListIterNext(iter)) {
|
while(tSkipListIterNext(iter)) {
|
||||||
SSkipListNode* pNode = tSkipListIterGet(iter);
|
SSkipListNode* pNode = tSkipListIterGet(iter);
|
||||||
comp = comp && (pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v) == 0);
|
comp = comp && (pQueryInfo->compare(SL_GET_NODE_KEY(pSkipList, pNode), cond.start->v) == 0);
|
||||||
|
@ -186,7 +186,7 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableKeyInfo info = {.pTable = *(void**)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
|
STableKeyInfo info = {.pTable = (void*)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
|
||||||
taosArrayPush(result, &info);
|
taosArrayPush(result, &info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
|
||||||
if (ret == 0 && optr == TSDB_RELATION_LESS) {
|
if (ret == 0 && optr == TSDB_RELATION_LESS) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
STableKeyInfo info = {.pTable = *(void **)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
|
STableKeyInfo info = {.pTable = (void *)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
|
||||||
taosArrayPush(result, &info);
|
taosArrayPush(result, &info);
|
||||||
comp = false; // no need to compare anymore
|
comp = false; // no need to compare anymore
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ static void tQueryIndexColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo, SArr
|
||||||
bool isnull = isNull(SL_GET_NODE_KEY(pSkipList, pNode), pQueryInfo->sch.type);
|
bool isnull = isNull(SL_GET_NODE_KEY(pSkipList, pNode), pQueryInfo->sch.type);
|
||||||
if ((pQueryInfo->optr == TSDB_RELATION_ISNULL && isnull) ||
|
if ((pQueryInfo->optr == TSDB_RELATION_ISNULL && isnull) ||
|
||||||
(pQueryInfo->optr == TSDB_RELATION_NOTNULL && (!isnull))) {
|
(pQueryInfo->optr == TSDB_RELATION_NOTNULL && (!isnull))) {
|
||||||
STableKeyInfo info = {.pTable = *(void **)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
|
STableKeyInfo info = {.pTable = (void *)SL_GET_NODE_DATA(pNode), .lastKey = TSKEY_INITIAL_VAL};
|
||||||
taosArrayPush(result, &info);
|
taosArrayPush(result, &info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,7 @@ static void tSQLBinaryTraverseOnSkipList(tExprNode *pExpr, SArray *pResult, SSki
|
||||||
while (tSkipListIterNext(iter)) {
|
while (tSkipListIterNext(iter)) {
|
||||||
SSkipListNode *pNode = tSkipListIterGet(iter);
|
SSkipListNode *pNode = tSkipListIterGet(iter);
|
||||||
if (filterItem(pExpr, pNode, param)) {
|
if (filterItem(pExpr, pNode, param)) {
|
||||||
taosArrayPush(pResult, SL_GET_NODE_DATA(pNode));
|
taosArrayPush(pResult, &(SL_GET_NODE_DATA(pNode)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tSkipListDestroyIter(iter);
|
tSkipListDestroyIter(iter);
|
||||||
|
@ -284,7 +284,7 @@ static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo,
|
||||||
SSkipListNode *pNode = tSkipListIterGet(iter);
|
SSkipListNode *pNode = tSkipListIterGet(iter);
|
||||||
char * pData = SL_GET_NODE_DATA(pNode);
|
char * pData = SL_GET_NODE_DATA(pNode);
|
||||||
|
|
||||||
tstr *name = (tstr*) tsdbGetTableName(*(void**) pData);
|
tstr *name = (tstr*) tsdbGetTableName((void*) pData);
|
||||||
|
|
||||||
// todo speed up by using hash
|
// todo speed up by using hash
|
||||||
if (pQueryInfo->sch.colId == TSDB_TBNAME_COLUMN_INDEX) {
|
if (pQueryInfo->sch.colId == TSDB_TBNAME_COLUMN_INDEX) {
|
||||||
|
@ -298,7 +298,7 @@ static void tQueryIndexlessColumn(SSkipList* pSkipList, tQueryInfo* pQueryInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addToResult) {
|
if (addToResult) {
|
||||||
STableKeyInfo info = {.pTable = *(void**)pData, .lastKey = TSKEY_INITIAL_VAL};
|
STableKeyInfo info = {.pTable = (void*)pData, .lastKey = TSKEY_INITIAL_VAL};
|
||||||
taosArrayPush(res, &info);
|
taosArrayPush(res, &info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1019,7 +1019,7 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
|
||||||
bool hasTimeWindow = false;
|
bool hasTimeWindow = false;
|
||||||
STimeWindow win = getActiveTimeWindow(pWindowResInfo, ts, pQuery);
|
STimeWindow win = getActiveTimeWindow(pWindowResInfo, ts, pQuery);
|
||||||
if (setWindowOutputBufByKey(pRuntimeEnv, pWindowResInfo, pDataBlockInfo, &win, masterScan, &hasTimeWindow) != TSDB_CODE_SUCCESS) {
|
if (setWindowOutputBufByKey(pRuntimeEnv, pWindowResInfo, pDataBlockInfo, &win, masterScan, &hasTimeWindow) != TSDB_CODE_SUCCESS) {
|
||||||
taosTFree(sasArray);
|
tfree(sasArray);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1081,10 +1081,10 @@ static void blockwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(sasArray[i].data);
|
tfree(sasArray[i].data);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(sasArray);
|
tfree(sasArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, char *pData, int16_t type, int16_t bytes, int32_t groupIndex) {
|
static int32_t setGroupResultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, char *pData, int16_t type, int16_t bytes, int32_t groupIndex) {
|
||||||
|
@ -1410,7 +1410,7 @@ static void rowwiseApplyFunctions(SQueryRuntimeEnv *pRuntimeEnv, SDataStatis *pS
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(sasArray[i].data);
|
tfree(sasArray[i].data);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(sasArray);
|
free(sasArray);
|
||||||
|
@ -1596,7 +1596,7 @@ static int32_t setCtxTagColumnInfo(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx
|
||||||
p->tagInfo.numOfTagCols = num;
|
p->tagInfo.numOfTagCols = num;
|
||||||
p->tagInfo.tagsLen = tagLen;
|
p->tagInfo.tagsLen = tagLen;
|
||||||
} else {
|
} else {
|
||||||
taosTFree(pTagCtx);
|
tfree(pTagCtx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1706,7 +1706,7 @@ static int32_t setupQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv, int16_t order
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
_clean:
|
_clean:
|
||||||
taosTFree(pRuntimeEnv->pCtx);
|
tfree(pRuntimeEnv->pCtx);
|
||||||
|
|
||||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
@ -1744,10 +1744,10 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tVariantDestroy(&pCtx->tag);
|
tVariantDestroy(&pCtx->tag);
|
||||||
taosTFree(pCtx->tagInfo.pTagCtxList);
|
tfree(pCtx->tagInfo.pTagCtxList);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pRuntimeEnv->pCtx);
|
tfree(pRuntimeEnv->pCtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
pRuntimeEnv->pFillInfo = taosDestroyFillInfo(pRuntimeEnv->pFillInfo);
|
pRuntimeEnv->pFillInfo = taosDestroyFillInfo(pRuntimeEnv->pFillInfo);
|
||||||
|
@ -1756,8 +1756,8 @@ static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) {
|
||||||
doFreeQueryHandle(pQInfo);
|
doFreeQueryHandle(pQInfo);
|
||||||
|
|
||||||
pRuntimeEnv->pTSBuf = tsBufDestroy(pRuntimeEnv->pTSBuf);
|
pRuntimeEnv->pTSBuf = tsBufDestroy(pRuntimeEnv->pTSBuf);
|
||||||
taosTFree(pRuntimeEnv->keyBuf);
|
tfree(pRuntimeEnv->keyBuf);
|
||||||
taosTFree(pRuntimeEnv->rowCellInfoOffset);
|
tfree(pRuntimeEnv->rowCellInfoOffset);
|
||||||
|
|
||||||
taosHashCleanup(pRuntimeEnv->pResultRowHashTable);
|
taosHashCleanup(pRuntimeEnv->pResultRowHashTable);
|
||||||
pRuntimeEnv->pResultRowHashTable = NULL;
|
pRuntimeEnv->pResultRowHashTable = NULL;
|
||||||
|
@ -2985,8 +2985,8 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
|
||||||
STableQueryInfo **pTableList = malloc(POINTER_BYTES * size);
|
STableQueryInfo **pTableList = malloc(POINTER_BYTES * size);
|
||||||
|
|
||||||
if (pTableList == NULL || posList == NULL) {
|
if (pTableList == NULL || posList == NULL) {
|
||||||
taosTFree(posList);
|
tfree(posList);
|
||||||
taosTFree(pTableList);
|
tfree(pTableList);
|
||||||
|
|
||||||
qError("QInfo:%p failed alloc memory", pQInfo);
|
qError("QInfo:%p failed alloc memory", pQInfo);
|
||||||
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
|
||||||
|
@ -3010,12 +3010,12 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
|
||||||
|
|
||||||
// there is no data in current group
|
// there is no data in current group
|
||||||
if (numOfTables == 0) {
|
if (numOfTables == 0) {
|
||||||
taosTFree(posList);
|
tfree(posList);
|
||||||
taosTFree(pTableList);
|
tfree(pTableList);
|
||||||
return 0;
|
return 0;
|
||||||
} else if (numOfTables == 1) { // no need to merge results since only one table in each group
|
} else if (numOfTables == 1) { // no need to merge results since only one table in each group
|
||||||
taosTFree(posList);
|
tfree(posList);
|
||||||
taosTFree(pTableList);
|
tfree(pTableList);
|
||||||
|
|
||||||
SGroupResInfo* pGroupResInfo = &pQInfo->groupResInfo;
|
SGroupResInfo* pGroupResInfo = &pQInfo->groupResInfo;
|
||||||
|
|
||||||
|
@ -3045,9 +3045,9 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
|
||||||
if (IS_QUERY_KILLED(pQInfo)) {
|
if (IS_QUERY_KILLED(pQInfo)) {
|
||||||
qDebug("QInfo:%p it is already killed, abort", pQInfo);
|
qDebug("QInfo:%p it is already killed, abort", pQInfo);
|
||||||
|
|
||||||
taosTFree(pTableList);
|
tfree(pTableList);
|
||||||
taosTFree(posList);
|
tfree(posList);
|
||||||
taosTFree(pTree);
|
tfree(pTree);
|
||||||
longjmp(pRuntimeEnv->env, TSDB_CODE_TSC_QUERY_CANCELLED);
|
longjmp(pRuntimeEnv->env, TSDB_CODE_TSC_QUERY_CANCELLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3118,9 +3118,9 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
|
||||||
if (flushFromResultBuf(pRuntimeEnv, &pQInfo->groupResInfo) != TSDB_CODE_SUCCESS) {
|
if (flushFromResultBuf(pRuntimeEnv, &pQInfo->groupResInfo) != TSDB_CODE_SUCCESS) {
|
||||||
qError("QInfo:%p failed to flush data into temp file, abort query", pQInfo);
|
qError("QInfo:%p failed to flush data into temp file, abort query", pQInfo);
|
||||||
|
|
||||||
taosTFree(pTree);
|
tfree(pTree);
|
||||||
taosTFree(pTableList);
|
tfree(pTableList);
|
||||||
taosTFree(posList);
|
tfree(posList);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3133,12 +3133,12 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
|
||||||
|
|
||||||
qDebug("QInfo:%p result merge completed for group:%d, elapsed time:%" PRId64 " ms", pQInfo, pQInfo->groupIndex, endt - startt);
|
qDebug("QInfo:%p result merge completed for group:%d, elapsed time:%" PRId64 " ms", pQInfo, pQInfo->groupIndex, endt - startt);
|
||||||
|
|
||||||
taosTFree(pTableList);
|
tfree(pTableList);
|
||||||
taosTFree(posList);
|
tfree(posList);
|
||||||
taosTFree(pTree);
|
tfree(pTree);
|
||||||
|
|
||||||
// taosTFree(pResultInfo);
|
// tfree(pResultInfo);
|
||||||
// taosTFree(buf);
|
// tfree(buf);
|
||||||
|
|
||||||
return pQInfo->groupResInfo.numOfDataPages;
|
return pQInfo->groupResInfo.numOfDataPages;
|
||||||
}
|
}
|
||||||
|
@ -5880,13 +5880,13 @@ static int32_t convertQueryMsg(SQueryTableMsg *pQueryMsg, SArray **pTableIdList,
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
_cleanup:
|
_cleanup:
|
||||||
taosTFree(*pExpr);
|
tfree(*pExpr);
|
||||||
taosArrayDestroy(*pTableIdList);
|
taosArrayDestroy(*pTableIdList);
|
||||||
*pTableIdList = NULL;
|
*pTableIdList = NULL;
|
||||||
taosTFree(*tbnameCond);
|
tfree(*tbnameCond);
|
||||||
taosTFree(*groupbyCols);
|
tfree(*groupbyCols);
|
||||||
taosTFree(*tagCols);
|
tfree(*tagCols);
|
||||||
taosTFree(*tagCond);
|
tfree(*tagCond);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -5937,7 +5937,7 @@ static int32_t createQFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo *
|
||||||
code = buildAirthmeticExprFromMsg(&pExprs[i], pQueryMsg);
|
code = buildAirthmeticExprFromMsg(&pExprs[i], pQueryMsg);
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
taosTFree(pExprs);
|
tfree(pExprs);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5976,7 +5976,7 @@ static int32_t createQFunctionExprFromMsg(SQueryTableMsg *pQueryMsg, SExprInfo *
|
||||||
int32_t param = (int32_t)pExprs[i].base.arg[0].argValue.i64;
|
int32_t param = (int32_t)pExprs[i].base.arg[0].argValue.i64;
|
||||||
if (getResultDataInfo(type, bytes, pExprs[i].base.functionId, param, &pExprs[i].type, &pExprs[i].bytes,
|
if (getResultDataInfo(type, bytes, pExprs[i].base.functionId, param, &pExprs[i].type, &pExprs[i].bytes,
|
||||||
&pExprs[i].interBytes, 0, isSuperTable) != TSDB_CODE_SUCCESS) {
|
&pExprs[i].interBytes, 0, isSuperTable) != TSDB_CODE_SUCCESS) {
|
||||||
taosTFree(pExprs);
|
tfree(pExprs);
|
||||||
return TSDB_CODE_QRY_INVALID_MSG;
|
return TSDB_CODE_QRY_INVALID_MSG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6352,7 +6352,7 @@ _cleanup_query:
|
||||||
free(pGroupbyExpr);
|
free(pGroupbyExpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pTagCols);
|
tfree(pTagCols);
|
||||||
for (int32_t i = 0; i < numOfOutput; ++i) {
|
for (int32_t i = 0; i < numOfOutput; ++i) {
|
||||||
SExprInfo* pExprInfo = &pExprs[i];
|
SExprInfo* pExprInfo = &pExprs[i];
|
||||||
if (pExprInfo->pExpr != NULL) {
|
if (pExprInfo->pExpr != NULL) {
|
||||||
|
@ -6360,7 +6360,7 @@ _cleanup_query:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pExprs);
|
tfree(pExprs);
|
||||||
|
|
||||||
_cleanup:
|
_cleanup:
|
||||||
freeQInfo(pQInfo);
|
freeQInfo(pQInfo);
|
||||||
|
@ -6479,19 +6479,19 @@ static void freeQInfo(SQInfo *pQInfo) {
|
||||||
if (pQuery != NULL) {
|
if (pQuery != NULL) {
|
||||||
if (pQuery->sdata != NULL) {
|
if (pQuery->sdata != NULL) {
|
||||||
for (int32_t col = 0; col < pQuery->numOfOutput; ++col) {
|
for (int32_t col = 0; col < pQuery->numOfOutput; ++col) {
|
||||||
taosTFree(pQuery->sdata[col]);
|
tfree(pQuery->sdata[col]);
|
||||||
}
|
}
|
||||||
taosTFree(pQuery->sdata);
|
tfree(pQuery->sdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pQuery->fillVal != NULL) {
|
if (pQuery->fillVal != NULL) {
|
||||||
taosTFree(pQuery->fillVal);
|
tfree(pQuery->fillVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < pQuery->numOfFilterCols; ++i) {
|
for (int32_t i = 0; i < pQuery->numOfFilterCols; ++i) {
|
||||||
SSingleColumnFilterInfo *pColFilter = &pQuery->pFilterInfo[i];
|
SSingleColumnFilterInfo *pColFilter = &pQuery->pFilterInfo[i];
|
||||||
if (pColFilter->numOfFilters > 0) {
|
if (pColFilter->numOfFilters > 0) {
|
||||||
taosTFree(pColFilter->pFilters);
|
tfree(pColFilter->pFilters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6504,31 +6504,31 @@ static void freeQInfo(SQInfo *pQInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pQuery->pSelectExpr);
|
tfree(pQuery->pSelectExpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pQuery->pGroupbyExpr != NULL) {
|
if (pQuery->pGroupbyExpr != NULL) {
|
||||||
taosArrayDestroy(pQuery->pGroupbyExpr->columnInfo);
|
taosArrayDestroy(pQuery->pGroupbyExpr->columnInfo);
|
||||||
taosTFree(pQuery->pGroupbyExpr);
|
tfree(pQuery->pGroupbyExpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pQuery->tagColList);
|
tfree(pQuery->tagColList);
|
||||||
taosTFree(pQuery->pFilterInfo);
|
tfree(pQuery->pFilterInfo);
|
||||||
|
|
||||||
if (pQuery->colList != NULL) {
|
if (pQuery->colList != NULL) {
|
||||||
for (int32_t i = 0; i < pQuery->numOfCols; i++) {
|
for (int32_t i = 0; i < pQuery->numOfCols; i++) {
|
||||||
SColumnInfo *column = pQuery->colList + i;
|
SColumnInfo *column = pQuery->colList + i;
|
||||||
freeColumnFilterInfo(column->filters, column->numOfFilters);
|
freeColumnFilterInfo(column->filters, column->numOfFilters);
|
||||||
}
|
}
|
||||||
taosTFree(pQuery->colList);
|
tfree(pQuery->colList);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pQuery);
|
tfree(pQuery);
|
||||||
}
|
}
|
||||||
|
|
||||||
doDestroyTableQueryInfo(&pQInfo->tableqinfoGroupInfo);
|
doDestroyTableQueryInfo(&pQInfo->tableqinfoGroupInfo);
|
||||||
|
|
||||||
taosTFree(pQInfo->pBuf);
|
tfree(pQInfo->pBuf);
|
||||||
tsdbDestroyTableGroup(&pQInfo->tableGroupInfo);
|
tsdbDestroyTableGroup(&pQInfo->tableGroupInfo);
|
||||||
taosArrayDestroy(pQInfo->arrTableIdInfo);
|
taosArrayDestroy(pQInfo->arrTableIdInfo);
|
||||||
|
|
||||||
|
@ -6536,7 +6536,7 @@ static void freeQInfo(SQInfo *pQInfo) {
|
||||||
|
|
||||||
qDebug("QInfo:%p QInfo is freed", pQInfo);
|
qDebug("QInfo:%p QInfo is freed", pQInfo);
|
||||||
|
|
||||||
taosTFree(pQInfo);
|
tfree(pQInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t getResultSize(SQInfo *pQInfo, int64_t *numOfRows) {
|
static size_t getResultSize(SQInfo *pQInfo, int64_t *numOfRows) {
|
||||||
|
@ -7231,7 +7231,7 @@ void qCleanupQueryMgmt(void* pQMgmt) {
|
||||||
|
|
||||||
taosCacheCleanup(pqinfoPool);
|
taosCacheCleanup(pqinfoPool);
|
||||||
pthread_mutex_destroy(&pQueryMgmt->lock);
|
pthread_mutex_destroy(&pQueryMgmt->lock);
|
||||||
taosTFree(pQueryMgmt);
|
tfree(pQueryMgmt);
|
||||||
|
|
||||||
qDebug("vgId:%d queryMgmt cleanup completed", vgId);
|
qDebug("vgId:%d queryMgmt cleanup completed", vgId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ void* destoryExtMemBuffer(tExtMemBuffer *pMemBuffer) {
|
||||||
// release flush out info link
|
// release flush out info link
|
||||||
SExtFileInfo *pFileMeta = &pMemBuffer->fileMeta;
|
SExtFileInfo *pFileMeta = &pMemBuffer->fileMeta;
|
||||||
if (pFileMeta->flushoutData.nAllocSize != 0 && pFileMeta->flushoutData.pFlushoutInfo != NULL) {
|
if (pFileMeta->flushoutData.nAllocSize != 0 && pFileMeta->flushoutData.pFlushoutInfo != NULL) {
|
||||||
taosTFree(pFileMeta->flushoutData.pFlushoutInfo);
|
tfree(pFileMeta->flushoutData.pFlushoutInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// release all in-memory buffer pages
|
// release all in-memory buffer pages
|
||||||
|
@ -72,7 +72,7 @@ void* destoryExtMemBuffer(tExtMemBuffer *pMemBuffer) {
|
||||||
while (pFilePages != NULL) {
|
while (pFilePages != NULL) {
|
||||||
tFilePagesItem *pTmp = pFilePages;
|
tFilePagesItem *pTmp = pFilePages;
|
||||||
pFilePages = pFilePages->pNext;
|
pFilePages = pFilePages->pNext;
|
||||||
taosTFree(pTmp);
|
tfree(pTmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// close temp file
|
// close temp file
|
||||||
|
@ -87,8 +87,8 @@ void* destoryExtMemBuffer(tExtMemBuffer *pMemBuffer) {
|
||||||
|
|
||||||
destroyColumnModel(pMemBuffer->pColumnModel);
|
destroyColumnModel(pMemBuffer->pColumnModel);
|
||||||
|
|
||||||
taosTFree(pMemBuffer->path);
|
tfree(pMemBuffer->path);
|
||||||
taosTFree(pMemBuffer);
|
tfree(pMemBuffer);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ int32_t tExtMemBufferFlush(tExtMemBuffer *pMemBuffer) {
|
||||||
tFilePagesItem *ptmp = first;
|
tFilePagesItem *ptmp = first;
|
||||||
first = first->pNext;
|
first = first->pNext;
|
||||||
|
|
||||||
taosTFree(ptmp); // release all data in memory buffer
|
tfree(ptmp); // release all data in memory buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
fflush(pMemBuffer->file); // flush to disk
|
fflush(pMemBuffer->file); // flush to disk
|
||||||
|
@ -300,7 +300,7 @@ void tExtMemBufferClear(tExtMemBuffer *pMemBuffer) {
|
||||||
while (first != NULL) {
|
while (first != NULL) {
|
||||||
tFilePagesItem *ptmp = first;
|
tFilePagesItem *ptmp = first;
|
||||||
first = first->pNext;
|
first = first->pNext;
|
||||||
taosTFree(ptmp);
|
tfree(ptmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
pMemBuffer->fileMeta.numOfElemsInFile = 0;
|
pMemBuffer->fileMeta.numOfElemsInFile = 0;
|
||||||
|
@ -802,7 +802,7 @@ void destroyColumnModel(SColumnModel *pModel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pModel);
|
tfree(pModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printBinaryData(char *data, int32_t len) {
|
static void printBinaryData(char *data, int32_t len) {
|
||||||
|
@ -1087,5 +1087,5 @@ void tOrderDescDestroy(tOrderDescriptor *pDesc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyColumnModel(pDesc->pColumnModel);
|
destroyColumnModel(pDesc->pColumnModel);
|
||||||
taosTFree(pDesc);
|
tfree(pDesc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,18 +121,18 @@ void* taosDestroyFillInfo(SFillInfo* pFillInfo) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pFillInfo->prevValues);
|
tfree(pFillInfo->prevValues);
|
||||||
taosTFree(pFillInfo->nextValues);
|
tfree(pFillInfo->nextValues);
|
||||||
taosTFree(pFillInfo->pTags);
|
tfree(pFillInfo->pTags);
|
||||||
|
|
||||||
for(int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
for(int32_t i = 0; i < pFillInfo->numOfCols; ++i) {
|
||||||
taosTFree(pFillInfo->pData[i]);
|
tfree(pFillInfo->pData[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pFillInfo->pData);
|
tfree(pFillInfo->pData);
|
||||||
taosTFree(pFillInfo->pFillCol);
|
tfree(pFillInfo->pFillCol);
|
||||||
|
|
||||||
taosTFree(pFillInfo);
|
tfree(pFillInfo);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -457,7 +457,7 @@ static int32_t fillResultImpl(SFillInfo* pFillInfo, tFilePage** data, int32_t ou
|
||||||
if (pFillInfo->index >= pFillInfo->numOfRows || pFillInfo->numOfCurrent >= outputRows) {
|
if (pFillInfo->index >= pFillInfo->numOfRows || pFillInfo->numOfCurrent >= outputRows) {
|
||||||
/* the raw data block is exhausted, next value does not exists */
|
/* the raw data block is exhausted, next value does not exists */
|
||||||
if (pFillInfo->index >= pFillInfo->numOfRows) {
|
if (pFillInfo->index >= pFillInfo->numOfRows) {
|
||||||
taosTFree(*next);
|
tfree(*next);
|
||||||
}
|
}
|
||||||
|
|
||||||
pFillInfo->numOfTotal += pFillInfo->numOfCurrent;
|
pFillInfo->numOfTotal += pFillInfo->numOfCurrent;
|
||||||
|
|
|
@ -168,7 +168,7 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) {
|
||||||
(*pHisto)->numOfEntries += 1;
|
(*pHisto)->numOfEntries += 1;
|
||||||
}
|
}
|
||||||
} else { /* insert a new slot */
|
} else { /* insert a new slot */
|
||||||
if ((*pHisto)->numOfElems > 1 && idx < (*pHisto)->numOfEntries) {
|
if ((*pHisto)->numOfElems >= 1 && idx < (*pHisto)->numOfEntries) {
|
||||||
if (idx > 0) {
|
if (idx > 0) {
|
||||||
assert((*pHisto)->elems[idx - 1].val <= val);
|
assert((*pHisto)->elems[idx - 1].val <= val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -500,7 +500,7 @@ void destroyAllSelectClause(SSubclauseInfo *pClause) {
|
||||||
doDestroyQuerySql(pQuerySql);
|
doDestroyQuerySql(pQuerySql);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pClause->pClause);
|
tfree(pClause->pClause);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCreateTableSQL *tSetCreateSQLElems(SArray *pCols, SArray *pTags, SStrToken *pStableName,
|
SCreateTableSQL *tSetCreateSQLElems(SArray *pCols, SArray *pTags, SStrToken *pStableName,
|
||||||
|
@ -570,12 +570,12 @@ void SQLInfoDestroy(SSqlInfo *pInfo) {
|
||||||
taosArrayDestroy(pCreateTableInfo->colInfo.pTagColumns);
|
taosArrayDestroy(pCreateTableInfo->colInfo.pTagColumns);
|
||||||
|
|
||||||
taosArrayDestroyEx(pCreateTableInfo->usingInfo.pTagVals, freeVariant);
|
taosArrayDestroyEx(pCreateTableInfo->usingInfo.pTagVals, freeVariant);
|
||||||
taosTFree(pInfo->pCreateTableInfo);
|
tfree(pInfo->pCreateTableInfo);
|
||||||
} else if (pInfo->type == TSDB_SQL_ALTER_TABLE) {
|
} else if (pInfo->type == TSDB_SQL_ALTER_TABLE) {
|
||||||
taosArrayDestroyEx(pInfo->pAlterInfo->varList, freeVariant);
|
taosArrayDestroyEx(pInfo->pAlterInfo->varList, freeVariant);
|
||||||
taosArrayDestroy(pInfo->pAlterInfo->pAddColumns);
|
taosArrayDestroy(pInfo->pAlterInfo->pAddColumns);
|
||||||
|
|
||||||
taosTFree(pInfo->pAlterInfo);
|
tfree(pInfo->pAlterInfo);
|
||||||
} else {
|
} else {
|
||||||
if (pInfo->pDCLInfo != NULL && pInfo->pDCLInfo->nAlloc > 0) {
|
if (pInfo->pDCLInfo != NULL && pInfo->pDCLInfo->nAlloc > 0) {
|
||||||
free(pInfo->pDCLInfo->a);
|
free(pInfo->pDCLInfo->a);
|
||||||
|
@ -585,7 +585,7 @@ void SQLInfoDestroy(SSqlInfo *pInfo) {
|
||||||
taosArrayDestroyEx(pInfo->pDCLInfo->dbOpt.keep, freeVariant);
|
taosArrayDestroyEx(pInfo->pDCLInfo->dbOpt.keep, freeVariant);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosTFree(pInfo->pDCLInfo);
|
tfree(pInfo->pDCLInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -801,5 +801,6 @@ void setDefaultCreateDbOption(SCreateDBInfo *pDBInfo) {
|
||||||
pDBInfo->quorum = -1;
|
pDBInfo->quorum = -1;
|
||||||
pDBInfo->keep = NULL;
|
pDBInfo->keep = NULL;
|
||||||
|
|
||||||
|
pDBInfo->update = -1;
|
||||||
memset(&pDBInfo->precision, 0, sizeof(SStrToken));
|
memset(&pDBInfo->precision, 0, sizeof(SStrToken));
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,8 +361,8 @@ void tMemBucketDestroy(tMemBucket *pBucket) {
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyResultBuf(pBucket->pBuffer);
|
destroyResultBuf(pBucket->pBuffer);
|
||||||
taosTFree(pBucket->pSlots);
|
tfree(pBucket->pSlots);
|
||||||
taosTFree(pBucket);
|
tfree(pBucket);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataType) {
|
void tMemBucketUpdateBoundingBox(MinMaxEntry *r, const char *data, int32_t dataType) {
|
||||||
|
@ -680,7 +680,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
|
||||||
}
|
}
|
||||||
|
|
||||||
double val = (1 - fraction) * td + fraction * nd;
|
double val = (1 - fraction) * td + fraction * nd;
|
||||||
taosTFree(buffer);
|
tfree(buffer);
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
} else { // incur a second round bucket split
|
} else { // incur a second round bucket split
|
||||||
|
|
|
@ -267,7 +267,7 @@ static char* evicOneDataPage(SDiskbasedResultBuf* pResultBuf) {
|
||||||
assert(d->pn == pn);
|
assert(d->pn == pn);
|
||||||
|
|
||||||
d->pn = NULL;
|
d->pn = NULL;
|
||||||
taosTFree(pn);
|
tfree(pn);
|
||||||
|
|
||||||
bufPage = flushPageToDisk(pResultBuf, d);
|
bufPage = flushPageToDisk(pResultBuf, d);
|
||||||
}
|
}
|
||||||
|
@ -418,7 +418,7 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf) {
|
||||||
}
|
}
|
||||||
|
|
||||||
unlink(pResultBuf->path);
|
unlink(pResultBuf->path);
|
||||||
taosTFree(pResultBuf->path);
|
tfree(pResultBuf->path);
|
||||||
|
|
||||||
SHashMutableIterator* iter = taosHashCreateIter(pResultBuf->groupSet);
|
SHashMutableIterator* iter = taosHashCreateIter(pResultBuf->groupSet);
|
||||||
while(taosHashIterNext(iter)) {
|
while(taosHashIterNext(iter)) {
|
||||||
|
@ -426,8 +426,8 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf) {
|
||||||
size_t n = taosArrayGetSize(*p);
|
size_t n = taosArrayGetSize(*p);
|
||||||
for(int32_t i = 0; i < n; ++i) {
|
for(int32_t i = 0; i < n; ++i) {
|
||||||
SPageInfo* pi = taosArrayGetP(*p, i);
|
SPageInfo* pi = taosArrayGetP(*p, i);
|
||||||
taosTFree(pi->pData);
|
tfree(pi->pData);
|
||||||
taosTFree(pi);
|
tfree(pi);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(*p);
|
taosArrayDestroy(*p);
|
||||||
|
@ -440,8 +440,8 @@ void destroyResultBuf(SDiskbasedResultBuf* pResultBuf) {
|
||||||
taosHashCleanup(pResultBuf->groupSet);
|
taosHashCleanup(pResultBuf->groupSet);
|
||||||
taosHashCleanup(pResultBuf->all);
|
taosHashCleanup(pResultBuf->all);
|
||||||
|
|
||||||
taosTFree(pResultBuf->assistBuf);
|
tfree(pResultBuf->assistBuf);
|
||||||
taosTFree(pResultBuf);
|
tfree(pResultBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
SPageInfo* getLastPageInfo(SIDList pList) {
|
SPageInfo* getLastPageInfo(SIDList pList) {
|
||||||
|
|
|
@ -155,6 +155,7 @@ static SKeyword keywordTable[] = {
|
||||||
{"INSERT", TK_INSERT},
|
{"INSERT", TK_INSERT},
|
||||||
{"INTO", TK_INTO},
|
{"INTO", TK_INTO},
|
||||||
{"VALUES", TK_VALUES},
|
{"VALUES", TK_VALUES},
|
||||||
|
{"UPDATE", TK_UPDATE},
|
||||||
{"RESET", TK_RESET},
|
{"RESET", TK_RESET},
|
||||||
{"QUERY", TK_QUERY},
|
{"QUERY", TK_QUERY},
|
||||||
{"ADD", TK_ADD},
|
{"ADD", TK_ADD},
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue