Fix DFile name parsing bug
When parsing DFile name, we expect the file name to follow the format of v<vid>f<fid>.<type>-ver<version>. When parsing type in tsdbParseDFilename(), it uses a glibc modifier "m" to allocate string. However, type string ("p" variable in the original code) could be NULL for various reasons, and the following code doesn't check NULL, while would lead to crash. This patch fixes this bug by using a stack allocated string to parse type. * Testing I have a local vnode repository like following: . ├── vnode145 │ ├── config.json │ ├── tsdb │ │ ├── data │ │ │ ├── v145f1736.data │ │ │ ├── v145f1736.head-ver14 │ │ │ ├── v145f1736.last │ │ │ ├── v145f1736.smad │ │ │ └── v145f1736.smal │ │ └── meta │ ├── version.json │ └── wal "vnode145" is lacking "current" for the FS status, but this is fine since it can be recovered from the "data" folder. However, the above repository will lead to taosd crashing while restoring "current", because type for DFile can sometimes be not parsed by the sscanf format before this patch. After this patch, the above repository can work OK and "current" can be restored. Also run taosdemo for sanity check. Spent 81.9563 seconds to insert rows: 100000000, affected rows: 100000000 with 8 thread(s) into test.meters. 1220162.42 records/second insert delay, avg: 65.13ms, max: 252.73ms, min: 24.77ms
Showing
想要评论请 注册 或 登录