3

My application is shifted from MongoDB to DocumentDB. I get these errors after migration though I resolved the connectivity issue to AWS DocumentDB.

MongoError: namespace name generated from index name is too long
    at /app/node_modules/mongodb-core/lib/connection/pool.js:581:63
    at authenticateStragglers (/app/node_modules/mongodb-core/lib/connection/pool.js:504:16)
    at Connection.messageHandler (/app/node_modules/mongodb-core/lib/connection/pool.js:540:5)
    at emitMessageHandler (/app/node_modules/mongodb-core/lib/connection/connection.js:310:10)
    at TLSSocket.<anonymous> (/app/node_modules/mongodb-core/lib/connection/connection.js:453:17)
    at emitOne (events.js:116:13)
    at TLSSocket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at TLSSocket.Readable.push (_stream_readable.js:208:10)
    at TLSWrap.onread (net.js:601:20)
  ok: 0,
  errmsg: 'namespace name generated from index name is too long',

{ MongoError: system collection creation not supported
    at Function.create (/app/node_modules/mongodb-core/lib/error.js:43:12)
    at db.s.topology.insert (/app/node_modules/mongodb/lib/operations/db_ops.js:329:54)
    at handler (/app/node_modules/mongodb-core/lib/topologies/replset.js:1197:22)
    at /app/node_modules/mongodb-core/lib/connection/pool.js:532:18
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickCallback (internal/process/next_tick.js:181:9)
  index: 0,
  code: 73,
  errmsg: 'system collection creation not supported',
  name: 'MongoError',
  [Symbol(mongoErrorContextSymbol)]: {} }
ensuring Indexing
Stennie
  • 63,885
  • 14
  • 149
  • 175
Harish
  • 565
  • 1
  • 12
  • 34
  • The error messages look straightforward: these are differences in DocumentDB's emulation of MongoDB. DocumentDB is a different implementation from the MongoDB server, so variations in behaviour or limits should be expected. – Stennie Jun 11 '19 at 01:09

2 Answers2

2

Looks like you are hitting into the index name limit in DocumentDB. Try creating a shorter index if possible. Refer to this documentation to understand DocumentDB limits better:
https://docs.aws.amazon.com/documentdb/latest/developerguide/limits.html#limits.naming

1

Infact to our surprise, while https://docs.aws.amazon.com/documentdb/latest/developerguide/limits.html#limits.naming

mentions that the "Index Name" contraint can only allow Length is [3–63] characters. in actual it only supports 47 characters.

While we have reported this to AWS, we used name attribute provided by mongo to set name of the index explicitly to proceed further.

Infact, according to "Mongo 4.0 Index Key Limit" document, Mongo allows index name upto 128 characters Reference: https://docs.mongodb.com/v4.0/reference/limits/#Index-Key-Limit

Amit Thawait
  • 4,862
  • 2
  • 31
  • 25
  • Is it that the limit is truly 47, or that the index name length calculation includes the collection name? My understanding (which is admittedly limited) is that (if you'll pardon the Pythonesque interpolation) the length of `{collection_name}${index_name}` must be in the 3-63 character range. – C. Michael Pilato Sep 01 '23 at 15:02