Skip to content
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

Duplicate Key Error in BlockchainWriter onCreateBatchSuccess #813

Open
lautarodragan opened this issue Nov 26, 2018 · 11 comments
Open

Duplicate Key Error in BlockchainWriter onCreateBatchSuccess #813

lautarodragan opened this issue Nov 26, 2018 · 11 comments
Assignees
Labels

Comments

@lautarodragan
Copy link
Member

lautarodragan commented Nov 26, 2018

I'm finding this a lot in the QA environment logs.

{  
   "msg":"Anchor request failure",
   "module":"BlockchainWriter",
   "file":"Router",
   "method":"onCreateBatchSuccess",
   "error":{  
      "driver":true,
      "name":"MongoError",
      "index":0,
      "code":11000,
      "errmsg":"E11000 duplicate key error collection: regtest.blockchainWriter index: ipfsDirectoryHash_1 dup key: { : \"QmbuvwFrxRu54uLkF12Ch3LiBZyA8vRTiQ2rfPenM3jxX7\" }",
      "stack":[  
         "MongoError: E11000 duplicate key error collection: regtest.blockchainWriter index: ipfsDirectoryHash_1 dup key: { : \"QmbuvwFrxRu54uLkF12Ch3LiBZyA8vRTiQ2rfPenM3jxX7\" }",
         "    at Function.create (/usr/src/app/node_modules/mongodb-core/lib/error.js:43:12)",
         "    at toError (/usr/src/app/node_modules/mongodb/lib/utils.js:149:22)",
         "    at coll.s.topology.insert (/usr/src/app/node_modules/mongodb/lib/operations/collection_ops.js:844:39)",
         "    at handler (/usr/src/app/node_modules/mongodb-core/lib/topologies/replset.js:1195:22)",
         "    at /usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:532:18",
         "    at process._tickCallback (internal/process/next_tick.js:61:11)"
      ],
      "message":"E11000 duplicate key error collection: regtest.blockchainWriter index: ipfsDirectoryHash_1 dup key: { : \"QmbuvwFrxRu54uLkF12Ch3LiBZyA8vRTiQ2rfPenM3jxX7\" }",
      "type":"MongoError"
   },
   "ipfsDirectoryHash":"QmbuvwFrxRu54uLkF12Ch3LiBZyA8vRTiQ2rfPenM3jxX7",
   "v":1
}

I think there is one for each POST request.

@geoffturk geoffturk modified the milestone: PML1 Nov 27, 2018
@geoffturk geoffturk added ct-z and removed ct-z labels Nov 29, 2018
@geoffturk geoffturk added this to the PML1 milestone Nov 29, 2018
@geoffturk geoffturk assigned krobi64 and unassigned lautarodragan Nov 30, 2018
@geoffturk
Copy link
Contributor

Reassigning to @krobi64.

@krobi64
Copy link
Contributor

krobi64 commented Dec 4, 2018

Kris Robison [11:51 AM]
in our qa environment, do multiple node instances share the same RMQ and mongo instance?

Warren Vosper [12:09 PM]
hello! yes, that would be the case in any env unless MONGODB_DATABASE and EXCHANGE_PREFIX are set to unique values for each node instance.

So here’s what I believe is happening… there is a race condition between multiple node instances picking up the same event and attempting to do an insert. If we modify the hard insert, then I think that error message will go away

I’ll try to create a test that does that locally

@geoffturk
Copy link
Contributor

@warrenv Is this related to #328?

@warrenv
Copy link
Contributor

warrenv commented Dec 4, 2018

yes, this is probably a subset of the issue in #328

@lautarodragan
Copy link
Member Author

lautarodragan commented Dec 5, 2018

Discussed this with Kris on the side, leaving a comment here for reference.

This is most likely not an issue related to #328, since the QA node instances don't share the same db, and there's only one instance of the node for each (one mainnet, one testnet).

@geoffturk
Copy link
Contributor

OK, so even with a freshly reset DB (regtest DB in QA), this error pops up for the very first work being written into the DB:

> @po.et/node@1.0.3 start /usr/src/app
> node dist/babel/src

Running Po.et Node

Loading Configuration...
Switching to Structured Logging
Logging Level: error

(node:26) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
Fri, 07 Dec 2018 10:20:01 GMT koa deprecated Support for generators will be removed in v3. See the documentation for examples of how to convert old middleware https://github.com/koajs/koa/blob/master/docs/migration.md at dist/babel/src/API/Router.js:108:18
(node:26) DeprecationWarning: collection.find option [fields] is deprecated and will be removed in a later version.
{"level":50,"time":1544181002026,"msg":"Anchor request failure","pid":26,"hostname":"node-regtest-poet-node-57d569b6b8-djst8","module":"BlockchainWriter","file":"Router","method":"onCreateBatchSuccess","error":{"driver":true,"name":"MongoError","index":0,"code":11000,"errmsg":"E11000 duplicate key error collection: regtest.blockchainWriter index: ipfsDirectoryHash_1 dup key: { : \"QmdjuqK3GQnDnB9KfoKHApXpTR7DUb4haMfVcK1kjT2jCo\" }","stack":["MongoError: E11000 duplicate key error collection: regtest.blockchainWriter index: ipfsDirectoryHash_1 dup key: { : \"QmdjuqK3GQnDnB9KfoKHApXpTR7DUb4haMfVcK1kjT2jCo\" }","    at Function.create (/usr/src/app/node_modules/mongodb-core/lib/error.js:43:12)","    at toError (/usr/src/app/node_modules/mongodb/lib/utils.js:149:22)","    at coll.s.topology.insert (/usr/src/app/node_modules/mongodb/lib/operations/collection_ops.js:844:39)","    at handler (/usr/src/app/node_modules/mongodb-core/lib/topologies/replset.js:1195:22)","    at /usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:532:18","    at process._tickCallback (internal/process/next_tick.js:61:11)"],"message":"E11000 duplicate key error collection: regtest.blockchainWriter index: ipfsDirectoryHash_1 dup key: { : \"QmdjuqK3GQnDnB9KfoKHApXpTR7DUb4haMfVcK1kjT2jCo\" }","type":"MongoError"},"ipfsDirectoryHash":"QmdjuqK3GQnDnB9KfoKHApXpTR7DUb4haMfVcK1kjT2jCo","v":1}

@krobi64
Copy link
Contributor

krobi64 commented Dec 12, 2018

@WesleyCharlesBlake Are we seeing this error in production or only QA? I tried looking for it in Logz, but the only error messages I see are Access Denied.

I have yet to figure out how to replicate it locally.

@geoffturk
Copy link
Contributor

@WesleyCharlesBlake ^^^^^^^^^^^^^^^^

@geoffturk
Copy link
Contributor

@krobi64 We're getting them in prod as well as QA.

@geoffturk
Copy link
Contributor

Also, found this other variant on an IPFS directory:

t error.errmsg |   | E11000 duplicate key error collection: mainnet.ipfsDirectoryHashInfo index: ipofsDirectoryHash_1 dup key: { : null }
? error.index |   | 0
t error.message |   | E11000 duplicate key error collection: mainnet.ipfsDirectoryHashInfo index: ipofsDirectoryHash_1 dup key: { : null }
t error.name |   | MongoError
t error.stack |   | MongoError: E11000 duplicate key error collection: mainnet.ipfsDirectoryHashInfo index: ipofsDirectoryHash_1 dup key: { : null },     at Function.create (/usr/src/app/node_modules/mongodb-core/lib/error.js:43:12),     at toError (/usr/src/app/node_modules/mongodb/lib/utils.js:149:22),     at coll.s.topology.update (/usr/src/app/node_modules/mongodb/lib/operations/collection_ops.js:1399:39),     at handler (/usr/src/app/node_modules/mongodb-core/lib/topologies/replset.js:1195:22),     at /usr/src/app/node_modules/mongodb-core/lib/connection/pool.js:532:18,     at process._tickCallback (internal/process/next_tick.js:61:11)

@WesleyCharlesBlake
Copy link
Member

yep getting it in both QA and PROD

@lautarodragan lautarodragan self-assigned this Jan 4, 2019
@lautarodragan lautarodragan removed this from the PML1 milestone Jan 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants