cssxsh / mirai-hibernate-plugin

Mirai Console Hibernate/ORM 数据库前置插件
GNU Affero General Public License v3.0
31 stars 1 forks source link

升级到2.15(dev98)后,无法获取聊天记录 #17

Closed Natsukage closed 1 year ago

Natsukage commented 1 year ago

同样的代码在2.14版mirai时工作正常(之前我还提过一次功能请求的issue) 当在2.15.0-dev-98 (fix-protocol 1.71 Android_Pad 8.8.88)登录后,通过mirai-hibernate-http请求群组的历史记录将会报错 返回内容为

{"code":500,"msg":"net/mamoe/mirai/message/data/MessageSourceKind$$serializer"}

mirai-hibernate-httpmirai-hibernate-plugin均已更新至最新版本。但是我并不确定究竟具体是哪一边导致的这个问题,所以只好先汇报在这边的issue了。

以下为我访问时的方式,为C#代码,不过这段代码之前2.14时是完全正常工作的,应该不会是这里的问题,列在这里仅供参考

private static async Task<string> GetChatHistory(string groupId, int days = 3)
{
    string url = $"http://{MiraiBot.Instance.Address.HttpAddress}";
    return await url.AppendPathSegments("message", "group")
        .SetQueryParams(new
        {
            bot = MiraiBot.Instance.QQ,
            group = groupId,
            start = DateTimeOffset.Now.AddDays(-days).ToUnixTimeSeconds(),
            end = DateTimeOffset.Now.ToUnixTimeSeconds(),
        })
        .WithHeader("Authorization", $"session {MiraiBot.Instance.HttpSessionKey}")
        .GetStringAsync(); ;
}
cssxsh commented 1 year ago

汇报问题请报具体的版本信息,最新版本 是随时间变动的,没有参考意义

https://github.com/mamoe/mirai/commit/427c37e6499d089d9b64c310a40de600af9745bf#diff-c1c2c95e10d73bad89764533c4e4cd48653a02484f07df8316b8fa9fc15da0c8 有关,需要在 2.15.0+下重新编译 mirai-hibernate-plugin

java.lang.NoClassDefFoundError: net/mamoe/mirai/message/data/MessageSourceKind$$serializer
    at mirai-hibernate-plugin-2.7.1.mirai2.jar//xyz.cssxsh.mirai.hibernate.entry.MessageRecord.write$Self(MessageRecord.kt:27)
    at mirai-hibernate-plugin-2.7.1.mirai2.jar//xyz.cssxsh.mirai.hibernate.entry.MessageRecord$$serializer.serialize(MessageRecord.kt:27)
    at mirai-hibernate-plugin-2.7.1.mirai2.jar//xyz.cssxsh.mirai.hibernate.entry.MessageRecord$$serializer.serialize(MessageRecord.kt:27)
    at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(StreamingJsonEncoder.kt:228)
    at kotlinx.serialization.encoding.AbstractEncoder.encodeSerializableElement(AbstractEncoder.kt:80)
    at kotlinx.serialization.internal.CollectionLikeSerializer.serialize(CollectionSerializers.kt:69)
    at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(StreamingJsonEncoder.kt:228)
    at kotlinx.serialization.encoding.Encoder$DefaultImpls.encodeNullableSerializableValue(Encoding.kt:299)
    at kotlinx.serialization.encoding.AbstractEncoder.encodeNullableSerializableValue(AbstractEncoder.kt:18)
    at kotlinx.serialization.encoding.AbstractEncoder.encodeNullableSerializableElement(AbstractEncoder.kt:90)
    at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeNullableSerializableElement(StreamingJsonEncoder.kt:157)
    at mirai-hibernate-http-1.2.0.mirai2.jar//xyz.cssxsh.mirai.hibernate.http.HibernateAdapterResult.write$Self(HibernateAdapterResult.kt:5)
    at mirai-hibernate-http-1.2.0.mirai2.jar//xyz.cssxsh.mirai.hibernate.http.HibernateAdapterResult$$serializer.serialize(HibernateAdapterResult.kt:5)
    at mirai-hibernate-http-1.2.0.mirai2.jar//xyz.cssxsh.mirai.hibernate.http.HibernateAdapterResult$$serializer.serialize(HibernateAdapterResult.kt:5)
    at kotlinx.serialization.json.internal.StreamingJsonEncoder.encodeSerializableValue(StreamingJsonEncoder.kt:228)
    at kotlinx.serialization.json.internal.JsonStreamsKt.encodeByWriter(JsonStreams.kt:28)
    at kotlinx.serialization.json.Json.encodeToString(Json.kt:81)
    at mirai-hibernate-http-1.2.0.mirai2.jar//xyz.cssxsh.mirai.hibernate.http.HibernateAdapter$initKtorAdapter$1$1$8$1.invokeSuspend(HibernateAdapter.kt:489)
    at mirai-hibernate-http-1.2.0.mirai2.jar//xyz.cssxsh.mirai.hibernate.http.HibernateAdapter$initKtorAdapter$1$1$8$1.invoke(HibernateAdapter.kt)
    at mirai-hibernate-http-1.2.0.mirai2.jar//xyz.cssxsh.mirai.hibernate.http.HibernateAdapter$initKtorAdapter$1$1$8$1.invoke(HibernateAdapter.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.response.ApplicationResponseFunctionsKt.respondText(ApplicationResponseFunctions.kt:131)
    at mirai-hibernate-http-1.2.0.mirai2.jar//xyz.cssxsh.mirai.hibernate.http.HibernateAdapter$initKtorAdapter$1$1$8.invokeSuspend(HibernateAdapter.kt:149)
    at mirai-hibernate-http-1.2.0.mirai2.jar//xyz.cssxsh.mirai.hibernate.http.HibernateAdapter$initKtorAdapter$1$1$8.invoke(HibernateAdapter.kt)
    at mirai-hibernate-http-1.2.0.mirai2.jar//xyz.cssxsh.mirai.hibernate.http.HibernateAdapter$initKtorAdapter$1$1$8.invoke(HibernateAdapter.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.routing.Route$buildPipeline$1$1.invokeSuspend(Route.kt:116)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.routing.Route$buildPipeline$1$1.invoke(Route.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.routing.Route$buildPipeline$1$1.invoke(Route.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:101)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.routing.Routing$executeResult$$inlined$execute$1.invokeSuspend(Pipeline.kt:478)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.routing.Routing$executeResult$$inlined$execute$1.invoke(Pipeline.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.routing.Routing$executeResult$$inlined$execute$1.invoke(Pipeline.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.debug.ContextUtilsKt.initContextInDebugMode(ContextUtils.kt:17)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.routing.Routing.executeResult(Routing.kt:174)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.routing.Routing.interceptor(Routing.kt:49)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.routing.Routing$Plugin$install$1.invokeSuspend(Routing.kt:124)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.routing.Routing$Plugin$install$1.invoke(Routing.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.routing.Routing$Plugin$install$1.invoke(Routing.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.engine.BaseApplicationEngineKt$installDefaultTransformationChecker$1.invokeSuspend(BaseApplicationEngine.kt:122)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.engine.BaseApplicationEngineKt$installDefaultTransformationChecker$1.invoke(BaseApplicationEngine.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.engine.BaseApplicationEngineKt$installDefaultTransformationChecker$1.invoke(BaseApplicationEngine.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:101)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1$invokeSuspend$$inlined$execute$1.invokeSuspend(Pipeline.kt:478)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.debug.ContextUtilsKt.initContextInDebugMode(ContextUtils.kt:17)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1.invokeSuspend(DefaultEnginePipeline.kt:118)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1.invoke(DefaultEnginePipeline.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.engine.DefaultEnginePipelineKt$defaultEnginePipeline$1.invoke(DefaultEnginePipeline.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.loop(SuspendFunctionGun.kt:123)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.proceed(SuspendFunctionGun.kt:81)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.pipeline.SuspendFunctionGun.execute$ktor_utils(SuspendFunctionGun.kt:101)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:77)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.cio.CIOApplicationEngine$handleRequest$2$invokeSuspend$$inlined$execute$1.invokeSuspend(Pipeline.kt:478)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.cio.CIOApplicationEngine$handleRequest$2$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.cio.CIOApplicationEngine$handleRequest$2$invokeSuspend$$inlined$execute$1.invoke(Pipeline.kt)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.util.debug.ContextUtilsKt.initContextInDebugMode(ContextUtils.kt:17)
    at mirai-api-http-2.9.1.mirai2.jar[shared]//io.ktor.server.cio.CIOApplicationEngine$handleRequest$2.invokeSuspend(CIOApplicationEngine.kt:189)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
    at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
    at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
Caused by: java.lang.ClassNotFoundException: net.mamoe.mirai.message.data.MessageSourceKind$$serializer
    ... 73 more
cssxsh commented 1 year ago

https://github.com/cssxsh/mirai-hibernate-plugin/actions/runs/5326441977

Natsukage commented 1 year ago

https://github.com/cssxsh/mirai-hibernate-plugin/actions/runs/5326441977

了解了 但是在使用这个编译的mirai-hibernate-plugin-2.7.1.mirai2.jar时,mirai启动过程会卡在

2023-06-21 04:00:18 I/com.zaxxer.hikari.HikariDataSource: HikariPool-1 - Start completed.

这行日志出现后不动(log等级已经开到了VERBOSE,确认这是最后一行日志)

回退回到release版本的2.7.1后没有此问题。 Start completed后会正常继续运行并登录

2023-06-21 04:02:07 I/com.zaxxer.hikari.HikariDataSource: HikariPool-1 - Start completed.
2023-06-21 04:02:07 I/mirai-hibernate-plugin: Database jdbc:h2:file:./data/xyz.cssxsh.mirai.plugin.mirai-hibernate-plugin/hibernate.h2 by H2 JDBC Driver.
2023-06-21 04:02:07 I/mirai-hibernate-plugin: 如果要使用 mirai-hibernate-plugin 为 mirai-api-http 提供消息持久化, 请安装 https://github.com/cssxsh/mirai-hibernate-http 
2023-06-21 04:02:07 V/JvmPluginLoader: Enabled  plugin mirai-hibernate-plugin v2.7.1
2023-06-21 04:02:07 V/JvmPluginLoader: Enabling plugin mirai-hibernate-http v1.1.1
2023-06-21 04:02:07 V/JvmPluginLoader: Enabled  plugin mirai-hibernate-http v1.1.1
cssxsh commented 1 year ago

请提供完整的插件列表

Natsukage commented 1 year ago

请提供完整的插件列表

fix-protocol-version-1.7.1.mirai2 mcl-addon-2.1.1 mirai-api-http-2.9.1.mirai2 mirai-device-generator-1.2.0.mirai2 mirai-hibernate-http-1.1.1.mirai2 mirai-hibernate-plugin-2.7.1.mirai2 mirai-native-2.0.1.mirai2

其中fix-protocol-version-1.7.1.mirai2来自此次编译 5276674247 mirai-native和mirai-hibernate-plugin外均为正式release版。但是删除mirai-native问题依旧。

cssxsh commented 1 year ago

这个版本里对数据表做了变更,启动插件时会尝试应用变更, 数据量大的时候会非常慢 你可以编辑 config/xyz.cssxsh.mirai.plugin.mirai-hibernate-plugin/hibernate.properties 更改 hibernate.hbm2ddl.auto=updatehibernate.hbm2ddl.auto=none 阻止变更生效

Natsukage commented 1 year ago

好的,修改后可以正常工作了,非常感谢!