从 mongoDB 迁移后出现 AWS DocumentDB 错误
AWS DocumentDB errors after migration from mongoDB
我的应用程序已从 MongoDB 转移到 DocumentDB。虽然我解决了与 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
您似乎遇到了 DocumentDB 中的索引名称限制。如果可能,请尝试创建一个较短的索引。请参阅此文档以更好地了解 DocumentDB 限制:
https://docs.aws.amazon.com/documentdb/latest/developerguide/limits.html#limits.naming
事实上,令我们惊讶的是,虽然
https://docs.aws.amazon.com/documentdb/latest/developerguide/limits.html#limits.naming
提到“Index Name”限制只能允许Length is [3–63] characters.
实际上它只支持47个字符。
虽然我们已将此报告给 AWS,但我们使用了 mongo 提供的 name
属性来明确设置索引的 name
以进一步处理。
事实上,根据“Mongo 4.0 Index Key Limit”文档,Mongo 允许索引名称最多 128 个字符
参考:https://docs.mongodb.com/v4.0/reference/limits/#Index-Key-Limit
我的应用程序已从 MongoDB 转移到 DocumentDB。虽然我解决了与 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
您似乎遇到了 DocumentDB 中的索引名称限制。如果可能,请尝试创建一个较短的索引。请参阅此文档以更好地了解 DocumentDB 限制:
https://docs.aws.amazon.com/documentdb/latest/developerguide/limits.html#limits.naming
事实上,令我们惊讶的是,虽然 https://docs.aws.amazon.com/documentdb/latest/developerguide/limits.html#limits.naming
提到“Index Name”限制只能允许Length is [3–63] characters.
实际上它只支持47个字符。
虽然我们已将此报告给 AWS,但我们使用了 mongo 提供的 name
属性来明确设置索引的 name
以进一步处理。
事实上,根据“Mongo 4.0 Index Key Limit”文档,Mongo 允许索引名称最多 128 个字符 参考:https://docs.mongodb.com/v4.0/reference/limits/#Index-Key-Limit