Automattic / Automattic/monk

not master error with read preference set as secondary

Open
#247 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.8k
Forks
180
PR merge metrics
No merged PRs in 30d

Description

My database object shows this when logged:
```
reconnect: [Function],
timeout: [Function] },
_eventsCount: 7,
_maxListeners: undefined,
s:
{ databaseName: 'users',
dbCache: {},
children: [],
topology:
Server {
domain: null,
_events: [Object],
_eventsCount: 7,
_maxListeners: undefined,
clientInfo: [Object],
s: [Object] },
options:
{ readPreference: [Object],
promiseLibrary: [Function: Promise] },
logger: Logger { className: 'Db' },
bson: BSON {},
authSource: undefined,
readPreference:
ReadPreference {
_type: 'ReadPreference',
mode: 'secondary',
tags: undefined,
options: undefined },
bufferMaxEntries: -1,
parentDb: null,
pkFactory: undefined,
nativeParser: undefined,
promiseLibrary: [Function: Promise],
noListener: false,
readConcern: undefined },
serverConfig: [Getter],
bufferMaxEntries: [Getter],
databaseName: [Getter] }
```
carrying out the write operation still shows the following error
```
{ MongoError: not master
at Function.MongoError.create (/usr/src/app/node_modules/mongodb-core/lib/error.js:31:11)
at /usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:497:72
at authenticateStragglers (/usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:443:16)
at Connection.messageHandler (/usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:477:5)
at Socket. (/usr/src/app/node_modules/mongodb-core/lib/connection/connection.js:331:22)
at emitOne (events.js:96:13)
at Socket.emit (events.js:191:7)
at readableAddChunk (_stream_readable.js:178:18)
at Socket.Readable.push (_stream_readable.js:136:10)
at TCP.onread (net.js:561:20)
name: 'MongoError',
message: 'not master',
ok: 0,
errmsg: 'not master',
code: 10107,
codeName: 'NotMaster' }
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the write with the database read preference set to secondary, then inspect the MongoDB-related call path shown in mongodb-core/lib/connection/pool.js and connection.js. Compare the configured read preference with the write operation and determine the expected behavior for the reported NotMaster error; done means the behavior is understood and the issue has a reproducible resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, mongodb
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.