Skip to content

ftsb_redisearch: histogram RecordValue is data-raced under -workers >1 (corrupts percentiles + counts) #116

Description

@fcostaoliveira

Found during the 7-way review of #115.

benchmark_runner.go's recording loop calls l.totalHistogram.RecordValue(...) and the per-label histograms (writeHistogram, readHistogram, …) from every worker goroutine without a lock. hdrhistogram's RecordValue is not concurrency-safe. Under the default -workers 8 this races: go build -race reports ~13 data races on the RecordValuesetCountAtIndex path, and increments are lost.

Note detailedMapHistograms and perSecondHistograms are mutex-protected, but totalHistogram and the per-label histograms are not — an internal inconsistency.

Impact:

Fix options:

  • Guard the shared histograms with a mutex on the record path (simple; adds contention to the hot loop), or
  • Record into per-worker histograms and merge at the end (no hot-path contention; preferred).

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions