Fix for race condition in rosbag2 recording tests with wait_for_db()
#1141
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.
wait_for_db()
#1140wait_for_db()
test infrastructure to avoid race condition with rosbag2 recorder.RCA
After some analysis @MichaelOrlov came to the conclusion that failure happening due to the race condition for the resource. i.e. database file.
In recording integration tests we usually spawn child process with
ros2 bag record
command and in parent process calling wait_for_db() function.The problem is that
wait_for_db()
inside trying to open the same database file as recorder supposed to create for recording.rosbag2/rosbag2_tests/test/rosbag2_tests/record_fixture.hpp
Lines 120 to 136 in 3df2fe3
Some times
wait_for_db()
creating DB reader and locking database at the moment when recorder already created database but hasn't fully initialized it.Somewhere in between one of the
database_->prepare_statement(create_stmt)->execute_and_reset();
rosbag2/rosbag2_storage_sqlite3/src/rosbag2_storage_sqlite3/sqlite_storage.cpp
Lines 377 to 385 in 3df2fe3
Recorder fails in this case since database get occupied from another
parent
process.Signed-off-by: Michael Orlov michael.orlov@apex.ai