Repository navigation
fix(tsdb): fix invalid cur_sector after reboot when all sectors are full - #447
Open
paxtonbacon wants to merge 2 commits into
Open
paxtonbacon wants to merge 2 commits into
paxtonbacon wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What this changes
我们设置
rollover为false进行使用,在使用过程中所有扇区被写满。当我们再次尝试append时,最后一个sector.status从USING变为FULL,此时所有扇区状态全部为FULL。此时进行重启,执行
fdb_tsdb_deinit,设置值后执行fdb_tsdb_init。由于
fdb_tsdb_init中db->rollover始终设置为true,其值本函数中不进行修改,所以永远无法访问下面的else分支:事实上,这个
if-else实际上是区分没有空扇区时的两种状态:USING,其他扇区全为FULLFULL(只有当rollover为false的时候,写满后添加,USING不会回环后移,导致所有扇区全为FULL)。第二种情况时
db->cur_sec不会被下面check_sec_hdr_cb回调赋值,保留db->cur_sec.addr = FDB_DATA_UNUSED;初始化时的无意义值(因为该回调中没有处理FULL的分支)所以修改条件区分上述两种状态,使其可达即可,对
cur_sec.addr准确赋值,修改如下:同时
fdb_tsdb_init后续对于last_time的恢复也存在未考虑rollover为false时cur_sec.status为FULL的情况,所以在if-else if中补充一个else if,修改(添加)如下:在
tests/fdb_tsdb_tc.c中已添加测试用例并已注册。Related issue
Closes #291
Closes #207
Closes #148
Test closure
tests/fdb_tsdb_tc.cUTEST_UNIT_RUN(...)list oftestcase()Write granularity covered
FDB_WRITE_GRAN= 1 / 8 / 32 / 64 / 128 / 256CI-equivalent local run: same source-copy step,
scons --global-macrosbuild and
qemu_runner.pyflow as.github/workflows/main.yml, run twice(PR source and unfixed parent source) at all six granularities. Not the
GitHub Actions runner: local ARM GCC 14.2.1 instead of the CI's GCC 10, and
the BSP snapshot carries local compatibility flags for GCC 14.
configuration. Risk limited to those two paths.
Data layout and compatibility
inc/flashdb.hchanged, compatibility impact:docs/plusdocs/zh-cn/are updatedPower-loss semantics
fdb_tsdb_deinit->fdb_tsdb_initreboot simulation