RavenDB 从 3.5 迁移到 5.0.3 会引发重复键错误

RavenDB migration from 3.5 to 5.0.3 throws duplicate key error

我正在将 RavenDB 实例从 3.5(build #35295)移动到 5.0.3(撰写本文时的最新版本)。我通过设置 > 导入数据 > 从 RavenDB 开始迁移。我只包括文档和索引。旧数据库使用了一段时间的修订,但不再这样做了。迁移失败的文档不是有修订的文档。

导入大约 650k 文档后,RavenDB 抛出错误

An item with the same key has already been added. Key: [Value: Redacted description, GlobalSortOrder: -1, PropertyId: 342, Value: Redacted description, GlobalSortOrder: -1, PropertyId: 342]
System.ArgumentException: An item with the same key has already been added. Key: [Value: Redacted description, GlobalSortOrder: -1, PropertyId: 342, Value: Redacted description, GlobalSortOrder: -1, PropertyId: 342]
   at System.Collections.Generic.TreeSet`1.AddIfNotPresent(T item)
   at System.Collections.Generic.SortedDictionary`2.Add(TKey key, TValue value)
   at Sparrow.Json.CachedProperties.UnlikelyGetProperty(LazyStringValue propName) in C:\Builds\RavenDB-Stable-5.0011\src\Sparrow\Json\CachedProperties.cs:line 157
   at Sparrow.Json.BlittableJsonDocumentBuilder.ReadInternal[TWriteStrategy]() in C:\Builds\RavenDB-Stable-5.0011\src\Sparrow\Json\BlittableJsonDocumentBuilder.cs:line 296
   at Sparrow.Json.Parsing.UnmanagedJsonParserHelper.ReadObject(BlittableJsonDocumentBuilder builder, PeepingTomStream peepingTomStream, UnmanagedJsonParser parser, MemoryBuffer buffer) in C:\Builds\RavenDB-Stable-5.0011\src\Sparrow\Json\Parsing\UnmanagedJsonParserHelper.cs:line 96
   at Raven.Server.Smuggler.Documents.StreamSource.ReadDocuments(INewDocumentActions actions)+MoveNext() in C:\Builds\RavenDB-Stable-5.0011\src\Raven.Server\Smuggler\Documents\StreamSource.cs:line 1184
   at Raven.Server.Smuggler.Documents.DatabaseSmuggler.ProcessDocuments(SmugglerResult result, BuildVersionType buildType) in C:\Builds\RavenDB-Stable-5.0011\src\Raven.Server\Smuggler\Documents\DatabaseSmuggler.cs:line 612
   at Raven.Server.Smuggler.Documents.DatabaseSmuggler.ProcessType(DatabaseItemType type, SmugglerResult result, BuildVersionType buildType, Boolean ensureStepsProcessed) in C:\Builds\RavenDB-Stable-5.0011\src\Raven.Server\Smuggler\Documents\DatabaseSmuggler.cs:line 190
   at Raven.Server.Smuggler.Documents.DatabaseSmuggler.Execute(Boolean ensureStepsProcessed, Boolean isLastFile) in C:\Builds\RavenDB-Stable-5.0011\src\Raven.Server\Smuggler\Documents\DatabaseSmuggler.cs:line 95
   at Raven.Server.Smuggler.Migration.Migrator_V3.MigrateDatabase(String json, Boolean readLegacyEtag) in C:\Builds\RavenDB-Stable-5.0011\src\Raven.Server\Smuggler\Migration\Migrator_V3.cs:line 338
   at Raven.Server.Smuggler.Migration.Migrator_V3.Execute() in C:\Builds\RavenDB-Stable-5.0011\src\Raven.Server\Smuggler\Migration\Migrator_V3.cs:line 99
   at Raven.Server.Smuggler.Migration.Migrator.<>c__DisplayClass15_1.<<StartMigratingSingleDatabase>b__1>d.MoveNext() in C:\Builds\RavenDB-Stable-5.0011\src\Raven.Server\Smuggler\Migration\Migrator.cs:line 318

“已编辑描述”包含在文档中找到的描述。它没有给我一个 id(即 products-1),它给了我文档的一部分。该文档具有唯一标识符。

经过一番挖掘,我检索到了文档,它看起来是这样的:

{
  ... other properties
  "Description": "Redacted description",
  ... other properties
  "Localisation": {
    "nl" {
      ... more translated content
      "Redacted description": "dutch translation (which is identical to Redacted description"
      ... more translated content
    },
    "fr": {
      ... more translated content
      "Redacted description": "french translation"
      ... more translated content
    }
  },
  ... more properties
}

省略的属性与编辑的描述不同,它们是日期、金额、百分比、布尔值、标签等

有人知道为什么数据库在此文档上失败吗?

如果我需要提供额外的信息,我可以。

抱歉,我无法 post 实际文件,但我不想泄露任何公司数据。 :) 在新冠疫情期间,我的客户对我来说太重要了,而 GDPR 的罚款对我的钱包来说有点太高了。

更新: 我尝试了选项 2,在创建数据库时从 3.X 数据库导入。现在我收到以下错误:

[18:13:01 INFO] Path of temporary export file: C:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp\export-MF.Studio-20201106_181301.ravendump
[18:13:22 INFO] Failed to initialize the storage it is probably been locked by RavenDB.
Error occurred during migration. Exception: System.ApplicationException: The data export tool have exited with code -532462766.
   at Raven.Server.Web.System.AdminDatabasesHandler.<>c__DisplayClass24_1.<<MigrateDatabaseOffline>b__2>d.MoveNext() in C:\Builds\RavenDB-Stable-5.0011\src\Raven.Server\Web\System\AdminDatabasesHandler.cs:line 1320. Process pid: 14668, killed: True
System.InvalidOperationException: Error occurred during migration. Exception: System.ApplicationException: The data export tool have exited with code -532462766.
   at Raven.Server.Web.System.AdminDatabasesHandler.<>c__DisplayClass24_1.<<MigrateDatabaseOffline>b__2>d.MoveNext() in C:\Builds\RavenDB-Stable-5.0011\src\Raven.Server\Web\System\AdminDatabasesHandler.cs:line 1320. Process pid: 14668, killed: True
   at Raven.Server.Web.System.AdminDatabasesHandler.<>c__DisplayClass24_1.<<MigrateDatabaseOffline>b__2>d.MoveNext() in C:\Builds\RavenDB-Stable-5.0011\src\Raven.Server\Web\System\AdminDatabasesHandler.cs:line 1353

我已经为运行 RavenDB5 服务(本地服务)的用户提供了对生产数据库文件夹的完全控制权(实际上是一个副本,但我也对实际生产数据库文件夹进行了尝试)。

我可以看到初始化在目标位置创建了文件,所以它在那里有足够的权限。

这似乎是一个错误,需要进行调查,如果你能提供转储文件(你可以匿名)将它发送给支持@ravendb.net

要解决此问题,您可以尝试使用其他选项迁移数据吗?

  1. 您可以设置 one-way 从 3.5 到 4 的复制。x/5.0 与在 3.5 服务器之间设置复制的方式相同。

为了允许复制到安全的 4.x/5.0 服务器,您可以修改配置文件并添加以下配置选项:

Raven/Replication/CertificatePath

Raven/Replication/CertificatePassword(可选)

证书必须从 4.x/5.0 服务器生成,并包含所需数据库的权限。 (运算符,如果您也需要迁移索引)。

  1. create a database from 3.x database or file system data
  2. live import data from a running instance