Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux的demo程序第一次运行都会卡住 #285

Open
syan-cham opened this issue Mar 28, 2024 · 2 comments
Open

linux的demo程序第一次运行都会卡住 #285

syan-cham opened this issue Mar 28, 2024 · 2 comments

Comments

@syan-cham
Copy link

FlashDB-2.1.0/demos/linux$ ./out/FlashDBLinuxDemo
[FlashDB][kv][env][fdb_kvdb1] (../../src/fdb_kvdb.c:1777) The oldest addr is @0x00000000
[FlashDB][kv][env][fdb_kvdb1] (../../src/fdb_kvdb.c:1793) KVDB size is 16384 bytes.
[FlashDB][kv][env][fdb_kvdb1] Sector header info is incorrect. Auto format this sector (0x00000000).
[FlashDB][kv][env][fdb_kvdb1] Sector header info is incorrect. Auto format this sector (0x00001000).
[FlashDB][kv][env][fdb_kvdb1] Sector header info is incorrect. Auto format this sector (0x00002000).
[FlashDB][kv][env][fdb_kvdb1] Sector header info is incorrect. Auto format this sector (0x00003000).
[FlashDB][kv][env][fdb_kvdb1] All sector header is incorrect. Set it to default.

这个地方就一直卡住,要ctrl+c停止再运行才能往下工作。
FlashDB-2.1.0/demos/linux$ ./out/FlashDBLinuxDemo
[FlashDB][kv][env][fdb_kvdb1] (../../src/fdb_kvdb.c:1777) The oldest addr is @0x00000000
[FlashDB][kv][env][fdb_kvdb1] (../../src/fdb_kvdb.c:1793) KVDB size is 16384 bytes.
[FlashDB] FlashDB V2.1.0 is initialize success.
[FlashDB] You can get the latest version on https://github.com/armink/FlashDB .
[FlashDB][sample][kvdb][basic] ==================== kvdb_basic_sample ====================
[FlashDB][sample][kvdb][basic] get the 'boot_count' failed
[FlashDB][sample][kvdb][basic] set the 'boot_count' value to 1
[FlashDB][sample][kvdb][basic] ===========================================================
[FlashDB][sample][kvdb][string] ==================== kvdb_type_string_sample ====================
[FlashDB][sample][kvdb][string] create the 'temp' string KV, value is: 36C
[FlashDB][sample][kvdb][string] get the 'temp' value is: 36C
[FlashDB][sample][kvdb][string] set 'temp' value to 38C
[FlashDB][sample][kvdb][string] delete the 'temp' finish
[FlashDB][sample][kvdb][string] ===========================================================
[FlashDB][sample][kvdb][blob] ==================== kvdb_type_blob_sample ====================
[FlashDB][sample][kvdb][blob] create the 'temp' blob KV, value is: 36
[FlashDB][sample][kvdb][blob] get the 'temp' value is: 36
[FlashDB][sample][kvdb][blob] set 'temp' value to 38
[FlashDB][sample][kvdb][blob] delete the 'temp' finish
[FlashDB][sample][kvdb][blob] ===========================================================
[FlashDB][tsl][log][fdb_tsdb1] Sector (0x00000000) header info is incorrect.
[FlashDB][tsl][log][fdb_tsdb1] All sector format finished.
[FlashDB][tsl][log][fdb_tsdb1] (../../src/fdb_tsdb.c:978) TSDB (log) oldest sectors is 0x00000000, current using sector is 0x00000000.
[FlashDB][sample][tsdb] ==================== tsdb_sample ====================
[FlashDB][sample][tsdb] append the new status.temp (36) and status.humi (85)
[FlashDB][tsl][log][fdb_tsdb1] Warning: current timestamp (1711640796) is less than or equal to the last save timestamp (1711640796). This tsl will be dropped.
[FlashDB][sample][tsdb] append the new status.temp (38) and status.humi (90)
[FlashDB][sample][tsdb] [query_cb] queried a TSL: time: 1711640796, temp: 36, humi: 85
[FlashDB][sample][tsdb] query count is: 0
[FlashDB][sample][tsdb] set the TSL (time 1711640796) status from 2 to 3
[FlashDB][sample][tsdb] ===========================================================

@mrchipset
Copy link
Contributor

今天看到这个项目想试一下也遇到这个问题。看了下发现是因为线程锁造成的阻塞。

fdb_kvdb_init这个函数里获得了线程锁,还没解锁前调用_fdb_kv_load中函数fdb_kv_set_default也想要获得线程锁就卡住了。
image

修改下代码fdb_kvdb.c文件中的fdb_kvdb_init函数可以修复

FDB_DEBUG("KVDB size is %" PRIu32 " bytes.\n", db_max_size(db));
db_unlock(db);

result = _fdb_kv_load(db);

db_lock(db);

@armink
Copy link
Owner

armink commented May 10, 2024

@mrchipset 多谢啦,估计是锁没有支持递归能力

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants