Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[Bug] PD KV keys share one namespace with TTL markers and locks, so the TTL cleanup deletes a client key named like a marker

Abierto
#3,392 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
java
Área
database

Línea de trabajo

Read KvService.java, especially getKey, getTTLStoreKey, getLockKey, and clearTTLData, then inspect TaskScheduleService to understand when cleanup runs. The issue describes a reproducible case and possible approaches; first trace how entries are stored and scanned, then choose a fix that prevents client keys from being mistaken for TTL markers or locks. Done means the probe scenario preserves the client value after cleanup and the existing KV tests pass.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

Bug Type (问题类型)

logic (逻辑设计问题)

Before submit
  • 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:

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
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

Lenguaje dominante
Java
Estrellas
3.2k
Forks
640
Merge medio
1 d 12 h
PR fusionados (30 d)
98

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de apache/hugegraph

Todos los issues de apache/hugegraph

Issues similares

Más issues de Java

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.