[SERVER-4999] all hostnames should be compared case insensitively Created: 17/Feb/12  Updated: 08/Jan/24  Resolved: 24/Jun/19

Status: Closed
Project: Core Server
Component/s: Networking
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Richard Kreuter (Inactive) Assignee: Backlog - Service Architecture
Resolution: Won't Fix Votes: 5
Labels: platforms-re-triaged
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Documented
is documented by DOCS-12719 Docs for SERVER-4999: all hostnames s... Closed
Duplicate
is duplicated by SERVER-18150 Hostname matching should be case-inse... Closed
Problem/Incident
causes SERVER-41181 Sharding test failures due to hostnam... Closed
causes SERVER-41614 Revert "all hostnames should be compa... Closed
Related
is related to SERVER-5138 Are node names case sensitive? Closed
Assigned Teams:
Service Arch
Operating System: ALL
Sprint: Service Arch 2019-04-22, Service Arch 2019-05-06, Service Arch 2019-05-20
Participants:
Linked BF Score: 35

 Description   

It seems like addshard treats hostnames case-sensitively, which is inconsistent with how hostnames work in DNS.

Here's my replica set, addshard failures below. (I know that using localhost adds some extra stupid to the problem, but I don't have a routable hostname to test with right now.)

> rs.conf()
{
        "_id" : "a",
        "version" : 3,
        "members" : [
                {
                        "_id" : 0,
                        "host" : "LOCALHOST:27017"
                },
                {
                        "_id" : 1,
                        "host" : "LOCALHOST:27018"
                },
                {
                        "_id" : 2,
                        "host" : "LOCALHOST:27019"
                }
        ]
}

Here are a bunch of attempts to add it as a shard:

mongos> db.adminCommand({addShard:"a/localhost"})
{
        "ok" : 0,
        "errmsg" : "in seed list a/localhost, host localhost:27017 does not belong to replica set a"
}
mongos> db.adminCommand({addShard:"a/localhost:27017"})
{
        "ok" : 0,
        "errmsg" : "in seed list a/localhost:27017, host localhost:27017 does not belong to replica set a"
}
mongos> db.adminCommand({addShard:"a/localhost:27017,localhost:27018"})
{
        "ok" : 0,
        "errmsg" : "in seed list a/localhost:27017,localhost:27018, host localhost:27017 does not belong to replica set a"
}
mongos> db.adminCommand({addShard:"localhost:27017"})
{
        "ok" : 0,
        "errmsg" : "host is part of set: a use replica set url format <setname>/<server1>,<server2>,...."
}
mongos> db.adminCommand({addShard:"LOCALHOST:27017"})
{
        "ok" : 0,
        "errmsg" : "can't use localhost as a shard since all shards need to communicate. either use all shards and configdbs in localhost or all in actual IPs  host: LOCALHOST:27017 isLocalHost:0"
}
mongos> db.adminCommand({addShard:"a/LOCALHOST:27017"})
{
        "ok" : 0,
        "errmsg" : "can't use localhost as a shard since all shards need to communicate. either use all shards and configdbs in localhost or all in actual IPs  host: LOCALHOST:27017 isLocalHost:0"
}
mongos> db.adminCommand({addShard:"a/LOCALHOST:27017,LOCALHOST:27018"})
{
        "ok" : 0,
        "errmsg" : "can't use localhost as a shard since all shards need to communicate. either use all shards and configdbs in localhost or all in actual IPs  host: LOCALHOST:27017 isLocalHost:0"
}



 Comments   
Comment by Andy Schwerin [ 24/Jun/19 ]

While MongoDB servers' treatment of hostnames ought to more closely match the behavior of DNS, it never has, and our attempt to change it ran into a lot of existing infrastructure that had come to rely on hostname case sensitivity. As such, we're no longer planning to change this behavior.

Comment by A. Jesse Jiryu Davis [ 11/Jun/19 ]

Reverted and reopened to give the Cloud Team time to adapt cloud monitoring for this change. This will not be released in 4.2.

Comment by A. Jesse Jiryu Davis [ 11/Jun/19 ]

When we reintroduce this patch, remember to apply two commits: the one for this ticket and the one for SERVER-41181.

ad9267a722e21268d1005c1428ccad85d5a98946

0ed0b97e6f62bba38cf4c93f5a7270569e79f24d

Comment by Githook User [ 11/Jun/19 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'email': 'jesse@mongodb.com', 'username': 'ajdavis'}

Message: Revert "SERVER-4999 Normalize all hostnames to lowercase"

This reverts commit ad9267a722e21268d1005c1428ccad85d5a98946 (SERVER-41614).
Branch: master
https://github.com/mongodb/mongo/commit/209e140be9a3d7426c204dee45548d52384dfa3c

Comment by Githook User [ 10/Jun/19 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'email': 'jesse@mongodb.com', 'username': 'ajdavis'}

Message: Revert "SERVER-4999 Normalize all hostnames to lowercase"

This reverts commit ad9267a722e21268d1005c1428ccad85d5a98946 (SERVER-41614).
Branch: v4.2
https://github.com/mongodb/mongo/commit/d9c43f9884938dd2c9e5a7062c1fc20ce087faf7

Comment by Githook User [ 14/May/19 ]

Author:

{'email': 'jesse@mongodb.com', 'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis'}

Message: SERVER-4999 Normalize all hostnames to lowercase

Hostnames passed to replSetInitiate, replSetReconfig, addShard, etc. are
all normalized by replacing ASCII uppercase characters with lowercase
characters, consistent with how MongoDB drivers treat hostnames.

The shell's getHostName() function now returns the hostname lowercased.

Fixes undefined behavior in mongo::str::toLower().
Branch: master
https://github.com/mongodb/mongo/commit/ad9267a722e21268d1005c1428ccad85d5a98946

Comment by A. Jesse Jiryu Davis [ 25/Apr/19 ]

Reverted and reopened while I work out some build failures.

Comment by Githook User [ 25/Apr/19 ]

Author:

{'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis', 'email': 'jesse@mongodb.com'}

Message: Revert "SERVER-4999 Normalize all hostnames to lowercase"

This reverts commit 5e346eb4b9bb3ec678d4eac36b3f0a18c1c10939.
Branch: master
https://github.com/mongodb/mongo/commit/a996036e453ef6c2719889d32f2d90817431529e

Comment by Githook User [ 25/Apr/19 ]

Author:

{'email': 'jesse@mongodb.com', 'name': 'A. Jesse Jiryu Davis', 'username': 'ajdavis'}

Message: SERVER-4999 Normalize all hostnames to lowercase

Hostnames passed to replSetInitiate, replSetReconfig, addShard, etc. are
all normalized by replacing ASCII uppercase characters with lowercase
characters, consistent with how MongoDB drivers treat hostnames.

Fixes undefined behavior in mongo::str::toLower().
Branch: master
https://github.com/mongodb/mongo/commit/5e346eb4b9bb3ec678d4eac36b3f0a18c1c10939

Comment by Dmitry Gusarov [ 23/Jan/18 ]

+1 please... I've wasted half a day before figured out one letter in server name been in wrong case
Getting wired error message when adding replica set of a shard:
in seed list S00/xxxDb-S00-A:27018, host xxxDb-S00-A:27018 d
oes not belong to replica set S00; found { hosts: [ "xxxDB-S00-A:27018", "xxx
DB-S00-B:27018", "xxxDB-S00-C:27018" ], setName: "S00"

Comment by Grégoire Seux [ 16/Oct/12 ]

All name should case insensitive and be more tolerant in general : ip, dns name, hostname should be seen as the same host if is really the same host.
This would easily done with a unique identifier per instance per node

Comment by Theo [ 17/Mar/12 ]

The description of this issue focus to much around replicaset and shards. This is wide spread throughout the product even when specifying hostnames on the command line and in configuration files. The desired fix is to make all hostnames case insensitive.

Comment by Spencer Brody (Inactive) [ 17/Feb/12 ]

The easiest fix would probably be to make the replica set and sharding configurations convert everything to lowercase when they're first added.

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