[SERVER-19533] collStats through mongoS on sharded collection incorrectly scales avgObjSize Created: 23/Jul/15  Updated: 19/Jul/16  Resolved: 07/Jul/16

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 2.6.10, 3.0.4
Fix Version/s: 3.3.10

Type: Bug Priority: Major - P3
Reporter: Joanna Cheng Assignee: Sam Dunietz
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File 1shard.js     File 2shards.js     File 3shards.js     HTML File repro    
Issue Links:
Related
related to SERVER-8617 db.stats(scale) and db.collection.sta... Closed
related to SERVER-7347 Do not scale avgObjSize in db.stats()... Closed
Backwards Compatibility: Minor Change
Operating System: ALL
Sprint: Sharding 10 (02/19/16), Sharding 16 (06/24/16), Sharding 17 (07/15/16)
Participants:

 Description   

When you try and run collStats on a mongoS, on a sharded collection, if you provide a "scale" argument, the avgObjSize is incorrectly scaled.

The actual scaled value also depends on the number of shards.

The same collStats command run on a mongoD does not scale the avgObjSize value

Full repro scripts attached, requires mtools. Test it like

bash repro

If I were better at scripting it would be prettier, but it does the following:

  1. Spins up a 1, 2, or 3 shard cluster with mtools
  2. Shards a collection and makes 1, 2, or 3 chunks, and waits for the balancer to put 1 chunk on each shard
  3. Inserts 6 documents
  4. Connects to the mongoS and directly to each shard, and gets the output of

    db.version()
    db.foo.stats().avgObjSize
    db.foo.stats(1024).avgObjSize
    

The average object size should be 2032, and this is reported every time for db.foo.stats().avgObjSize

For db.foo.stats(1024).avgObjSize

  • If you're connecting to a mongod directly, it reports 2032
  • If you're connecting to a mongoS...
    • ... and there's 1 shard, it reports 1.83333
    • ... and there's 2 shards, it reports 1.6666666666666667
    • ... and there's 3 shards, it reports 1.5

Tested in 2.6.10 and 3.0.4

jstests/sharding/stats.js will need be be updated as it's not catching this



 Comments   
Comment by Githook User [ 07/Jul/16 ]

Author:

{u'name': u'Sam Dunietz', u'email': u'sam.dunietz@10gen.com'}

Message: SERVER-19533 collStats through mongoS on sharded collection incorrectly scales avgObjSize
Branch: master
https://github.com/mongodb/mongo/commit/082acbd2ab2e1a5f0c494b5203daf0c1aea00462

Comment by Githook User [ 20/Jun/16 ]

Author:

{u'name': u'Sam Dunietz', u'email': u'sam.dunietz@10gen.com'}

Message: Revert "SERVER-19533: collStats through mongoS on sharded collection incorrectly scales avgObjSize"

This reverts commit 5290f5a62439f10aa6681f6253489cf87377a82e.
Branch: master
https://github.com/mongodb/mongo/commit/35005a8199ae21d571b0a11778ee534f56c2c859

Comment by Githook User [ 20/Jun/16 ]

Author:

{u'name': u'Sam Dunietz', u'email': u'sam.dunietz@10gen.com'}

Message: SERVER-19533: collStats through mongoS on sharded collection incorrectly scales avgObjSize
Branch: master
https://github.com/mongodb/mongo/commit/5290f5a62439f10aa6681f6253489cf87377a82e

Generated at Thu Feb 08 03:51:17 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.