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

mcap-record: Fix race condition when adding messages #598

Conversation

achim-k
Copy link
Collaborator

@achim-k achim-k commented Nov 22, 2023

Public-Facing Changes

mcap-record: Fix race condition when adding messages

Description

Does not directly call writer.addMessage in the websocket message handler but instead pushes it to a queue. This makes sure that we do not call writer.addMessage concurrently which could happen due to a certain addMessage taking longer when a chunk is ready to be compressed & written. This PR also allows to set the message queue size and to opt out of chunk compression.

Fixes #592
Resolves FG-5775

@achim-k achim-k requested a review from jtbandes November 22, 2023 16:00
data: new Uint8Array(event.data.buffer, event.data.byteOffset, event.data.byteLength),
});

// If we can't acquire the lock, we will drop the message to avoid potential OOM issues.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we could have a setting for this? It could be useful in some situations to record everything even if it takes longer than realtime. We should make sure that after ^C the writer still gets closed cleanly — ideally finishing everything that was in the write queue already

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

@achim-k achim-k requested a review from jtbandes November 22, 2023 20:05
@achim-k achim-k requested a review from jtbandes November 22, 2023 22:30
@achim-k
Copy link
Collaborator Author

achim-k commented Nov 27, 2023

@jtbandes ping

@achim-k achim-k merged commit b4d7dff into main Nov 28, 2023
11 checks passed
@achim-k achim-k deleted the achim/fg-5775-the-data-recorded-by-the-mcap-record-command-is-too-large branch November 28, 2023 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

The data recorded by the mcap-record command is too large.
2 participants