You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hugegraph.apache.org by "bitflicker64 (via GitHub)" <gi...@apache.org> on 2026/10/22 16:38:20 UTC
[I] [Bug] PD KV keys share one namespace with TTL markers and locks, so the TTL cleanup deletes a client key named like a marker [hugegraph]
bitflicker64 opened a new issue, #3392:
URL: https://github.com/apache/hugegraph/issues/3392
### Bug Type (问题类型)
logic (逻辑设计问题)
### Before submit
- [x] I have confirmed and searched that there are no similar problems in the historical issue and documents
### Environment (环境信息)
- Server Version: PD on `master` at `ebb8f4e17` (1.8.0-SNAPSHOT), and #3382 at `55ae8fee6`
- Backend: PD's own RocksDB metadata store (the KV service), checked without raft as the `pd-core-test` suite runs it
- OS: macOS, JDK 17.0.20.1
- Data Size: one key
### Expected & Actual behavior (期望与实际表现)
A key that a client writes through the KV service should stay until the client deletes it or its TTL expires, whatever its name.
The KV service keeps three kinds of entries under the same store prefix `K@` (`KvService.java`, lines 47 to 49 and `getKey`):
1. client keys: `put("a/b", v)` is stored as `K@a/b`;
2. TTL markers: a key put with a TTL gets `K@T@<expireAt>@<key>` (`getTTLStoreKey`);
3. lock keys: `lock(key, ttl, clientId)` puts `L@<key>@<clientId>` (`getLockKey`), stored as `K@L@<key>@<clientId>`.
Nothing stops a client key from having the shape of a marker or a lock. `TaskScheduleService` runs `KvService.clearTTLData()` every second on the leader; it scans `[K@T@0@, K@T@<now>@)` and handles every entry there as a marker. So a client key whose name starts with `T@` and sorts below `T@<now>@` is taken for a marker:
- On master, `clearTTLData` removes every entry it scans (`meta.remove(kv.getKey())`, line 305), so such a client key is deleted within a second of being written.
- With #3382, which fixes the cleanup's parse (#3378), an entry whose time is not a number, such as `T@123abc@foo`, is skipped. One with a numeric time, such as `T@1700000000000@foo`, is still taken for a marker, and the cleanup removes it once it finds no value of `foo` with that expiry.
Measured on 2026-10-22 with JDK 17.0.20.1, with this test added to `hg-pd-test`'s `core` package and `mvn test -pl hugegraph-pd/hg-pd-test -am -P pd-core-test -Dtest=KvNamespaceProbeTest`, once at master `ebb8f4e17` and once at #3382's `55ae8fee6`:
```java
KvService service = new KvService(getPdConfig());
service.put("T@1700000000000@foo", "ordinary");
Assert.assertEquals("ordinary", service.get("T@1700000000000@foo"));
service.clearTTLData();
Assert.assertEquals("ordinary", service.get("T@1700000000000@foo")); // fails on both
```
```text
KvNamespaceProbeTest.testOrdinaryKeyShapedLikeAMarker:32 expected:<[ordinary]> but was:<[]>
```
The same holds the other way round for locks: a client key named `L@<key>@<n>` is read by `locked(key)` and `owned(key, n)` as a lock held by client `n`. That was not measured here.
Possible directions: keep markers and locks under store prefixes of their own (for example `T@...` and `L@...` next to `K@...`, not inside it), with a migration of the existing entries; or reject client keys that start with the reserved `T@` and `L@` names. Either would also let the cleanup trust that every entry it scans is a marker.
### Vertex/Edge example (问题点 / 边数据举例)
N/A
### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
N/A
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@hugegraph.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org