8000 Fix flaky stats spec size comparisons across collStats calls by smtlaissezfaire · Pull Request #768 · mongomapper/mongomapper · GitHub
[go: up one dir, main page]

Skip to content

Fix flaky stats spec size comparisons across collStats calls - #768

Merged
smtlaissezfaire merged 2 commits into
masterfrom
cursor/fix-flaky-stats-spec-ef73
Nov 3, 2026
Merged

smtlaissezfaire merged 2 commits into
masterfrom
cursor/fix-flaky-stats-spec-ef73

Conversation

@smtlaissezfaire
@smtlaissezfaire smtlaissezfaire commented Nov 3, 2026 •
Copy link
Copy Markdown
Member

Problem

spec/functional/stats_spec.rb compared WiredTiger size stats from two separate collStats commands. Those sizes (index size, storage size, data size) can change between calls as data is checkpointed, so exact equality is racy.

This showed up in CI on Ruby 3.4 / rails6_1 / mongo:4.4:

Stats with documents present with scale keyword argument
  should have the correct total index size (with scale)
Failure/Error: Docs.stats(scale: 1_024).total_index_size.should == (get_stats['totalIndexSize'] / 1_024)
  expected: 20
       got: 4

Change

Size assertions now use a single Docs.stats response:

  • size, storage_size, total_index_size, and last_extent_size must be numeric and positive
  • avg_obj_size must match size / count from that same response
  • per-index sizes must sum to total_index_size and match nindexes
  • scale: 1024 is proven via scale_factor on the scaled response, plus the same internal size consistency (not scaled == unscaled / 1024 across two commands)

Deterministic fields (count, ns, nindexes, numExtents, paddingFactor, userFlags) stay exact.

CI

The first Actions run was 65/66 green. The remaining job (Ruby 4 / rails8_0 / mongo:8.0) never started mongod: GitHub ubuntu-latest is now on Linux 6.19+, and MongoDB 8.0 exits at startup (SERVER-121912). That same job is already red on master.

This PR sets GLIBC_TUNABLES=glibc.pthread.rseq=1 on the mongo service so 8.0 can start on those kernels.

Test plan

  • bundle exec rspec spec/functional/stats_spec.rb against local MongoDB (20 consecutive passes)
  • Full GitHub Actions matrix on this PR (66/66 green)
Open in Web Open in Cursor 

cursoragent and others added 2 commits November 3, 2026 18:23
WiredTiger index and storage sizes can change between collStats
commands as data is checkpointed, so exact equality against a
second command is racy. Assert size fields from a single response
and keep deterministic fields exact.

Co-authored-by: Scott Taylor <smtlaissezfaire@users.noreply.github.com>
GitHub ubuntu-latest now runs kernel 6.19+, and mongo:8.0 exits
at startup (SERVER-121912). Set GLIBC_TUNABLES so tcmalloc rseq
is enabled and the container can start.

Co-authored-by: Scott Taylor <smtlaissezfaire@users.noreply.github.com>
@smtlaissezfaire
smtlaissezfaire merged commit f501065 into master Nov 3, 2026
66 checks passed
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

0