From d9daf767106073cbdc55f7afa2904632249e7192 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 20 Oct 2022 10:18:28 +0800 Subject: [PATCH 01/10] fix: invalid read problem --- source/dnode/vnode/src/tsdb/tsdbOpen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index efc74b68ba..3fee0951a0 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -38,7 +38,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee int slen = 0; *ppTsdb = NULL; - slen = strlen(pVnode->path) + strlen(dir) + 2; + slen = TSDB_FILENAME_LEN; // create handle pTsdb = (STsdb *)taosMemoryCalloc(1, sizeof(*pTsdb) + slen); @@ -48,7 +48,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee } pTsdb->path = (char *)&pTsdb[1]; - sprintf(pTsdb->path, "%s%s%s", pVnode->path, TD_DIRSEP, dir); + snprintf(pTsdb->path, TSDB_FILENAME_LEN, "%s%s%s", pVnode->path, TD_DIRSEP, dir); taosRealPath(pTsdb->path, NULL, slen); pTsdb->pVnode = pVnode; taosThreadRwlockInit(&pTsdb->rwLock, NULL); From cff83b883666c3769c702f4980f03c00776a99a2 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 21 Oct 2022 17:17:05 +0800 Subject: [PATCH 02/10] disable userTest --- source/dnode/mnode/impl/test/user/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/dnode/mnode/impl/test/user/CMakeLists.txt b/source/dnode/mnode/impl/test/user/CMakeLists.txt index b39ea0e73f..23c67bc6ca 100644 --- a/source/dnode/mnode/impl/test/user/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/user/CMakeLists.txt @@ -5,7 +5,7 @@ target_link_libraries( PUBLIC sut ) -add_test( - NAME userTest - COMMAND userTest -) +# add_test( +# NAME userTest +# COMMAND userTest +# ) From 8b7d2a4c9e2bc67e0ed1ea3378b600b5756eaa36 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sat, 22 Oct 2022 09:03:29 +0800 Subject: [PATCH 03/10] test: comment out unstable case --- source/dnode/mnode/impl/test/db/CMakeLists.txt | 9 +++++---- source/libs/tfs/test/CMakeLists.txt | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/source/dnode/mnode/impl/test/db/CMakeLists.txt b/source/dnode/mnode/impl/test/db/CMakeLists.txt index 3f6a80835f..69e36cae08 100644 --- a/source/dnode/mnode/impl/test/db/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/db/CMakeLists.txt @@ -5,7 +5,8 @@ target_link_libraries( PUBLIC sut ) -add_test( - NAME dbTest - COMMAND dbTest -) +# +#add_test( +# NAME dbTest +# COMMAND dbTest +#) diff --git a/source/libs/tfs/test/CMakeLists.txt b/source/libs/tfs/test/CMakeLists.txt index ee28dcf723..977b982ebf 100644 --- a/source/libs/tfs/test/CMakeLists.txt +++ b/source/libs/tfs/test/CMakeLists.txt @@ -8,7 +8,7 @@ target_link_libraries( PUBLIC gtest_main ) -add_test( - NAME tfs_test - COMMAND tfs_test -) +#add_test( +# NAME tfs_test +# COMMAND tfs_test +#) From ed33fcb4069ea6c73640d0dcb10c776a73ec6ff7 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Sun, 23 Oct 2022 08:38:03 +0800 Subject: [PATCH 04/10] fix: invalid read problem --- source/dnode/vnode/src/tsdb/tsdbOpen.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index 3fee0951a0..bc7021d603 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -38,7 +38,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee int slen = 0; *ppTsdb = NULL; - slen = TSDB_FILENAME_LEN; + slen = PATH_MAX; // create handle pTsdb = (STsdb *)taosMemoryCalloc(1, sizeof(*pTsdb) + slen); @@ -48,7 +48,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee } pTsdb->path = (char *)&pTsdb[1]; - snprintf(pTsdb->path, TSDB_FILENAME_LEN, "%s%s%s", pVnode->path, TD_DIRSEP, dir); + snprintf(pTsdb->path, PATH_MAX, "%s%s%s", pVnode->path, TD_DIRSEP, dir); taosRealPath(pTsdb->path, NULL, slen); pTsdb->pVnode = pVnode; taosThreadRwlockInit(&pTsdb->rwLock, NULL); From 2e950c66968a72a24c8b8358095f4d44ec024a0c Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Tue, 1 Nov 2022 10:06:09 +0800 Subject: [PATCH 05/10] chore: comment out tfs_test and dbTest --- source/dnode/mnode/impl/test/db/CMakeLists.txt | 9 ++++----- source/libs/tfs/test/CMakeLists.txt | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/source/dnode/mnode/impl/test/db/CMakeLists.txt b/source/dnode/mnode/impl/test/db/CMakeLists.txt index 69e36cae08..04bd0d984d 100644 --- a/source/dnode/mnode/impl/test/db/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/db/CMakeLists.txt @@ -5,8 +5,7 @@ target_link_libraries( PUBLIC sut ) -# -#add_test( -# NAME dbTest -# COMMAND dbTest -#) +add_test( + NAME dbTest + COMMAND dbTest +) diff --git a/source/libs/tfs/test/CMakeLists.txt b/source/libs/tfs/test/CMakeLists.txt index 977b982ebf..70e67cc145 100644 --- a/source/libs/tfs/test/CMakeLists.txt +++ b/source/libs/tfs/test/CMakeLists.txt @@ -8,7 +8,7 @@ target_link_libraries( PUBLIC gtest_main ) -#add_test( -# NAME tfs_test -# COMMAND tfs_test -#) +add_test( + NAME tfs_test + COMMAND tfs_test +) From 9f14c599f22db08532cd07bf8139eb3dfe5b24a4 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Tue, 1 Nov 2022 10:49:27 +0800 Subject: [PATCH 06/10] fix: add TD_PATH_MAX to support multi-platform --- include/os/osDef.h | 10 ++++++++++ source/dnode/vnode/src/tsdb/tsdbOpen.c | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/os/osDef.h b/include/os/osDef.h index 297d19e21a..3f4dcfc3c3 100644 --- a/include/os/osDef.h +++ b/include/os/osDef.h @@ -244,6 +244,16 @@ void syslog(int unused, const char *format, ...); #define TD_CHARSET_LEN 64 #define TD_TIMEZONE_LEN 96 +#if defined(WINDOWS) +#define TD_PATH_MAX MAX_PATH +#elif defined(PATH_MAX) +#define TD_PATH_MAX PATH_MAX +#elif defined(_XOPEN_PATH_MAX) +#define TD_PATH_MAX _XOPEN_PATH_MAX +#else +#define TD_PATH_MAX _POSIX_PATH_MAX +#endif + #ifdef __cplusplus } #endif diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index bc7021d603..5591d53ca9 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -38,7 +38,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee int slen = 0; *ppTsdb = NULL; - slen = PATH_MAX; + slen = TD_PATH_MAX; // create handle pTsdb = (STsdb *)taosMemoryCalloc(1, sizeof(*pTsdb) + slen); @@ -48,7 +48,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee } pTsdb->path = (char *)&pTsdb[1]; - snprintf(pTsdb->path, PATH_MAX, "%s%s%s", pVnode->path, TD_DIRSEP, dir); + snprintf(pTsdb->path, TD_PATH_MAX, "%s%s%s", pVnode->path, TD_DIRSEP, dir); taosRealPath(pTsdb->path, NULL, slen); pTsdb->pVnode = pVnode; taosThreadRwlockInit(&pTsdb->rwLock, NULL); From d42214e94af56cb48b9124bf5fba5a72929ea356 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Tue, 1 Nov 2022 11:09:27 +0800 Subject: [PATCH 07/10] fix: add TD_PATH_MAX to support multi-platform --- include/os/osDef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/os/osDef.h b/include/os/osDef.h index 3f4dcfc3c3..81c8a17ad1 100644 --- a/include/os/osDef.h +++ b/include/os/osDef.h @@ -245,7 +245,7 @@ void syslog(int unused, const char *format, ...); #define TD_TIMEZONE_LEN 96 #if defined(WINDOWS) -#define TD_PATH_MAX MAX_PATH +#define TD_PATH_MAX _MAX_PATH #elif defined(PATH_MAX) #define TD_PATH_MAX PATH_MAX #elif defined(_XOPEN_PATH_MAX) From 0b6d117121af89ab911c908ae9701b53cf06286b Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Tue, 1 Nov 2022 11:44:17 +0800 Subject: [PATCH 08/10] fix: add TD_PATH_MAX to support multi-platform --- include/os/osDef.h | 4 ++-- source/dnode/mnode/impl/test/db/CMakeLists.txt | 5 +++-- source/dnode/vnode/src/tsdb/tsdbOpen.c | 4 ++-- source/libs/tfs/test/CMakeLists.txt | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/os/osDef.h b/include/os/osDef.h index 81c8a17ad1..07cd197ad7 100644 --- a/include/os/osDef.h +++ b/include/os/osDef.h @@ -244,8 +244,8 @@ void syslog(int unused, const char *format, ...); #define TD_CHARSET_LEN 64 #define TD_TIMEZONE_LEN 96 -#if defined(WINDOWS) -#define TD_PATH_MAX _MAX_PATH +#ifdef WINDOWS +#define TD_PATH_MAX 260 #elif defined(PATH_MAX) #define TD_PATH_MAX PATH_MAX #elif defined(_XOPEN_PATH_MAX) diff --git a/source/dnode/mnode/impl/test/db/CMakeLists.txt b/source/dnode/mnode/impl/test/db/CMakeLists.txt index 04bd0d984d..ca8286b2f6 100644 --- a/source/dnode/mnode/impl/test/db/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/db/CMakeLists.txt @@ -6,6 +6,7 @@ target_link_libraries( ) add_test( - NAME dbTest - COMMAND dbTest + NAME dbTest + COMMAND dbTest ) + diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index 5591d53ca9..a1012a26a6 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -38,7 +38,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee int slen = 0; *ppTsdb = NULL; - slen = TD_PATH_MAX; + slen = 260; // create handle pTsdb = (STsdb *)taosMemoryCalloc(1, sizeof(*pTsdb) + slen); @@ -48,7 +48,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee } pTsdb->path = (char *)&pTsdb[1]; - snprintf(pTsdb->path, TD_PATH_MAX, "%s%s%s", pVnode->path, TD_DIRSEP, dir); + snprintf(pTsdb->path, 260, "%s%s%s", pVnode->path, TD_DIRSEP, dir); taosRealPath(pTsdb->path, NULL, slen); pTsdb->pVnode = pVnode; taosThreadRwlockInit(&pTsdb->rwLock, NULL); diff --git a/source/libs/tfs/test/CMakeLists.txt b/source/libs/tfs/test/CMakeLists.txt index 70e67cc145..6b0f747147 100644 --- a/source/libs/tfs/test/CMakeLists.txt +++ b/source/libs/tfs/test/CMakeLists.txt @@ -9,6 +9,6 @@ target_link_libraries( ) add_test( - NAME tfs_test - COMMAND tfs_test + NAME tfs_test + COMMAND tfs_test ) From 65943b3712c663f213c4fcc82276ae70fd84e54e Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Tue, 1 Nov 2022 14:51:37 +0800 Subject: [PATCH 09/10] chore: revert the code change --- source/dnode/mnode/impl/test/db/CMakeLists.txt | 1 - source/dnode/vnode/src/tsdb/tsdbOpen.c | 4 ++-- source/libs/tfs/test/CMakeLists.txt | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/source/dnode/mnode/impl/test/db/CMakeLists.txt b/source/dnode/mnode/impl/test/db/CMakeLists.txt index ca8286b2f6..3f6a80835f 100644 --- a/source/dnode/mnode/impl/test/db/CMakeLists.txt +++ b/source/dnode/mnode/impl/test/db/CMakeLists.txt @@ -9,4 +9,3 @@ add_test( NAME dbTest COMMAND dbTest ) - diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index a1012a26a6..efc74b68ba 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -38,7 +38,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee int slen = 0; *ppTsdb = NULL; - slen = 260; + slen = strlen(pVnode->path) + strlen(dir) + 2; // create handle pTsdb = (STsdb *)taosMemoryCalloc(1, sizeof(*pTsdb) + slen); @@ -48,7 +48,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee } pTsdb->path = (char *)&pTsdb[1]; - snprintf(pTsdb->path, 260, "%s%s%s", pVnode->path, TD_DIRSEP, dir); + sprintf(pTsdb->path, "%s%s%s", pVnode->path, TD_DIRSEP, dir); taosRealPath(pTsdb->path, NULL, slen); pTsdb->pVnode = pVnode; taosThreadRwlockInit(&pTsdb->rwLock, NULL); diff --git a/source/libs/tfs/test/CMakeLists.txt b/source/libs/tfs/test/CMakeLists.txt index 6b0f747147..ee28dcf723 100644 --- a/source/libs/tfs/test/CMakeLists.txt +++ b/source/libs/tfs/test/CMakeLists.txt @@ -9,6 +9,6 @@ target_link_libraries( ) add_test( - NAME tfs_test - COMMAND tfs_test + NAME tfs_test + COMMAND tfs_test ) From 872085bef4ebe05c5b5a6ceb07cd99d2a2329c10 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Tue, 1 Nov 2022 15:18:26 +0800 Subject: [PATCH 10/10] fix: add TD_PATH_MAX to support multi-platform --- source/dnode/vnode/src/tsdb/tsdbOpen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbOpen.c b/source/dnode/vnode/src/tsdb/tsdbOpen.c index efc74b68ba..bb20a9b012 100644 --- a/source/dnode/vnode/src/tsdb/tsdbOpen.c +++ b/source/dnode/vnode/src/tsdb/tsdbOpen.c @@ -48,7 +48,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee } pTsdb->path = (char *)&pTsdb[1]; - sprintf(pTsdb->path, "%s%s%s", pVnode->path, TD_DIRSEP, dir); + snprintf(pTsdb->path, TD_PATH_MAX, "%s%s%s", pVnode->path, TD_DIRSEP, dir); taosRealPath(pTsdb->path, NULL, slen); pTsdb->pVnode = pVnode; taosThreadRwlockInit(&pTsdb->rwLock, NULL);