Skip to content

fix(grpc): Put/Delete 走 kv.Write 修复 standalone 下 nil raft panic#149

Merged
NeverENG merged 1 commit into
mainfrom
fix/grpc-standalone-write
Jul 10, 2026
Merged

fix(grpc): Put/Delete 走 kv.Write 修复 standalone 下 nil raft panic#149
NeverENG merged 1 commit into
mainfrom
fix/grpc-standalone-write

Conversation

@NeverENG

@NeverENG NeverENG commented Jul 10, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when storing and deleting data through gRPC.
    • Fixed standalone-mode operations that could previously trigger a runtime error.
  • Tests
    • Added coverage confirming that standalone Put and Get operations successfully persist and retrieve values.

@NeverENG
NeverENG merged commit e584b47 into main Jul 10, 2026
3 checks passed
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 73985cb4-6fe3-4a19-8a18-2b2290f78e35

📥 Commits

Reviewing files that changed from the base of the PR and between bc16d98 and 62b6218.

📒 Files selected for processing (2)
  • test_grpc/grpc_server.go
  • test_grpc/grpc_server_test.go

📝 Walkthrough

Walkthrough

The gRPC Put and Delete handlers now persist commands with kv.Write. A standalone-mode test configures an isolated WAL and verifies that a stored value can be retrieved through Put and Get.

Changes

gRPC write flow

Layer / File(s) Summary
Use Write for RPC commands
test_grpc/grpc_server.go
Put and Delete now determine success directly from s.kv.Write(cmd) instead of appending entries and waiting for commits.
Validate standalone Put/Get
test_grpc/grpc_server_test.go
Adds standalone-mode setup and cleanup, then verifies Put stores v1 under k1 and Get returns it.

Estimated code review effort: 2 (Simple) | ~10 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/grpc-standalone-write

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🐯 BanGD 数据库内核评审

整体风险:🟢 低

变更总结:该 PR 将 gRPC 层 PutDelete 原本手动调用 kv.AppendEntry + kv.WaitForCommit 的两步操作,替换为调用单步 kv.Write(cmd)。动机是修复 standalone 模式下 raft 为 nil 时的 panic——旧代码在非 Raft 模式下直接调用 AppendEntry(内部访问 raft 指针)会空指针崩溃;而 kv.Write 内部做了模式分发(standalone 走本地写入,cluster 走 Raft)。同时新增了 TestGRPCServer_PutGetStandalone 回归测试。

本评审不阻塞合入;架构级建议以 Issue 形式跟踪,普通问题在下方内联列出。

未发现需要从架构层面改进的问题。


本次评审消耗 token:共 10595 tokens(输入 10313,输出 282,缓存命中 0,缓存写入 0)|维度 [concurrency, memory, storage, performance, resource]|对抗式复核 3 票/条,过滤疑似误报 0 条

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant