Skip to content

Commit

Permalink
feat: reduce latency for reading AOF and flushing commands to destina…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
suxb201 committed Dec 13, 2024
1 parent 2cba3c5 commit 3e1c3b5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/reader/sync_standalone_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ func (r *syncStandaloneReader) sendAOF(offset int64) {
iArgv, err := protoReader.ReadReply()
if err != nil {
if err == io.EOF {
time.Sleep(100 * time.Millisecond)
time.Sleep(10 * time.Millisecond)
continue
} else {
log.Panicf("[%s] read aof file failed. error=[%v]", r.stat.Name, err)
Expand Down
2 changes: 1 addition & 1 deletion internal/writer/redis_standalone_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (w *redisStandaloneWriter) Close() {
func (w *redisStandaloneWriter) StartWrite(ctx context.Context) chan *entry.Entry {
w.chWg = sync.WaitGroup{}
w.chWg.Add(1)
timer := time.NewTicker(100 * time.Millisecond)
timer := time.NewTicker(10 * time.Millisecond)
go func() {
for {
select {
Expand Down
7 changes: 6 additions & 1 deletion tests/cases/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ def split_mset_to_set():
shake = h.Shake(opts)
src.do("mset", "k1", "v1", "k2", "v2", "k3", "v3")
# wait sync done
p.ASSERT_TRUE_TIMEOUT(lambda: shake.is_consistent(), timeout=10, interval=0.01)
try:
p.ASSERT_TRUE_TIMEOUT(lambda: shake.is_consistent(), timeout=10, interval=0.01)
except Exception as e:
with open(f"{shake.dir}/data/shake.log") as f:
p.log(f.read())
raise e
dst.do("select", 1)
p.ASSERT_EQ(dst.do("get", "k1"), b"v1")
p.ASSERT_EQ(dst.do("get", "k2"), b"v2")
Expand Down

0 comments on commit 3e1c3b5

Please sign in to comment.