fix: sync to x replace fuser with mtime check#151
Merged
otenim merged 4 commits intodevelop/r36.4.0from Apr 23, 2026
Merged
Conversation
fuser scans /proc/*/fd for all processes and resolves each symlink via stat(), which causes excessive NFS round-trips when destinations include a NAS mount. This results in severe per-file latency inside the transfer loop. Replace the fuser-based open-file check with a modification time check using stat -c %Y. Files modified within the last 10 seconds are considered active and skipped. This avoids any NFS network I/O for the active-file guard while remaining reliable for the mcap recording use case.
Replace the hardcoded 10s mtime guard with a configurable parameter sync_to_x_active_file_threshold_sec (default: 30s). This allows operators to tune how long after recording ends a file is held back from transfer.
Verified on both NAS and external SSD hardware. How to verify: Check transfer speed with NAS and external SSD. Improvements: Resolved the transfer bandwidth limitation issue by adjusting the rsync bandwidth limit to 200m. Limitations: None.
otenim
requested changes
Apr 22, 2026
Collaborator
There was a problem hiding this comment.
Request: fix stat failure fallback in the active-file check
file_mtime=$(stat -c %Y "$mcap_file" 2>/dev/null || echo 0)
now=$(date +%s)
if [ $((now - file_mtime)) -lt {{ sync_to_x_active_file_threshold_sec }} ]; then
continue
fiWhen stat fails, file_mtime falls back to 0, so now - 0 is a huge number and the condition is false — the file is not skipped and the script proceeds to rsync, then rm -f on success.
Could you change the fallback to skip on stat failure instead? e.g.
if ! file_mtime=$(stat -c %Y "$mcap_file" 2>/dev/null); then
echo "Skipping (stat failed): $mcap_file"
continue
fi
now=$(date +%s)
if [ $((now - file_mtime)) -lt {{ sync_to_x_active_file_threshold_sec }} ]; then
echo "Skipping recently modified file (active within {{ sync_to_x_active_file_threshold_sec }}s): $mcap_file"
continue
fiThe file will be retried on the next timer tick, which is the safer default.
When stat fails, the previous fallback (|| echo 0) caused now-0 to be a large number, bypassing the active-file guard and allowing rsync followed by rm -f on a file whose state was unknown. The file is now skipped with a log message and retried on the next timer tick.
Contributor
Author
|
@otenim |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR replaces the
fusercommand with anmtime(modification time) check in thesync-to-xdata synchronization process.Previously, using
fusercaused significant slowdowns when operating over network file systems (NFS). Using anmtime-based check provides a much more efficient way to determine if a file is still actively being written to.Additionally, this PR includes the following updates:
mtimeis now configurable via an Ansible parameter.rsyncbandwidth limit (increased from 100m to 200m) to resolve transfer bottlenecks.How to verify
sync-to-xconfiguration.Improvements
fuserdependency.mtimethreshold configurable.Limitations