Skip to content

Skipping earlier days logic in archGetLogPath is apparently incorrect #334

Description

@sbtrn-devil

Fragment 1:

// Skip earlier days
if (replicator->lastCheckedDay.empty() && replicator->lastCheckedDay == ent->d_name)
continue;

This condition looks incorrect and can never trigger, so the whole set of available log files will re-enqueue on each round. Was it supposed to be !replicator->lastCheckedDay.empty() && replicator->lastCheckedDay.compare(ent->d_name) >= 0 ?

Fragment 2:

if (!newLastCheckedDay.empty() || (!replicator->lastCheckedDay.empty() && replicator->lastCheckedDay.compare(newLastCheckedDay) < 0)) {
if (unlikely(replicator->ctx->isTraceSet(Ctx::TRACE::ARCHIVE_LIST)))
replicator->ctx->logTrace(Ctx::TRACE::ARCHIVE_LIST, "updating last checked day to: " + newLastCheckedDay);
replicator->lastCheckedDay = newLastCheckedDay;

Similar here, looks like it has to be !newLastCheckedDay.empty() && (replicator->lastCheckedDay.empty() || replicator->lastCheckedDay.compare(newLastCheckedDay) < 0) if it means to update to later day.

Fragment 3:

if (newLastCheckedDay.empty() || (newLastCheckedDay != ent->d_name))
newLastCheckedDay = ent->d_name;

Does this assume readdir iterates in ascending name order? This assumption may not always hold.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions