GreedyBear icon indicating copy to clipboard operation
GreedyBear copied to clipboard

GreedyBear loses payload records when a download times out

Open ABHIGYA0205 opened this issue 1 week ago • 5 comments

Description

T-Pot can list a new payload successfully, then time out when GreedyBear tries to download the file. When that happens, GreedyBear loses the details it already received, including which sensor saw the payload.

How it was reproduced

A local test on develop (8d1fe9e) used two simulated T-Pot sensors. Both sensors listed the same file. GreedyBear tried to download it from sensor A first, but the download timed out. It then downloaded the file from sensor B and recorded only B as a source. Sensor A also listed a file that no other sensor had. That download timed out too. GreedyBear marked sensor A’s run as successful and moved on to the next time window. The file was still missing after sensor A recovered.

Expected behavior

GreedyBear should save the payload details and the sensor that reported them even if the file download fails.

Proposed fix

If T-Pot lists a payload but the download times out, save the payload details, including which sensor saw it and where the file is stored.Leave the file itself empty. GreedyBear already does this when quarantine storage is full, so it could reuse that logic.If another sensor provides the same file, attach it to the existing record and keep both sensors listed.

Related issue

#1532 covers files skipped when quarantine storage is full. This also happens when there is space available and the download times out.

ABHIGYA0205 avatar Nov 27 '26 18:11 ABHIGYA0205

Hi @ABHIGYA0205, I tried this on the latest develop commit you mentioned with two payload servers and could reproduce it. When sensor A's downloads time out, the file only A had gets no row at all, the shared file ends up with only B's observation, and both runs are marked success, so A's window is never fetched again even after it comes back. I think the cause is the except requests.RequestException in _download_and_store, which just logs and returns False, so the interval counts as done and _extract_from_source still advances the watermark.

I also tried the approach you suggested, calling _store_metadata_only for the payload when the download fails. With that change the A-only file gets a metadata row with A's locator, and B's download upgrades the shared row with both observations kept, so it covers both cases from the report. A couple of small things to handle with it: the rows are saved, but the summary log still reports them as skipped/failed, 0 stored as metadata only and the run's count stays at 0, so those should treat them as stored metadata. The same except also catches 404 and 401 responses (I checked, they end up as metadata-only rows the same way), which I think is fine.

Prasad8830 avatar Nov 27 '26 20:11 Prasad8830

One thing your approach doesn't solve is that the file is still never downloaded. On #1532 the backfill sweep was left for a separate issue because with a full quota it wouldn't do anything, but timeouts are usually transient, so a retry would actually recover these files. Maybe worth a follow-up issue once this is in?

Prasad8830 avatar Nov 27 '26 20:11 Prasad8830

@regulartim, What are your thoughts on this? Also, @ABHIGYA0205, are you planning to working on this or should I take this one?

Prasad8830 avatar Nov 27 '26 20:11 Prasad8830

Thanks @Prasad8830 for reproducing the bug and testing the proposed fix. I would like to work on this issue. I will update the summary log and extraction run count to include records saved as metadata only.I agree that automatic retries for timed out downloads make sense as a follow up once this fix is in. @regulartim, could you assign this issue to me? Does that scope sound right?

ABHIGYA0205 avatar Nov 27 '26 21:11 ABHIGYA0205

Hey @ABHIGYA0205 and @Prasad8830 ! Thanks for raising this issue and for your discussion. Yes, I'll assign you. Retrying failed downloads is a follow up. If you want, @Prasad8830 , you can open an issue and I'll assign you to that.

One thing that you can also care about here @ABHIGYA0205 , if you think it's a good idea: after a ConnectionError or Timeout (not a 4xx), stop downloading from that source and store the rest of the batch as metadata-only. That way a dead sensor can not stall the whole extraction run.

regulartim avatar Nov 30 '26 15:11 regulartim