You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typeRetentionPolicyInfostruct {
IndexGroups []IndexGroupInfo// each IndexGroupInfo contains Indexes that expire at the same time for all nodesMeasurementsmap[string]*MeasurementInfo// {"cpu_0001": *MeasurementInfo}// 新增KeyIDuint64// 此RP,保证每一个tag/field能分配一个递增的ID
}
元数据老化设计方案
问题
问题1:
由于一些业务,Tag 和 Field 会持续增加,导致元数据膨胀,而很多Tag和Field可能随着业务调整,不会再有新数据写入。导致这些元数据一直存在meta中,浪费空间,可能会影响性能。故需要设计一个安全删除过期元数据的方案。
问题2:
Tag 和 Field 不支持同名字段,需要兼容吗? Influxdb支持。
问题3:
某个表数据已经全部过期,是否需要删除整个measurement元数据。--- RP过期是否会删除?
本方案目标:
Tag Field支持同名
将Tag和Field拆成2个map
IndexGroup 引用 schema id
基于引用计数的清理。
每一个表的tag, field会被分配一个全局唯一的ID,按顺序递增1,2,3......,schema id就是上面说的ID。
当其中一个IndexGroup过期后,对应的所有tag/field的引用计数 ref - 1,当其中的tag/field引用计数ref减为0了,则可以清理了。
// TODO:写互斥
meta元数据存在如下更新
IndexGroupInfo
MeasurementInfo
RetentionPolicyInfo
写流程
写IndexGroup1(IG1), 写入新tag/field
SQL创建IndexGroup,记录Tag/Field的ID。
SQL创建Tag/Field,ref加1
已存在IndexGroup1(IG1),写入新tag/field
已存在IndexGroup1(IG1),写入旧 tag/field
写新IndexGroup2,写入新/旧 tag/field
已存在IndexGroup2(IG2),旧 tag/field
schema id
写入时,由meta统一递增分配
tag/field过期老化
随着IndexGroup过期,他所记录的所有tag/field相关的ref都减1,当有ref==0时,可删除。
删除和写互斥判断:TODO
schama查询
修改点
![image-20230406204905577](/Users/xiangyu/Library/Application Support/typora-user-images/image-20230406204905577.png)
Q&As
The text was updated successfully, but these errors were encountered: