Skip to content

[RED-169833] fix: fix reporting used memory as unsigned long long#6971

Merged
JoanFM merged 5 commits intomasterfrom
joan-fix-change-info-report
Nov 10, 2025
Merged

[RED-169833] fix: fix reporting used memory as unsigned long long#6971
JoanFM merged 5 commits intomasterfrom
joan-fix-change-info-report

Conversation

@JoanFM
Copy link
Collaborator

@JoanFM JoanFM commented Oct 3, 2025

Describe the changes in the pull request

We are reporting max memory from the module as double which could lead to errors, while we have a size_t value, we should report as ULongLong


Note

Switch INFO metrics from double to unsigned long long for memory, GC, and error counters to avoid precision issues.

  • Info output type corrections:
    • Memory section: used_memory_indexes, smallest_memory_index, largest_memory_index, used_memory_vector_index now use RedisModule_InfoAddFieldULongLong; human-readable fields unchanged.
    • Garbage collector: gc_total_cycles, gc_total_ms_run switched to unsigned long long (kept gc_bytes_collected as double).
    • Warnings and errors: errors_indexing_failures, errors_for_index_with_max_failures, OOM_indexing_failures_indexes_count switched to unsigned long long.

Written by Cursor Bugbot for commit 701ceda. This will update automatically on new commits. Configure here.

@github-actions github-actions bot added the size:S label Oct 3, 2025
cursor[bot]

This comment was marked as outdated.

@JoanFM JoanFM force-pushed the joan-fix-change-info-report branch from 817e3c4 to 3860f8b Compare October 3, 2025 13:27
@JoanFM JoanFM requested a review from oshadmi October 3, 2025 13:29
@JoanFM JoanFM changed the title fix: fix reporting used memory as unsigned long long [RED-169833] fix: fix reporting used memory as unsigned long long Oct 3, 2025
@codecov
Copy link

codecov bot commented Oct 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.22%. Comparing base (6f30cc3) to head (701ceda).
⚠️ Report is 15 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6971      +/-   ##
==========================================
- Coverage   85.23%   85.22%   -0.01%     
==========================================
  Files         341      341              
  Lines       52603    52603              
  Branches    12526    12526              
==========================================
- Hits        44835    44832       -3     
- Misses       7576     7579       +3     
  Partials      192      192              
Flag Coverage Δ
flow 84.13% <100.00%> (-0.12%) ⬇️
unit 52.30% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

cursor[bot]

This comment was marked as outdated.

@JoanFM JoanFM force-pushed the joan-fix-change-info-report branch from c6ccd18 to 701ceda Compare November 4, 2025 15:17
// Total
RedisModule_InfoAddFieldDouble(ctx, "used_memory_indexes", total_info->total_mem);
// Total
RedisModule_InfoAddFieldULongLong(ctx, "used_memory_indexes", total_info->total_mem);
Copy link
Collaborator

Choose a reason for hiding this comment

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

These changes are backward compatible, right? (users were getting double values and now they would get unsigned long long, so should not break anything)

Copy link
Collaborator

@oshadmi oshadmi Nov 6, 2025

Choose a reason for hiding this comment

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

The unit listed in docs is bytes. Looks OK.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In Redis these are returned as formatted strings, so they should all be properly parsed by a client application

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

/* See RedisModule_InfoAddFieldString(). */
int RM_InfoAddFieldULongLong(RedisModuleInfoCtx *ctx, const char *field, unsigned long long value) {
    if (!ctx->in_section)
        return REDISMODULE_ERR;
    if (ctx->in_dict_field) {
        ctx->info = sdscatfmt(ctx->info,
            "%s=%U,",
            field,
            value);
        return REDISMODULE_OK;
    }
    ctx->info = sdscatfmt(ctx->info,
        "%s_%s:%U\r\n",
        ctx->module->name,
        field,
        value);
    return REDISMODULE_OK;
}
int RM_InfoAddFieldDouble(RedisModuleInfoCtx *ctx, const char *field, double value) {
    if (!ctx->in_section)
        return REDISMODULE_ERR;
    if (ctx->in_dict_field) {
        ctx->info = sdscatprintf(ctx->info,
            "%s=%.17g,",
            field,
            value);
        return REDISMODULE_OK;
    }
    ctx->info = sdscatprintf(ctx->info,
        "%s_%s:%.17g\r\n",
        ctx->module->name,
        field,
        value);
    return REDISMODULE_OK;
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

And if parsed as double, would still succeed with parsing a string of an unsigned long long, except maybe for the supported range, which could be larger now?

@JoanFM JoanFM requested a review from oshadmi November 6, 2025 10:36
// Vector memory
RedisModule_InfoAddFieldDouble(ctx, "used_memory_vector_index", total_info->fields_stats.total_vector_idx_mem);
// Vector memory
RedisModule_InfoAddFieldULongLong(ctx, "used_memory_vector_index", total_info->fields_stats.total_vector_idx_mem);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not documented as bytes

search_used_memory_vector_index: The total memory usage of all vector indexes in the shard.

@JoanFM is it in bytes?

@dwdougherty Shouldn't we make it clearer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will check if is bytes, but IMO this does not affect at all the code. The Field API should be used according to the type declared.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looking at the code, it indeed seems to come from bytes.

RedisModule_InfoAddFieldDouble(ctx, "errors_for_index_with_max_failures", total_info->max_indexing_failures);
RedisModule_InfoAddFieldDouble(ctx, "OOM_indexing_failures_indexes_count", total_info->background_indexing_failures_OOM);
RedisModule_InfoAddFieldULongLong(ctx, "errors_for_index_with_max_failures", total_info->max_indexing_failures);
RedisModule_InfoAddFieldULongLong(ctx, "OOM_indexing_failures_indexes_count", total_info->background_indexing_failures_OOM);
Copy link
Collaborator

Choose a reason for hiding this comment

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

@dwdougherty This is not documented (#5778)

@lerman25 Can add description?

@JoanFM JoanFM added this pull request to the merge queue Nov 6, 2025
@JoanFM JoanFM removed this pull request from the merge queue due to a manual request Nov 6, 2025
@JoanFM JoanFM added this pull request to the merge queue Nov 6, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 7, 2025
@JoanFM JoanFM added this pull request to the merge queue Nov 7, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 7, 2025
@JoanFM JoanFM added this pull request to the merge queue Nov 7, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 7, 2025
@JoanFM JoanFM added this pull request to the merge queue Nov 7, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 7, 2025
@JoanFM JoanFM added this pull request to the merge queue Nov 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 9, 2025
@JoanFM JoanFM added this pull request to the merge queue Nov 10, 2025
Merged via the queue into master with commit ca5b662 Nov 10, 2025
19 checks passed
@JoanFM JoanFM deleted the joan-fix-change-info-report branch November 10, 2025 10:00
@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 2.8, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 2.8
git worktree add -d .worktree/backport-6971-to-2.8 origin/2.8
cd .worktree/backport-6971-to-2.8
git switch --create backport-6971-to-2.8
git cherry-pick -x ca5b662612a4eaeab391f89bcc58f010b3a90dd8

@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 2.6, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 2.6
git worktree add -d .worktree/backport-6971-to-2.6 origin/2.6
cd .worktree/backport-6971-to-2.6
git switch --create backport-6971-to-2.6
git cherry-pick -x ca5b662612a4eaeab391f89bcc58f010b3a90dd8

@redisearch-backport-pull-request
Copy link
Contributor

Backport failed for 2.10, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin 2.10
git worktree add -d .worktree/backport-6971-to-2.10 origin/2.10
cd .worktree/backport-6971-to-2.10
git switch --create backport-6971-to-2.10
git cherry-pick -x ca5b662612a4eaeab391f89bcc58f010b3a90dd8

redisearch-backport-pull-request bot pushed a commit that referenced this pull request Nov 10, 2025
)

* fix: fix reporting used memory as unsigned long long

* change the bytes collected type to double again after change by other PR

(cherry picked from commit ca5b662)
@redisearch-backport-pull-request
Copy link
Contributor

Successfully created backport PR for 8.2:

redisearch-backport-pull-request bot pushed a commit that referenced this pull request Nov 10, 2025
)

* fix: fix reporting used memory as unsigned long long

* change the bytes collected type to double again after change by other PR

(cherry picked from commit ca5b662)
@redisearch-backport-pull-request
Copy link
Contributor

Successfully created backport PR for 8.4:

JoanFM added a commit that referenced this pull request Nov 10, 2025
)

* fix: fix reporting used memory as unsigned long long

* change the bytes collected type to double again after change by other PR

(cherry picked from commit ca5b662)
JoanFM added a commit that referenced this pull request Nov 10, 2025
)

* fix: fix reporting used memory as unsigned long long

* change the bytes collected type to double again after change by other PR

(cherry picked from commit ca5b662)
JoanFM added a commit that referenced this pull request Nov 10, 2025
)

* fix: fix reporting used memory as unsigned long long

* change the bytes collected type to double again after change by other PR

(cherry picked from commit ca5b662)
github-merge-queue bot pushed a commit that referenced this pull request Nov 10, 2025
…ng (#7276)

* [RED-169833] fix: fix reporting used memory as unsigned long long (#6971)

* fix: fix reporting used memory as unsigned long long

* change the bytes collected type to double again after change by other PR

(cherry picked from commit ca5b662)

* fix: correct stats for gc collected bytes

---------

Co-authored-by: Joan Fontanals <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Nov 11, 2025
…ng (#6… (#7278)

[RED-169833] fix: fix reporting used memory as unsigned long long (#6971)

* fix: fix reporting used memory as unsigned long long

* change the bytes collected type to double again after change by other PR

(cherry picked from commit ca5b662)
github-merge-queue bot pushed a commit that referenced this pull request Nov 11, 2025
…ong (#6… (#7277)

[RED-169833] fix: fix reporting used memory as unsigned long long (#6971)

* fix: fix reporting used memory as unsigned long long

* change the bytes collected type to double again after change by other PR

(cherry picked from commit ca5b662)
github-merge-queue bot pushed a commit that referenced this pull request Nov 11, 2025
…ng (#7275)

* [RED-169833] fix: fix reporting used memory as unsigned long long (#6971)

* fix: fix reporting used memory as unsigned long long

* change the bytes collected type to double again after change by other PR

(cherry picked from commit ca5b662)

* fix: correct stats for gc collected bytes

---------

Co-authored-by: Joan Fontanals <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants