Skip to content

Automated dictionary recovery/repairing#1669

Merged
matlabbe merged 6 commits intomasterfrom
auto_dictionary_repairing
Mar 11, 2026
Merged

Automated dictionary recovery/repairing#1669
matlabbe merged 6 commits intomasterfrom
auto_dictionary_repairing

Conversation

@matlabbe
Copy link
Copy Markdown
Member

@matlabbe matlabbe commented Mar 10, 2026

This would solve errors like:

[ ERROR] (2026-03-10 13:57:45.845) VWDictionary.cpp:885::addWordRef() Not found word 456 (dict size=0)

when rtabmap has not been properly closed. After mapping, rtabmap has to save the latest state of the visual world dictionary back to the database. However, if this process gets interrupted (e.g., rtabmap is running in a docker container and by default docker would sig-term the process after 10 sec when stopping), it may partially saved the dictionary. On subsequent runs, on initialization we can get a lot of errors like above saying that the word we want to reference doesn't exist in the dictionary.

In this PR, when the above error happens, it will now start a recovery automatically to re-generate the dictionary with the missing words. When rtabmap closes, it should save the latest state and be fine for next initializations. Well, if rtabmap gets always killed before it can save the dictionary safely, it will recover the next time too. There will be some warning messages shown everytime that can make the user aware to increase wait time before killing the process.

To quickly test:

# Remove all words
$ sqlite3 rtabmap.db "delete from Word where id>=0"
$ rtabmap rtabmap.db
[...]
[ WARN] (2026-03-10 15:48:11.417) VWDictionary.cpp:885::addWordRef() Not found word 1 (dict size=0)
[ WARN] (2026-03-10 15:48:11.417) Memory.cpp:479::loadDataFromDb() The dictionary is empty or missing some words from nodes in WM, we will try to repair it. This can be caused by rtabmap closing before it has time to save the dictionary. Re-creating the dictionary from 4048 nodes...
[ WARN] (2026-03-10 15:48:26.818) Memory.cpp:545::loadDataFromDb() Regenerated the dictionary with 1375293 missing words (0 -> 1375293) from 4048 nodes.

# Remove some of the words
$ sqlite3 rtabmap.db "delete from Word where id >=20000 and id <30000"
$ rtabmap  rtabmap.db 
[...]
[ WARN] (2026-03-10 15:49:47.407) VWDictionary.cpp:885::addWordRef() Not found word 20000 (dict size=1365293)
[ WARN] (2026-03-10 15:49:47.407) Memory.cpp:479::loadDataFromDb() The dictionary is empty or missing some words from nodes in WM, we will try to repair it. This can be caused by rtabmap closing before it has time to save the dictionary. Re-creating the dictionary from 4048 nodes...
[ WARN] (2026-03-10 15:50:20.146) Memory.cpp:545::loadDataFromDb() Regenerated the dictionary with 10000 missing words (1365293 -> 1375293) from 31 nodes.

# Remove the last words
$ sqlite3 rtabmap.db "delete from Word where id >1000000"
$ rtabmap  rtabmap.db 
[...]
[ WARN] (2026-03-10 15:51:45.456) VWDictionary.cpp:885::addWordRef() Not found word 1000001 (dict size=957196)
[ WARN] (2026-03-10 15:51:45.456) Memory.cpp:479::loadDataFromDb() The dictionary is empty or missing some words from nodes in WM, we will try to repair it. This can be caused by rtabmap closing before it has time to save the dictionary. Re-creating the dictionary from 4048 nodes...
[ WARN] (2026-03-10 15:51:57.484) Memory.cpp:545::loadDataFromDb() Regenerated the dictionary with 418097 missing words (957196 -> 1375293) from 1239 nodes

When recovering:
image

When there is no issue:
image

Could recover automatically these cases:
#456
#895

@matlabbe matlabbe marked this pull request as ready for review March 10, 2026 22:54
@matlabbe matlabbe merged commit 8051be4 into master Mar 11, 2026
6 of 7 checks passed
@matlabbe matlabbe deleted the auto_dictionary_repairing branch March 11, 2026 22:11
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

Successfully merging this pull request may close these issues.

1 participant