Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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, which would lead to crash.
This patch fixes this bug by using a stack allocated string to
parse type.
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