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

[21413] Record data in SQL #173

Open
wants to merge 36 commits into
base: main
Choose a base branch
from
Open

[21413] Record data in SQL #173

wants to merge 36 commits into from

Conversation

EugenioCollado
Copy link
Contributor

Code improvements:

  • Make a Serializer to serialize and deserialize TopicQoS, TypeObjects, TypeIdentifiers, and DynamicTypes.
    
  • Make a time_utils to convert between different time formats.
    
  • Make the DdsRecorder and the DdsReplayer agnostic of the output format.
    
  • Refactor McapLogErrorTest to improve its readability.
    

Configuration improvements:

  • Move cleanup-period and max-pending-samples from specs to recorder.
    
  • Configure safety-margin as a string (100MB, 128GiB, etc).
    

Bug fixes:

  • Avoid creating a payload when replaying a message in a topic without a reader.
    
  • Fix assert in ROS 2 topics.
    

Potential TODOs:

  • Separate data storage calls to dedicated thread
    

@codecov-commenter
Copy link

codecov-commenter commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 40.29944% with 957 lines in your changes missing coverage. Please review.

Project coverage is 29.33%. Comparing base (37d1303) to head (a3ce840).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...er_participants/src/cpp/recorder/sql/SqlWriter.cpp 31.21% 103 Missing and 113 partials ⚠️
...rticipants/src/cpp/recorder/output/BaseHandler.cpp 42.85% 74 Missing and 70 partials ⚠️
...icipants/src/cpp/replayer/SqlReaderParticipant.cpp 26.85% 24 Missing and 55 partials ⚠️
ddsrecorder/src/cpp/tool/DdsRecorder.cpp 44.68% 51 Missing and 27 partials ⚠️
..._yaml/src/cpp/recorder/YamlReaderConfiguration.cpp 26.53% 27 Missing and 45 partials ⚠️
...cipants/src/cpp/replayer/McapReaderParticipant.cpp 27.63% 9 Missing and 46 partials ⚠️
...r_participants/src/cpp/recorder/sql/SqlHandler.cpp 38.80% 8 Missing and 33 partials ⚠️
...participants/src/cpp/recorder/mcap/McapHandler.cpp 34.21% 6 Missing and 19 partials ⚠️
...rticipants/src/cpp/recorder/message/SqlMessage.cpp 41.86% 7 Missing and 18 partials ⚠️
...rticipants/src/cpp/common/serialize/Serializer.cpp 56.60% 2 Missing and 21 partials ⚠️
... and 18 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #173      +/-   ##
==========================================
+ Coverage   25.17%   29.33%   +4.15%     
==========================================
  Files          75       70       -5     
  Lines        5842     4445    -1397     
  Branches     2999     2262     -737     
==========================================
- Hits         1471     1304     -167     
+ Misses       3408     2144    -1264     
- Partials      963      997      +34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Eugenio Collado <eugeniocollado@eprosima.com>
Signed-off-by: Eugenio Collado <eugeniocollado@eprosima.com>
Signed-off-by: Eugenio Collado <eugeniocollado@eprosima.com>
Signed-off-by: Eugenio Collado <eugeniocollado@eprosima.com>
Signed-off-by: Eugenio Collado <eugeniocollado@eprosima.com>
Signed-off-by: Eugenio Collado <eugeniocollado@eprosima.com>
Signed-off-by: Eugenio Collado <eugeniocollado@eprosima.com>
Signed-off-by: Juan Lopez Fernandez <juanlopez@eprosima.com>
Signed-off-by: Eugenio Collado <eugeniocollado@eprosima.com>
@@ -16,8 +16,10 @@
# CMake build rules for DDS Recorder Submodule
###############################################################################
cmake_minimum_required(VERSION 3.5)
set(CMAKE_SYSTEM_VERSION 10.0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is the best approach. First, apparently this only makes sense in Windows, so it should be within an if. I also wonder if we should be imposing the sdk version here or we should investigate which versions are compatible with sqlite and warn the user she should be compiling with one of those (and specify it via cmake args). Otherwise, we could be forcing a version not available in a user's machine when another compatible one is present.


# Done this to set machine architecture and be able to call cmake_utils
enable_language(C)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this, and the new statement above should only be added to blackbox tests using sqlite.

Comment on lines +409 to +416
if(!config_loaded)
{
configuration = eprosima::ddsrecorder::yaml::RecorderConfiguration(commandline_args.file_path);
}
else
{
config_loaded = false;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is an improvement. I agree it would be better to avoid two immediate consecutive configuration loads, as it is the case when the initial state is running or paused. But a long time might have passed when coming from a stopped state, and the user might have changed the allowlist in the meantime.

@@ -47,8 +46,8 @@ ENUMERATION_BUILDER(
DdsRecorderStateCode,
STOPPED, //! Internal entities are not created and thus no messages are received.
SUSPENDED, //! Messages are received (internal entities created) but discarded.
RUNNING, //! Messages are stored in MCAP file.
PAUSED //! Messages are stored in buffer and stored in MCAP file if event triggered.
RUNNING, //! Messages are stored in MCAP/SQL file.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: SQL file? or database?

@@ -81,15 +82,16 @@ class DdsRecorder
*
* @param configuration: Structure encapsulating all recorder configuration options.
* @param init_state: Initial instance state (RUNNING/PAUSED/SUSPENDED/STOPPED).
* @param event_handler: Reference to event handler used for thread synchronization in main application.
* @param file_tracker: Reference to file tracker used to manage mcap files.
* @param mcap_file_tracker: Reference to file tracker used to manage mcap files.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please restore event_handler.

Comment on lines +44 to +50
publishTime = to_mcap_timestamp(publish_time);
logTime = to_mcap_timestamp(log_time);

if (log_publish_time)
{
log_time = publish_time;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
publishTime = to_mcap_timestamp(publish_time);
logTime = to_mcap_timestamp(log_time);
if (log_publish_time)
{
log_time = publish_time;
}
publishTime = to_mcap_timestamp(publish_time);
if (log_publish_time)
{
logTime = publishTime;
}
else
{
logTime = to_mcap_timestamp(log_time);
}


pending_samples.pop_front();
}
process_new_sample_nts_(std::make_shared<const McapMessage>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the fact that you create the message for dropping it later on if state is stopped.

}
else
{
// No schema available + no pending samples -> Add to buffer with blank schema
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally prefer to have the explicit comment to make clear that doing nothing is the intended purpose.

// NOTE: the outdated pending samples are not removed since they must be written as soon as they receive their type.

// Buffer
samples_buffer_.remove_if([&](const auto sample)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why pass by value now? Avoid copy.

Comment on lines +170 to 175
if (pending_samples_.find(type_name) != pending_samples_.end() ||
(state_ == BaseHandlerStateCode::PAUSED &&
pending_samples_paused_.find(type_name) != pending_samples_paused_.end()))
{
add_pending_samples_nts_(type_name);
dump_pending_samples_nts_(type_name);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please encapsulate this in a parent method?

Signed-off-by: Eugenio Collado <eugeniocollado@eprosima.com>
Signed-off-by: Eugenio Collado <eugeniocollado@eprosima.com>
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.

3 participants