Skip to content

Conversation

@quzn
Copy link

@quzn quzn commented May 6, 2025

Description

Fixes a bug where the dlt-daemon fails to rotate log files in offline storage mode due to fd unavailable.

Issue Manifestation

  • During initial storage, when no log files exist in the designated directory, rotation occurs correctly as configured in dlt_logstorage.conf
  • Upon device reboot, when historical log files are present in the storage directory, there exists a probability of rotation failure, resulting in indefinite growth of a single file. The failure probability exhibits an inverse correlation with the FileSize parameter configured in the filter.

Trigger Conditions

  • When writing the first log message after device reboot, if the combined size of the most recent historical log file and the current message exceeds the configured file size threshold

Example scenario:

  • Config->FileSize: 1000
  • LatestFileSize: 900
  • LogMessage: 110

Root Cause

The file handle acquisition function fails to execute, leaving the file handle with its default invalid value.

	- Add explicit initialization for fd
	- Add availability check for fd
@quzn quzn changed the title fix file-rotation-failure-in-offline-storage Fix file rotation failure in offline storage May 6, 2025
@minminlittleshrimp minminlittleshrimp self-assigned this Aug 3, 2025
@minminlittleshrimp minminlittleshrimp self-requested a review August 3, 2025 08:38
@minminlittleshrimp minminlittleshrimp self-requested a review August 3, 2025 08:39
Copy link
Collaborator

@minminlittleshrimp minminlittleshrimp left a comment

Choose a reason for hiding this comment

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

need utest

@quzn
Copy link
Author

quzn commented Aug 27, 2025

OK, will add utest later. Thanks!

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.

2 participants