Fixed the behavior of avro write to old files

This commit is contained in:
Aditya Ujeniya
2025-10-28 09:42:28 +01:00
parent 2287586700
commit 3c1a7e0171

View File

@@ -25,7 +25,7 @@ import (
) )
var NumAvroWorkers int = 4 var NumAvroWorkers int = 4
var startUp bool = true
var ErrNoNewData error = errors.New("no data in the pool") var ErrNoNewData error = errors.New("no data in the pool")
func (as *AvroStore) ToCheckpoint(dir string, dumpAll bool) (int, error) { func (as *AvroStore) ToCheckpoint(dir string, dumpAll bool) (int, error) {
@@ -96,6 +96,9 @@ func (as *AvroStore) ToCheckpoint(dir string, dumpAll bool) (int, error) {
if errs > 0 { if errs > 0 {
return int(n), fmt.Errorf("%d errors happend while creating avro checkpoints (%d successes)", errs, n) return int(n), fmt.Errorf("%d errors happend while creating avro checkpoints (%d successes)", errs, n)
} }
startUp = false
return int(n), nil return int(n), nil
} }
@@ -143,6 +146,10 @@ func getTimestamp(dir string) int64 {
interval, _ := time.ParseDuration(Keys.Checkpoints.Interval) interval, _ := time.ParseDuration(Keys.Checkpoints.Interval)
updateTime := time.Unix(maxTS, 0).Add(interval).Add(time.Duration(CheckpointBufferMinutes-1) * time.Minute).Unix() updateTime := time.Unix(maxTS, 0).Add(interval).Add(time.Duration(CheckpointBufferMinutes-1) * time.Minute).Unix()
if startUp {
return 0
}
if updateTime < time.Now().Unix() { if updateTime < time.Now().Unix() {
return 0 return 0
} }