Skip to content

Connection to the mongo server is periodically reconnected #101

Closed
@changwoo-nam

Description

@changwoo-nam

description

The isMaster request fails in syncServersIteration(), which is repeatedly executed, and disconnects from the existing mongodb server and repeats the connection again.

This causes user requests to mongodb to be periodically delayed.

It seems to occur when an isMaster request is made through a pooled mongodb connection.

  • mgo debug log
2018/02/07 19:12:33 Cluster 0xc4202cc900 acquired (refs=3)
2018/02/07 19:12:33 New session 0xc4203ed380 on cluster 0xc4202cc900
2018/02/07 19:12:33 Session 0xc4203ed380: setting mode 1 with refresh=true (master=0x0, slave=0x0)
2018/02/07 19:12:33 Socket 0xc420660000 to 10.101.216.180:27017: serializing op: &mgo.queryOp{query:bson.D{bson.DocElem{Name:"isMaster", Value:1}, bson.DocElem{Name:"client", Value:bson.M{"driver":bson.M{"name":"mgo", "version":"globalsign"}, "os":bson.M{"type":"linux", "architecture":"amd64"}}}}, collection:"admin.$cmd", serverTags:[]bson.D(nil), selector:interface {}(nil), replyFunc:(mgo.replyFunc)(0x869280), mode:1, skip:0, limit:-1, options:mgo.queryWrapper{Query:interface {}(nil), OrderBy:interface {}(nil), Hint:interface {}(nil), Explain:false, Snapshot:false, ReadPreference:bson.D(nil), MaxScan:0, MaxTimeMS:0, Comment:"", Collation:(*mgo.Collation)(nil)}, hasOptions:false, flags:0x4, readConcern:""}
2018/02/07 19:12:33 final query is &mgo.queryWrapper{Query:bson.D{bson.DocElem{Name:"isMaster", Value:1}, bson.DocElem{Name:"client", Value:bson.M{"driver":bson.M{"name":"mgo", "version":"globalsign"}, "os":bson.M{"architecture":"amd64", "type":"linux"}}}}, OrderBy:interface {}(nil), Hint:interface {}(nil), Explain:false, Snapshot:false, ReadPreference:bson.D{bson.DocElem{Name:"mode", Value:"secondaryPreferred"}}, MaxScan:0, MaxTimeMS:0, Comment:"", Collation:(*mgo.Collation)(nil)}
2018/02/07 19:12:33 Socket 0xc420660000 to 10.101.216.180:27017: sending 1 op(s) (235 bytes)
2018/02/07 19:12:33 Socket 0xc420660000 to 10.101.216.180:27017: updated write deadline to 5s ahead (2018-02-07 19:12:38.348446658 +0900 KST)
2018/02/07 19:12:33 Socket 0xc420660000 to 10.101.216.180:27017: updated read deadline to 5s ahead (2018-02-07 19:12:38.348473501 +0900 KST)
2018/02/07 19:12:33 Socket 0xc420660000 to 10.101.216.180:27017: got reply (187 bytes)
2018/02/07 19:12:33 Socket 0xc420660000 to 10.101.216.180:27017: received document: bson.M{"ok":0, "errmsg":"The client metadata document may only be sent in the first isMaster", "code":186, "codeName":"ClientMetadataCannotBeMutated"}
2018/02/07 19:12:33 Run command unmarshaled: mgo.queryOp{query:bson.D{bson.DocElem{Name:"isMaster", Value:1}, bson.DocElem{Name:"client", Value:bson.M{"driver":bson.M{"name":"mgo", "version":"globalsign"}, "os":bson.M{"type":"linux", "architecture":"amd64"}}}}, collection:"admin.$cmd", serverTags:[]bson.D(nil), selector:interface {}(nil), replyFunc:(mgo.replyFunc)(0x869280), mode:1, skip:0, limit:-1, options:mgo.queryWrapper{Query:bson.D{bson.DocElem{Name:"isMaster", Value:1}, bson.DocElem{Name:"client", Value:bson.M{"driver":bson.M{"name":"mgo", "version":"globalsign"}, "os":bson.M{"type":"linux", "architecture":"amd64"}}}}, OrderBy:interface {}(nil), Hint:interface {}(nil), Explain:false, Snapshot:false, ReadPreference:bson.D{bson.DocElem{Name:"mode", Value:"secondaryPreferred"}}, MaxScan:0, MaxTimeMS:0, Comment:"", Collation:(*mgo.Collation)(nil)}, hasOptions:true, flags:0x4, readConcern:""}, result: bson.M{"ok":0, "errmsg":"The client metadata document may only be sent in the first isMaster", "code":186, "codeName":"ClientMetadataCannotBeMutated"}
2018/02/07 19:12:33 Closing session 0xc4203ed380
2018/02/07 19:12:33 unset master socket from session 0xc4203ed380
2018/02/07 19:12:33 Cluster 0xc4202cc900 released (refs=2)
2018/02/07 19:12:33 SYNC Command 'ismaster' to 10.101.216.180:27017 failed: The client metadata document may only be sent in the first isMaster
2018/02/07 19:12:33 Connections to 10.101.216.180:27017 closing (1 live sockets).
2018/02/07 19:12:33 Socket 0xc420660000 to 10.101.216.180:27017: closing: Closed explicitly (abend=false)
2018/02/07 19:12:33 Socket 0xc420660000 to 10.101.216.180:27017: idle and close.
2018/02/07 19:12:33 Removed server 10.101.216.180:27017 from cluster.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions