从3.5到5.0.3的RavenDB迁移引发重复密钥错误

从3.5到5.0.3的RavenDB迁移引发重复密钥错误,ravendb,ravendb5,ravendb-3.5,Ravendb,Ravendb5,Ravendb 3.5,我正在将一个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:

我正在将一个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.0\50011\src\Sparrow\Json\CachedProperties.cs:line 157
   at Sparrow.Json.BlittableJsonDocumentBuilder.ReadInternal[TWriteStrategy]() in C:\Builds\RavenDB-Stable-5.0\50011\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.0\50011\src\Sparrow\Json\Parsing\UnmanagedJsonParserHelper.cs:line 96
   at Raven.Server.Smuggler.Documents.StreamSource.ReadDocuments(INewDocumentActions actions)+MoveNext() in C:\Builds\RavenDB-Stable-5.0\50011\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.0\50011\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.0\50011\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.0\50011\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.0\50011\src\Raven.Server\Smuggler\Migration\Migrator_V3.cs:line 338
   at Raven.Server.Smuggler.Migration.Migrator_V3.Execute() in C:\Builds\RavenDB-Stable-5.0\50011\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.0\50011\src\Raven.Server\Smuggler\Migration\Migrator.cs:line 318
ommited属性与修订后的描述不同,它们是日期、金额、百分比、布尔值、标记等

有人知道数据库在这个文档上失败的原因吗

如果我需要提供更多信息,我可以

很抱歉,我无法发布实际文档,但我不想泄露任何公司数据。:)在科罗纳时代,我的客户对我来说太贵了,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.0\50011\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.0\50011\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.0\50011\src\Raven.Server\Web\System\AdminDatabasesHandler.cs:line 1353
临时导出文件的路径:C:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp\export-MF.Studio-20201106\u 181301.ravendump [18:13:22信息]无法初始化存储,它可能已被RavenDB锁定。 迁移期间发生错误。异常:System.ApplicationException:数据导出工具已退出,代码为-532462766。 在c:\Builds\RavenDB-Stable-5.0\50011\src\Raven.Server\Web\System.AdminDatabasesHandler.c\uu中显示class24\u 1.d.MoveNext():第1320行。进程pid:14668,终止:真 System.InvalidOperationException:迁移期间发生错误。异常:System.ApplicationException:数据导出工具已退出,代码为-532462766。 在c:\Builds\RavenDB-Stable-5.0\50011\src\Raven.Server\Web\System.AdminDatabasesHandler.c\uu中显示class24\u 1.d.MoveNext():第1320行。进程pid:14668,终止:真 在c:\Builds\RavenDB-Stable-5.0\50011\src\Raven.Server\Web\System.AdminDatabasesHandler.c\uu中显示Class24\u 1.d.MoveNext():第1353行 我已经让运行RavenDB5服务(本地服务)的用户完全控制了生产数据库文件夹(实际上是一个副本,但我也尝试了实际的生产数据库文件夹)


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

这似乎是一个错误,需要进行调查,如果您可以提供转储文件(您可以将其匿名化)并将其发送给support@ravendb.net

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

  • 您可以设置从3.5到4.x/5.0的单向复制,设置方式与设置3.5服务器之间的复制相同
  • 为了允许复制到安全的4.x/5.0服务器,您可以修改配置文件并添加以下配置选项:

    Raven/Replication/CertificatePath

    Raven/复制/证书密码(可选)

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


  • 谢谢你的建议!我尝试了选项3,但出现了错误。今晚下班后我将尝试选项2,因为我需要在导入时关闭旧的db。此导入不会删除或更改旧文件,对吗?由于这是我第一次与raven合作(这里没有人帮助我),我如何创建匿名转储文件?是我在导入窗口中看到的输出吗?是否还有其他文件需要检查?该文档似乎不是正确的json格式,请尝试使用json解析器运行它,或者将其删除。Holy sh。。有一个对象,其中键中有html,并且它也有特殊字符(\r\n)。这就是问题的根源。非常感谢你!
    [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.0\50011\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.0\50011\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.0\50011\src\Raven.Server\Web\System\AdminDatabasesHandler.cs:line 1353