FerretDB / FerretDB

A truly Open Source MongoDB alternative
https://www.ferretdb.com
Apache License 2.0
9.22k stars 405 forks source link

mongoimport index creation fails #4638

Open conmarti opened 1 week ago

conmarti commented 1 week ago

FerretDB version

v1.24.0

Backend

PostgreSQL 16

Environment

What did you do?

What did you expect to see?

successful import without any error

What did you see instead?

mongorestore showed errors when trying to create additional indexes and indexes are not created at PostgreSQL DB.

Failed: made_su_db.mongobeelock: error creating indexes for made_su_db.mongobeelock: createIndex error: (BadValue) Index option "ns" is unknown

in ferretdb log

2024-11-26T14:53:23.720Z    DEBUG   clientconn/conn.go:263  Request message:
{
  "FlagBits": "[]",
  "Checksum": int64(0),
  "Sections": [
    {
      "Kind": 0,
      "Document": {
        "createIndexes": "mongobeelock",
        "indexes": [
          {
            "key": {"key": 1},
            "unique": true,
            "ns": "made_su_db.mongobeelock",
            "name": "mongobeelock_key_idx",
          },
        ],
        "ignoreUnknownIndexOptions": true,
        "lsid": {"id": Binary(uuid:UhLZSibLRFWb2W/kS7zICg==)},
        "$db": "made_su_db",
      },
    },
  ],
}
    {"name":"// 10.42.125.26:49896 -> 10.42.141.153:27017 "}
2024-11-26T14:53:23.720Z    WARN    clientconn/conn.go:624  Response header: length:   112, id:   11, response_to:   14, opcode: OP_MSG {"name":"// 10.42.125.26:49896 -> 10.42.141.153:27017 "}
2024-11-26T14:53:23.720Z    WARN    clientconn/conn.go:625  Response message:
{
  "FlagBits": "[]",
  "Checksum": int64(0),
  "Sections": [
    {
      "Kind": 0,
      "Document": {
        "ok": 0.0,
        "errmsg": "Index option \"ns\" is unknown",
        "code": 2,
        "codeName": "BadValue",
      },
    },
  ],
}
    {"name":"// 10.42.125.26:49896 -> 10.42.141.153:27017 "}
chilagrow commented 6 days ago

Thanks for reporting this 🙏

I see in the request that createIndexes command has ns option and FerretDB currently returns an error upon unknown options. It would make sense for FerretDB to ignore such field for the compatibility.