Skip to content

mgo writeConcern wtimeout does not work  #175

Closed
@Mei-Zhao

Description

@Mei-Zhao

After obtain a session using the Dial function(mgo.Dial(url)), try to make the session in safety mode (session.EnsureSafe) with wmode="majority" and wtimeout = 5000. I should get the writeConcernErr of a insert command because the mongo cluster has 5 nodes and 3 was locked by fsyncLock.
After 1 min (the default socketTimeout) I got net tcp error like "read tcp i/o timeout".

Some details about code in newSession function:

`

func newSession(consistency Mode, cluster *mongoCluster, timeout time.Duration) (session *Session) {

......
session.SetMode(consistency, true)

session.SetSafe(&Safe{})

session.queryConfig.prefetch = defaultPrefetch

return session

}
`

The session has beed init safe mode with &Safe{}.Wtimeout has beed set to 0.

The ensureSafe function will try to update the safe mode with some check ,detail in code:

`
var cmd getLastError

if s.safeOp == nil {

	cmd = getLastError{1, w, safe.WTimeout, safe.FSync, safe.J}

} else {

           ......

           if safe.WTimeout > 0 && safe.WTimeout < cmd.WTimeout {

		cmd.WTimeout = safe.WTimeout

	}

         ......

   }

`
This condition could not be true cause cmd.WTimeout is 0.So the wtimeout always is 0.

I could see the wmode=majority but no wtimeout info of writeConcern with the mongosniff, some test result ;
2018/05/25-10:10:31.146682 [10.46.22.23:44792] QUERY id:7 coll:test.$cmd toskip:0 toret:-1 flag:0 query:{"documents":[{"_id":1,"val":"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="}],"insert":"test2","ordered":true,"writeConcern":{"getLastError":1,"w":"majority"}} sel:null

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions