如何修复损坏的 JetBrains Xodus 数据库完整性?

How to repair corrupted integrity of a JetBrains Xodus database?

背景:我们的 YouTrack 数据库已损坏。相关的错误报告在这里:https://youtrack.jetbrains.com/issue/JT-48235#comment=27-2952375现在我正在尝试修复 YouTrack 内部使用的 Xodus 数据库的损坏状态。

问题:数据库包含具有 link 已删除实体的实体。我的问题是:如何删除或修复这些损坏的 links?

关闭 YouTrack 后,我使用 Xodus Entity Browser 检查数据库。

我想到了两个可能的解决方案:

  1. 重新创建已删除的实体。在我的例子中是 Sprint[86-191]。这不起作用,因为创建新实体不允许我再次选择数字 191。相反,它创建了 Sprint[86-208].
  2. 删除损坏的link。没有工作,因为为了删除 link,Xodus 期望数据库的一致性导致以下堆栈跟踪:
jetbrains.xodus.browser.web.EntityNotFoundException: jetbrains.exodus.entitystore.EntityRemovedInDatabaseException: Sprint was removed.                                                       
        at jetbrains.xodus.browser.web.db.StoreService.getEntity(StoreService.kt:204) ~[xodus-entity-browser.jar:na]                                                                          
        at jetbrains.xodus.browser.web.db.StoreService.access$getEntity(StoreService.kt:14) ~[xodus-entity-browser.jar:na]                                                                    
        at jetbrains.xodus.browser.web.db.StoreService$getEntity.invoke(StoreService.kt:168) ~[xodus-entity-browser.jar:na]                                                                 
        at jetbrains.xodus.browser.web.db.StoreService$getEntity.invoke(StoreService.kt:14) ~[xodus-entity-browser.jar:na]                                                                  
        at jetbrains.xodus.browser.web.db.StoreServiceKt$transactional.compute(StoreService.kt:229) ~[xodus-entity-browser.jar:na]                                                          
        at jetbrains.exodus.entitystore.PersistentEntityStoreImpl.computeInTransaction(PersistentEntityStoreImpl.java:596) ~[xodus-entity-browser.jar:na]                                     
        at jetbrains.xodus.browser.web.db.StoreServiceKt.transactional(StoreService.kt:229) ~[xodus-entity-browser.jar:na]                                                                    
        at jetbrains.xodus.browser.web.db.StoreService.transactional(StoreService.kt:218) ~[xodus-entity-browser.jar:na]                                                                      
        at jetbrains.xodus.browser.web.db.StoreService.getEntity(StoreService.kt:167) ~[xodus-entity-browser.jar:na]                                                                          
        at jetbrains.xodus.browser.web.resources.Entities$registerRouting.invoke(Entities.kt:37) ~[xodus-entity-browser.jar:na]                                                           
        at jetbrains.xodus.browser.web.resources.Entities$registerRouting.invoke(Entities.kt:10) ~[xodus-entity-browser.jar:na]                                                           
        at jetbrains.xodus.browser.web.WebConfigKt$safeGet.invoke(WebConfig.kt:61) ~[xodus-entity-browser.jar:na]                                                                           
        at jetbrains.xodus.browser.web.WebConfigKt$safeGet.invoke(WebConfig.kt) ~[xodus-entity-browser.jar:na]                                                                              
        at spark.kotlin.Http$get.handle(Http.kt:560) ~[xodus-entity-browser.jar:na]
        at spark.RouteImpl.handle(RouteImpl.java:72) ~[xodus-entity-browser.jar:na]
        at spark.http.matching.Routes.execute(Routes.java:61) ~[xodus-entity-browser.jar:na]
        at spark.http.matching.MatcherFilter.doFilter(MatcherFilter.java:130) ~[xodus-entity-browser.jar:na]                                                                                  
        at spark.embeddedserver.jetty.JettyHandler.doHandle(JettyHandler.java:50) [xodus-entity-browser.jar:na]                                                                               
        at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1568) [xodus-entity-browser.jar:na]                                                                    
        at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [xodus-entity-browser.jar:na]                                                                        
        at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132) [xodus-entity-browser.jar:na]                                                                      
        at org.eclipse.jetty.server.Server.handle(Server.java:564) [xodus-entity-browser.jar:na]                                                                                              
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:317) [xodus-entity-browser.jar:na]                                                                                    
        at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:251) [xodus-entity-browser.jar:na]                                                                          
        at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279) [xodus-entity-browser.jar:na]                                                          
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110) [xodus-entity-browser.jar:na]                                                                                    
        at org.eclipse.jetty.io.ChannelEndPoint.run(ChannelEndPoint.java:124) [xodus-entity-browser.jar:na]                                                                                 
        at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:128) [xodus-entity-browser.jar:na]                                                                          
        at org.eclipse.jetty.util.thread.Invocable$InvocableExecutor.invoke(Invocable.java:222) [xodus-entity-browser.jar:na]                                                                 
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:294) [xodus-entity-browser.jar:na]                                                             
        at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:199) [xodus-entity-browser.jar:na]                                                                   
        at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:673) [xodus-entity-browser.jar:na]                                                                     
        at org.eclipse.jetty.util.thread.QueuedThreadPool.run(QueuedThreadPool.java:591) [xodus-entity-browser.jar:na]                                                                      
        at java.lang.Thread.run(Thread.java:748) [na:1.8.0_171]
Caused by: jetbrains.exodus.entitystore.EntityRemovedInDatabaseException: Sprint was removed.
        at jetbrains.exodus.entitystore.PersistentStoreTransaction.getEntity(PersistentStoreTransaction.java:276) ~[xodus-entity-browser.jar:na]                                              
        at jetbrains.xodus.browser.web.db.StoreService.getEntity(StoreService.kt:201) ~[xodus-entity-browser.jar:na]                                                                          
        ... 33 common frames omitted

有没有办法解决这个损坏的状态?

使用 java 参数 -Dexodus.entityStore.refactoring.heavyLinks=true 启动 YouTrack。您无需在每次启动时都强制执行此重构。