Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid file not exist #904

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ RedisShake is a powerful tool for Redis data transformation and migration, offer
2. **Redis Compatibility**: Supports Redis 2.8 to 7.4, across standalone, master-slave, sentinel, and cluster deployments.

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

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).
12 changes: 12 additions & 0 deletions internal/utils/file_rotate/aof_reader.go
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"os"
"time"
)

type AOFReader struct {
@@ -21,7 +22,18 @@ func NewAOFReader(name string, dir string, offset int64) *AOFReader {
r := new(AOFReader)
r.name = name
r.dir = dir

filepath := fmt.Sprintf("%s/%d.aof", r.dir, r.offset)

startWaitTimeStart := time.Now()
for !utils.IsExist(filepath) {
time.Sleep(100 * time.Millisecond)
if time.Since(startWaitTimeStart) > 3*time.Second {
log.Panicf("[%s] file not exist. filename=[%s]", r.name, filepath)
}
}
r.openFile(offset)

return r
}