Skip to content

RDKEMW-21242: Detect log rotation via inode tracking to prevent data loss when new log file grows past seek value#392

Merged
shibu-kv merged 3 commits into
developfrom
feature/RDKEMW-21242
Jul 14, 2026
Merged

RDKEMW-21242: Detect log rotation via inode tracking to prevent data loss when new log file grows past seek value#392
shibu-kv merged 3 commits into
developfrom
feature/RDKEMW-21242

Conversation

@yogeswaransky

Copy link
Copy Markdown
Contributor

No description provided.

…loss when new log file grows past seek value

Signed-off-by: yogeswaransky <yogeswaransky@github.com>
Copilot AI review requested due to automatic review settings July 8, 2026 17:27
@yogeswaransky yogeswaransky requested a review from a team as a code owner July 8, 2026 17:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates DCA log-seek persistence and log parsing to detect log rotation via inode tracking, preventing missed data when a rotated/new log file grows beyond the previously stored seek offset.

Changes:

  • Introduces LogSeekInfo { seekValue, inode } and updates seek-map handling to track both fields.
  • Persists/loads seek state in a new JSON format (while supporting legacy numeric-only seek values).
  • Updates DCA log scanning to use inode changes to decide when to read rotated logs and when to re-read the new current log from offset 0, plus adds unit tests for key rotation corner cases.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
source/test/dcautils/dcautilTest.cpp Updates tests to use LogSeekInfo and adds new inode-rotation corner-case tests.
source/dcautil/legacyutils.h Adds LogSeekInfo and includes sys/types.h for ino_t.
source/dcautil/dcautil.c Updates seek config save/load to persist both seek value and inode (with legacy read support).
source/dcautil/dca.c Adds inode-aware rotation detection and adjusts mmap/rotated-file search behavior accordingly.
Comments suppressed due to low confidence (1)

source/dcautil/dcautil.c:127

  • saveSeekConfigtoFile allocates a cJSON array/object tree and cJSON_PrintUnformatted string but never frees them on the success path, which will leak memory each time seek config is saved.
    char *jsonReport = cJSON_PrintUnformatted(valArray);
    if(T2ERROR_SUCCESS != saveConfigToFile(SEEKFOLDER, profileName, jsonReport))
    {
        T2Error("Failed to save config to file\n");
        cJSON_Delete(valArray);
        free(jsonReport);
        return T2ERROR_FAILURE;
    }
    T2Debug("%s --out\n", __FUNCTION__);
    return T2ERROR_SUCCESS;

Comment thread source/dcautil/dcautil.c
Comment thread source/test/dcautils/dcautilTest.cpp
Comment thread source/test/dcautils/dcautilTest.cpp
Comment thread source/test/dcautils/dcautilTest.cpp
Comment thread source/test/dcautils/dcautilTest.cpp
Comment thread source/test/dcautils/dcautilTest.cpp
…loss when new log file grows past seek value

Signed-off-by: yogeswaransky <yogeswaransky@github.com>
Copilot AI review requested due to automatic review settings July 9, 2026 12:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

source/dcautil/dcautil.c:127

  • On the success path, valArray and jsonReport are never freed (cJSON_Delete(valArray) / free(jsonReport)), causing a persistent memory leak each time seek config is saved (important on embedded devices). Free both before returning success.
    char *jsonReport = cJSON_PrintUnformatted(valArray);
    if(T2ERROR_SUCCESS != saveConfigToFile(SEEKFOLDER, profileName, jsonReport))
    {
        T2Error("Failed to save config to file\n");
        cJSON_Delete(valArray);
        free(jsonReport);
        return T2ERROR_FAILURE;
    }
    T2Debug("%s --out\n", __FUNCTION__);
    return T2ERROR_SUCCESS;

Comment thread source/dcautil/dcautil.c
Comment thread source/test/dcautils/dcautilTest.cpp
Comment thread source/test/dcautils/dcautilTest.cpp

@shibu-kv shibu-kv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor review comment on NULL checks

Comment thread source/dcautil/dcautil.c
…loss when new log file grows past seek value

Signed-off-by: yogeswaransky <yogeswaransky@github.com>
Copilot AI review requested due to automatic review settings July 14, 2026 18:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

source/dcautil/dcautil.c:136

  • saveSeekConfigtoFile() leaks valArray and jsonReport on the success path. The failure path frees them, but the success path returns without cJSON_Delete(valArray) / free(jsonReport), which will accumulate over repeated periodic runs.
    char *jsonReport = cJSON_PrintUnformatted(valArray);
    if(T2ERROR_SUCCESS != saveConfigToFile(SEEKFOLDER, profileName, jsonReport))
    {
        T2Error("Failed to save config to file\n");
        cJSON_Delete(valArray);

Comment thread source/dcautil/dcautil.c
Comment thread source/dcautil/dcautil.c
Comment thread source/dcautil/dca.c
Comment thread source/test/dcautils/dcautilTest.cpp
Comment thread source/test/dcautils/dcautilTest.cpp
@shibu-kv shibu-kv merged commit 4d71915 into develop Jul 14, 2026
16 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants