| 2469 | } |
| 2470 | |
| 2471 | func (f *VFSFile) monitorReplicaClient(ctx context.Context) { |
| 2472 | ticker := time.NewTicker(f.PollInterval) |
| 2473 | defer ticker.Stop() |
| 2474 | |
| 2475 | for { |
| 2476 | select { |
| 2477 | case <-ctx.Done(): |
| 2478 | return |
| 2479 | case <-ticker.C: |
| 2480 | if f.hasTargetTime() { |
| 2481 | continue |
| 2482 | } |
| 2483 | if err := f.pollReplicaClient(ctx); err != nil { |
| 2484 | // Don't log context cancellation errors during shutdown |
| 2485 | if !errors.Is(err, context.Canceled) && !errors.Is(err, context.DeadlineExceeded) { |
| 2486 | f.logger.Error("cannot fetch new ltx files", "error", err) |
| 2487 | } |
| 2488 | } else { |
| 2489 | // Track successful poll time |
| 2490 | f.mu.Lock() |
| 2491 | f.lastPollSuccess = time.Now() |
| 2492 | f.mu.Unlock() |
| 2493 | } |
| 2494 | } |
| 2495 | } |
| 2496 | } |
| 2497 | |
| 2498 | // pollReplicaClient fetches new LTX files from the replica client and updates |
| 2499 | // the page index & the current position. |