Skip to content

Commit 3300657

Browse files
Copilotbootjp
andauthored
Fix leader TTL checks to avoid local buffer state
Agent-Logs-Url: https://github.com/bootjp/elastickv/sessions/9f4a161f-317a-4e73-942d-1b31a4247c79 Co-authored-by: bootjp <1306365+bootjp@users.noreply.github.com>
1 parent c21330b commit 3300657

2 files changed

Lines changed: 4 additions & 13 deletions

File tree

adapter/redis.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,12 +1030,6 @@ func (r *RedisServer) get(conn redcon.Conn, cmd redcon.Command) {
10301030

10311031
// isLeaderKeyExpired checks whether the key has an expired TTL on the leader.
10321032
func (r *RedisServer) isLeaderKeyExpired(key []byte) bool {
1033-
if expireAt, found := r.ttlBuffer.Get(key); found {
1034-
if expireAt == nil {
1035-
return false
1036-
}
1037-
return !expireAt.After(time.Now())
1038-
}
10391033
raw, err := r.tryLeaderGetAt(redisTTLKey(key), 0)
10401034
if err != nil {
10411035
return false
@@ -1052,11 +1046,7 @@ func (r *RedisServer) isLeaderKeyExpired(key []byte) bool {
10521046
// key has an expired TTL.
10531047
func (r *RedisServer) tryLeaderNonStringExists(key []byte) bool {
10541048
// Check TTL first: if expired, the key is logically gone.
1055-
if expireAt, found := r.ttlBuffer.Get(key); found {
1056-
if expireAt != nil && !expireAt.After(time.Now()) {
1057-
return false
1058-
}
1059-
} else if raw, err := r.tryLeaderGetAt(redisTTLKey(key), 0); err == nil {
1049+
if raw, err := r.tryLeaderGetAt(redisTTLKey(key), 0); err == nil {
10601050
if ttl, decErr := decodeRedisTTL(raw); decErr == nil && !ttl.After(time.Now()) {
10611051
return false
10621052
}

proxy/dualwrite.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ const (
2121
// (EVAL / EVALSHA). Lua scripts under high load cause write conflicts in the Raft
2222
// layer, and each conflict triggers a full script re-execution. Capping the
2323
// concurrency reduces contention so individual scripts complete within
24-
// SecondaryTimeout. Excess scripts are dropped (acceptable in dual-write mode
25-
// where Redis remains the authoritative store).
24+
// SecondaryTimeout. Excess secondary script writes may be dropped to keep
25+
// contention bounded; this is only tolerable in modes where the script write
26+
// is targeting the non-authoritative backend.
2627
maxScriptWriteGoroutines = 64
2728
)
2829

0 commit comments

Comments
 (0)