influxdb
influxdb copied to clipboard
In 2.x, seems series ids may be possible to be incomplete in series id set cache?
Steps to reproduce: I am reading 2.x source codes recently, and found series ids seems can be incomplete in some cases? I am not so sure about it...
The tagValueCache
's normal filling path seems like:
- Search
series ids
bytag key
+tag value
from each partition(include currentinactive log file
,active log file
,index file
) inIndex::TagValueSeriesIDIterator
. - Build the multi level index
measurement -> tag key -> tag value -> series ids
inIndex::TagValueSeriesIDIterator
. - Append the new log(include new series and its index entries) into
active log file
inIndex::CreateSeriesIfNotExists
orindex::CreateSeriesListIfNotExists
. - Insert the new
series id
if themeasurement -> tag key -> tag value -> series ids
path above exist in cache inIndex::CreateSeriesIfNotExists
orindex::CreateSeriesListIfNotExists
.
However, due to multithreading, the order of steps can be:
- Search
series ids
bytag key
+tag value
from each partition(include currentinactive log file
,active log file
,index file
) inIndex::TagValueSeriesIDIterator
. - Append the new log(include new series and its index entries) into
active log file
inIndex::CreateSeriesIfNotExists
orindex::CreateSeriesListIfNotExists
. - Try to Insert the new
series id
, but found themeasurement -> tag key -> tag value -> series ids
path non-exist in cache inIndex::CreateSeriesIfNotExists
orindex::CreateSeriesListIfNotExists
. - Build the multi level index
measurement -> tag key -> tag value -> series ids
inIndex::TagValueSeriesIDIterator
.
And in the later query, because the measurement -> tag key -> tag value -> series ids
exists, it won't try to search from files again, so the series ids
have no changes to become complete...
Expected behaviour: Complete series ids in cache.
Actual behaviour: Maybe incomplete series ids in cache.
Environment info:
Config:
Logs: