Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[server] Periodic KV snapshot initialization races with Replica deletion

未关闭
#4,599 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@MaheshS08 已经在做这个了。

开始于 2026年10月13日。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
53/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
java
领域
backend, databases

调研方向

Start with Replica.delete() and Replica.dropKv(), then trace how closeableRegistryForKv closes PeriodicSnapshotManager and how snapshot initialization runs under kvLock. Use the deterministic regression described in the issue with the existing ReplicaTest fixtures to reproduce the registry-closing window. Done means deletion stops or synchronizes periodic snapshot initialization before the KV registry closes, with the regression confirming no closed-registry IOException is logged.

由索引模型根据 Issue 内容生成。

描述

Search before asking
  • I searched in the issues and found nothing similar.
Fluss version

main (development)

Please describe the bug 🐞

Periodic KV snapshot initialization can race with Replica deletion and attempt to register resources after the Replica's KV registry has been closed.

java.io.IOException: Cannot register Closeable, registry is already closed. Closing argument.
    at AbstractAutoCloseableRegistry.registerCloseable
    at AsyncSnapshotCallable$AsyncSnapshotTask.<init>
    at AsyncSnapshotCallable.toAsyncSnapshotFutureTask
    at SnapshotRunner.snapshot
    at KvTabletSnapshotTarget.initSnapshot
    at PeriodicSnapshotManager.lambda$triggerSnapshot$2

Replica.dropKv() closes closeableRegistryForKv. The registry first sets closed=true, then closes its registered resources, including PeriodicSnapshotManager. A scheduled snapshot can still run between these steps and reach task registration while the registry is already closed.

The manager's close() also does not serialize with snapshot initialization under the tablet's kvLock, so cancelling the scheduled future alone does not cover an initialization already in progress.

Deterministic reproduction

A local regression uses the existing ReplicaTest fixtures and real Replica, RocksDB, snapshot target, runner and registry:

  1. Create a KV leader, write and flush records, and retain the snapshot timer automatically scheduled during leader initialization.
  2. Register a latch-controlled Closeable after the snapshot manager. Call Replica.delete() on another thread and pause resource closing after the registry becomes closed, before the manager stops.
  3. Execute the original scheduled timer, then release the latch and wait for deletion to finish.

This enlarges a valid closing window without mocking the initialization exception. The assertion that no closed-registry IOException is logged fails on both revisions:

Regression Base b530fcc2 PR #4492 19870c605
Retry after snapshot-init failure Fails: no replacement task Passes
Snapshot initialization during Replica deletion Fails: closed-registry IOException Fails: same IOException

Four occurrences were observed during test table deletion. Deletion completed, and no snapshot corruption was established.

Expected behavior

Replica deletion should stop or cancel periodic snapshots cleanly, without allowing snapshot task registration after the KV registry closes.

Solution

Serialize stopping the snapshot manager with snapshot initialization before closing the KV registry and dropping the tablet, while preserving cancellation and cleanup of already registered tasks.

Related: #4489 and #4492 address retry after initialization failure. The closing race exists before that PR and requires a separate lifecycle fix.

Are you willing to submit a PR?
  • I'm willing to submit a PR!
主要语言
Java
星标
2.2k
派生
658
平均合并
2 天 23 小时
30 天内合并 PR
101

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/fluss 的其他 Issue

查看 apache/fluss 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。