使用 MongoDB 中的某些时区时出错

Error when working with some time zones in MongoDB

我有 Ubuntu 20.04 服务器,安装了 MongoDB 5.0,运行 official tutorial。我遇到了一些时区问题,例如 Etc/UTC 时区。我收到错误“无法识别的时区标识符”:

> db.data.insert({ dt: new ISODate() })
WriteResult({ "nInserted" : 1 })
> db.data.aggregate([
...     {
...         "$project": {
...             "dtTimezone": {
...                 "$dateToString": {
...                     "date": "$dt",
...                     "timezone": "Etc/UTC"
...                 }
...             }
...         }
...     }
... ])
uncaught exception: Error: command failed: {
    "ok" : 0,
    "errmsg" : "PlanExecutor error during aggregation :: caused by :: unrecognized time zone identifier: \"Etc/UTC\"",
    "code" : 40485,
    "codeName" : "Location40485"
} with original command request: {
    "aggregate" : "data",
    "pipeline" : [
        {
            "$project" : {
                "dtTimezone" : {
                    "$dateToString" : {
                        "date" : "$dt",
                        "timezone" : "Etc/UTC"
                    }
                }
            }
        }
    ],
    "cursor" : {
        
    },
    "lsid" : {
        "id" : UUID("24a0ca58-6d03-4827-b59c-4bd82ddf9976")
    }
} on connection: connection to 127.0.0.1:27017 : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:18:14
_assertCommandWorked@src/mongo/shell/assert.js:719:17
assert.commandWorked@src/mongo/shell/assert.js:811:16
DB.prototype._runAggregate@src/mongo/shell/db.js:276:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1058:12
@(shell):1:1

同时,当使用Europe/London时,一切正常:

> db.data.aggregate([
...     {
...         "$project": {
...             "dtTimezone": {
...                 "$dateToString": {
...                     "date": "$dt",
...                     "timezone": "Europe/London"
...                 }
...             }
...         }
...     }
... ])
{ "_id" : ObjectId("611832f076340952c425ce80"), "dtTimezone" : "2021-08-14T22:17:36.349Z" }

我找到了similar problem, but the solution was to comment "processManagement.timeZoneInfo" option and use internal timezones database. I've also tried copying timezones database from the MongoDB documentation,但没有任何区别:

curl -O https://downloads.mongodb.org/olson_tz_db/timezonedb-latest.zip
unzip timezonedb-latest.zip
rsync -a --delete timezonedb-2021a/ /usr/share/zoneinfo/
systemctl restart mongod

可能是什么问题?为什么系统数据库不适合 MongoDB?

这是 MongoDB 中的错误,已在 5.0.4 中修复:https://jira.mongodb.org/browse/SERVER-59701