Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-31020

Sharding database creation is slow because of shard disk-usage statistics gathering

    • Catalog and Routing
    • ALL
    • Hide
      use anthony110920175
      db.test.insert({test:true})
      
      Show
      use anthony110920175 db.test.insert({test: true })
    • 3

      Hi team,

      We are using a 10 shards (Primary / Secondary / Arbiter) cluster to host around 20k databases.
      We noticed that creating new databases take lot of time, around 10s :

      2017-09-11T09:48:52.763+0000 I SHARDING [conn641] distributed lock 'anthony110920175' acquired for 'createDatabase', ts : 59b65c04bb2f983e7e106b2c
      2017-09-11T09:49:02.438+0000 I SHARDING [conn641] Placing [anthony110920175] on: clust-1-sh1
      2017-09-11T09:49:02.448+0000 I SHARDING [conn641] distributed lock with ts: 59b65c04bb2f983e7e106b2c' unlocked.
      

      It looks like a

      db.runCommand({listDatabases:1})
      

      is launched on all shard, one by one, before creating the database on the config servers. This command take arount 1s per shard.
      Adding the "nameOnly:true" option make the query almost instantaneous. Maybe it should be added when a mongos check database existency ?

      Regards,
      Anthony

            Assignee:
            Unassigned Unassigned
            Reporter:
            anthony@sendinblue.com Anthony Brodard
            Votes:
            0 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated: