[Bug] PD reports "Started" and keeps serving after failing to open its RocksDB (lock held by the previous instance): every request fails, /v1/health stays 200, no retry, no exit
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- grpc, java, spring-boot
- Domain
- api, backend, databases, distributed-systems
Research direction
Start with HgKVStoreImpl.java:66-80 and openRocksDB(), then inspect HugePDServer’s /v1/health behavior and the linked repro_pd_lock.sh. Reproduce the held-lock startup case and trace the existing readiness and startup paths. Done means a failed RocksDB open cannot leave PD half-alive, and the health response reflects the resulting state.
Written by the indexing model from the issue text.
Description
Bug Type (问题类型)
others (availability)
Before submit
- 我已经确认现有的 Issues 与 FAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)
Environment (环境信息)
PD master 83ef9f3f (the code path is unchanged since 1.7.0: HgKVStoreImpl.init), single PD, Java 17. Second occurrence: a 3-node PD cluster restarted by systemd during a load; the new JVMs started before the old ones released the RocksDB lock, all three came up half-initialised, stores lost the PD leader, servers timed out, and the cluster stood still until an operator deleted the LOCK files by hand.
Expected & Actual behavior (期望与实际表现)
Expected: a PD that cannot open its KV store either retries the open (the lock is transient during a restart race) or exits non-zero so the supervisor restarts it.
Actual (lab, results/pd-halfalive-lock):
15:19:10 ERROR HgKVStoreImpl - Failed to open RocksDB from ./pd_data/rocksdb/
org.rocksdb.RocksDBException: While lock file: ./pd_data/rocksdb//LOCK: Resource temporarily unavailable
15:19:10 ERROR HgKVStoreImpl - Failed to open data file,{}
15:19:13 INFO HugePDServer - Started HugePDServer in 5.856 seconds
lock released at 15:19:50; three minutes later:
GET /v1/health -> 200
GET /v1/ready -> 503 {"ready":false,"state":"STATE_UNINITIALIZED","isLeader":false}
GET /v1/members -> 401 {"status":-1,"error":"Unauthorized"} (auth cannot read anything either)
gRPC and raft ports listening; stores: Failed to get the PD leader
"Failed to open RocksDB" logged exactly once: no retry, no exit
Analysis
HgKVStoreImpl.init()catches thePDExceptionfromopenRocksDB()and only logs it (HgKVStoreImpl.java:66-80);this.dbstays null. Spring Boot finishes startup, Tomcat, gRPC and the raft node come up, and every KV access later fails, surfacing as "Unauthorized" on REST and "leader not ready" for the stores.- The lock error is the normal outcome of a restart race: RocksDB's
LOCKis an fcntl lock held until the previous JVM exits, and a supervisor that restarts on the shell wrapper (or a manualstartright afterstop) lands in that window. jraft's own log storage inpd_raft/loghas the same lock; when that one is held as well the process eventually exits, so the half-alive state needs the raft side to open while the KV side fails. - With
/v1/healthhard-coded to 200 (see #3222) nothing external restarts such a PD; a 3-node cluster where all three hit the window stays down until an operator intervenes, and deletingLOCKfiles is the wrong fix when the old process is still alive.
How to reproduce (lab, no systemd needed, repro_pd_lock.sh)
- Copy a PD data directory; from another process hold an fcntl lock on
pd_data/rocksdb/LOCK(Pythonfcntl.lockf) for 40 s. - Start PD on that directory while the lock is held.
- Release the lock. PD never recovers:
/v1/ready503STATE_UNINITIALIZED, REST 401, health 200, process alive.
Proposal
HgKVStoreImpl.init()retries the open for a bounded time when the failure is a lock conflict (the previous instance is shutting down), then rethrows; the caller lets Spring startup fail, so the process exits non-zero and the supervisor restarts it cleanly.- Until the store is open,
/v1/healthanswers 503 (the same direction as #3222: health should reflect a terminal error state, ready reflects leadership, #3185). - A note in the operations guide that the
LOCKfiles must never be deleted while a previous JVM is alive.
Related: #3222 (single-node PD stays leaderless after a snapshot error, health still 200), #3185, #3189.
- Dominant language
- Java
- Stars
- 3.2k
- Forks
- 637
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 23
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/hugegraph
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
All issues in apache/hugegraph
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100