Skip to content

Force temporary server to use unix socket only #443

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 12, 2021

Conversation

tianon
Copy link
Member

@tianon tianon commented Dec 4, 2020

Consider this an official "request for comments" 😅
(If your comment amounts to "I agree with this change" please just leave a thumbs up on this comment -- please don't make "+1" comments. 🙏)

This better matches the "initdb" behavior of the various SQL images, and avoids issues like running two instances in the same pod on different ports (and thus one of them failing to bind to 127.0.0.1:27017).

This is supported as of MongoDB 3.5+, and was discovered via https://stackoverflow.com/a/39901199/433558 -> https://jira.mongodb.org/browse/SERVER-9383 -> https://jira.mongodb.org/browse/SERVER-29403 (which was closed/fixed/implemented in 3.5.9).

Closes #440
Closes #437

This has implications for #437, #246, and probably many others, but for implementations like the one in #246 (comment), this would actually make things better because the second container wouldn't even be able to connect until the first initialization is fully complete (as seen in "proper" external setup solutions like https://gist.github.com/crapthings/71fb6156a8e9b31a2fa7946ebd7c4edc).

For reference, here's the output of rs.initiate() on a daemon that's listening on the unix socket only:

> rs.initiate();
{
	"operationTime" : Timestamp(0, 0),
	"ok" : 0,
	"errmsg" : "FailedToParse: Empty host component parsing HostAndPort from \":27017\" for member:{ _id: 0, host: \":27017\" }",
	"code" : 93,
	"codeName" : "InvalidReplicaSetConfig",
	"$clusterTime" : {
		"clusterTime" : Timestamp(0, 0),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	}
}
> rs.initiate({_id:"foo", members: [{"_id":1, "host":"test:27017"}]})
{
	"operationTime" : Timestamp(0, 0),
	"ok" : 0,
	"errmsg" : "No host described in new configuration with {version: 1, term: 0} for replica set foo maps to this node",
	"code" : 93,
	"codeName" : "InvalidReplicaSetConfig",
	"$clusterTime" : {
		"clusterTime" : Timestamp(0, 0),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	}
}

(Although IMO this isn't a huge deal because the real "conclusion" from #246 is that it's not really reasonable to do rs.initiate from our initdb scripts anyhow and that users should be using external setup solutions like https://gist.github.com/crapthings/71fb6156a8e9b31a2fa7946ebd7c4edc instead.)

This better matches the "initdb" behavior of the various SQL images, and avoids issues like running two instances in the same pod on different ports (and thus one of them failing to bind to 127.0.0.1:27017).

This is supported as of MongoDB 3.5+, and was discovered via https://stackoverflow.com/a/39901199/433558 -> https://jira.mongodb.org/browse/SERVER-9383 -> https://jira.mongodb.org/browse/SERVER-29403 (which was closed/fixed/implemented in 3.5.9).
Copy link
Member

@yosifkit yosifkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Since many are out on holiday, we should wait to merge until later in January.

@tianon
Copy link
Member Author

tianon commented Jan 11, 2021

New year, fresh eyes; does this still look good/interesting?

@yosifkit yosifkit merged commit 8ff1aa4 into docker-library:master Jan 12, 2021
@yosifkit yosifkit deleted the unix-socket branch January 12, 2021 22:28
docker-library-bot added a commit to docker-library-bot/official-images that referenced this pull request Jan 12, 2021
Changes:

- docker-library/mongo@8ff1aa4: Merge pull request docker-library/mongo#443 from infosiftr/unix-socket
@imsamurai
Copy link

imsamurai commented Jan 14, 2021

This MR broke our init script with mongorestore...

@tianon
Copy link
Member Author

tianon commented Jan 14, 2021

This is being reverted in #454 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants