fix(database): 完善数据库与 Redis 资源生命周期#709
Open
zhibeigg wants to merge 1 commit into
Open
Conversation
确保数据源、连接、客户端和线程资源在启动失败、重连及并发关服场景下可靠释放,并补充相关回归测试。
11 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
原有问题
数据库与 Redis 客户端对“资源由谁创建、由谁关闭”缺少一致约定,异步启动与关闭之间也存在竞态:
database-player无法区分外部传入的数据源和模块内部创建的数据源,可能误关共享数据源,也可能遗漏关闭自建数据源。典型触发场景与后果
本 PR 修改
database-player增加明确的数据源所有权和幂等关闭协议,只关闭模块自身拥有的资源。修改目的
建立可预测的资源所有权和生命周期边界,保证插件启停、重载及连接失败时不会误关共享资源,也不会泄漏连接、线程或订阅任务。
兼容性与行为变化
验证
./gradlew :module:database:database-player:test :module:database:database-alkaid-redis:test :module:database:database-player-redis:build :module:database:database-lettuce-redis:test --no-daemon --stacktracegit diff --checkRefs #703