You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apache NiFi跨GCS桶传输文件时出现丢失问题:是否由竞态条件导致?

Is the File Loss Caused by a Race Condition in NiFi's ListGCSBucket?

Great question—let’s break this down step by step, starting with how NiFi’s ListGCSBucket processor behaves by default, since that’s the core of your concern.

Default Behavior of ListGCSBucket

By default, ListGCSBucket uses a bookmarking mechanism (or timestamp-based state) to track which files it’s already processed. Here’s the play-by-play:

  • When the processor starts a run, it first captures a "cutoff timestamp" (the exact moment the run begins).
  • It scans BucketA for all files where the last modified time falls before this cutoff timestamp and hasn’t been processed in prior runs.
  • After the run completes successfully, it updates its bookmark to this cutoff timestamp—so the next scheduled run will only target files modified after that time.

Your Race Condition Scenario: Will It Cause Permanent Loss?

The short answer: No, not with default configuration. Here’s why:
If a file is uploaded to BucketA while ListGCSBucket is mid-scan, its last modified time will be later than the current run’s cutoff timestamp. That means it won’t be picked up in this scan—but it will absolutely be included in the next scheduled run (since the next run’s cutoff will be after the file was uploaded). The bookmark system ensures no files are permanently missed as long as the processor runs consistently.

So Why Are Files Missing?

If files aren’t showing up in BucketB, the issue is almost certainly not a race condition in the listing step. Here are the most likely culprits to investigate:

  • PutGCSObject failures: The file might have been listed and fetched, but failed to upload to BucketB (e.g., permission errors, network blips, quota limits). Check the processor’s error logs, and verify you’ve configured retry policies or connected a "failure" relationship to handle these cases instead of dropping files.
  • Misconfigured ListGCSBucket:
    • If you disabled bookmarking (not the default), the processor might skip files if it’s set to only list files newer than a fixed time, or if your filter rules (filename patterns, file sizes) exclude the missing files.
    • Double-check the processor’s "Filter Attributes" and "Filename Filter" settings to rule out accidental exclusions.
  • GCS metadata delays: Occasionally, GCS takes a few seconds to index new files after upload. If a file is uploaded right after ListGCSBucket starts a run, it might not show up in that scan—but it will be picked up in the next 30-second run.
  • File deletion in BucketA: If the original file is deleted from BucketA before FetchGCSObject can retrieve it, the processor won’t be able to process it.
  • Provenance data gaps: Use NiFi’s Provenance Explorer to search for the missing filenames—this will show exactly where in the flow they were lost (e.g., never listed, fetched but not uploaded).

Quick Troubleshooting Steps

  1. Check the ListGCSBucket processor’s State tab to confirm the bookmark is advancing correctly (it should reflect the timestamp of the last successful run).
  2. Review the PutGCSObject processor’s metrics (e.g., "Sent" vs. "Failed" counts) and error logs for clues about upload failures.
  3. Trace missing files via NiFi’s Provenance UI to pinpoint the exact step where they dropped out of the flow.

内容的提问来源于stack exchange,提问作者Shailesh Jain

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.29 20:57:34