Skip to content

Commit 0bb1ab7

Browse files
committed
fix: avoid file not exist
1 parent 9a45203 commit 0bb1ab7

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ RedisShake is a powerful tool for Redis data transformation and migration, offer
2121
2. **Redis Compatibility**: Supports Redis 2.8 to 7.4, across standalone, master-slave, sentinel, and cluster deployments.
2222

2323
3. **Cloud Service Integration**: Seamlessly works with Redis-like databases from major cloud providers:
24-
- Alibaba Cloud: [ApsaraDB for Redis](https://www.alibabacloud.com/product/apsaradb-for-redis), [Tair](https://www.alibabacloud.com/product/tair)
24+
- Alibaba Cloud: [Tair (Redis® OSS-Compatible)](https://www.alibabacloud.com/en/product/tair)
2525
- AWS: [ElastiCache](https://aws.amazon.com/elasticache/), [MemoryDB](https://aws.amazon.com/memorydb/)
2626

2727
4. **Module Support**: Compatible with [TairString](https://github.com/tair-opensource/TairString), [TairZSet](https://github.com/tair-opensource/TairZset), and [TairHash](https://github.com/tair-opensource/TairHash).

internal/utils/file_rotate/aof_reader.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"io"
88
"os"
9+
"time"
910
)
1011

1112
type AOFReader struct {
@@ -21,7 +22,18 @@ func NewAOFReader(name string, dir string, offset int64) *AOFReader {
2122
r := new(AOFReader)
2223
r.name = name
2324
r.dir = dir
25+
26+
filepath := fmt.Sprintf("%s/%d.aof", r.dir, r.offset)
27+
28+
startWaitTimeStart := time.Now()
29+
for !utils.IsExist(filepath) {
30+
time.Sleep(100 * time.Millisecond)
31+
if time.Since(startWaitTimeStart) > 3*time.Second {
32+
log.Panicf("[%s] file not exist. filename=[%s]", r.name, filepath)
33+
}
34+
}
2435
r.openFile(offset)
36+
2537
return r
2638
}
2739

0 commit comments

Comments
 (0)