Skip to content

feat(search): retry extractions tika could not answer during a walk - #4123

Merged
fschade merged 5 commits into
opencloud-eu:mainfrom
fschade:search-extraction-retry
Nov 25, 2026
Merged

fschade merged 5 commits into
opencloud-eu:mainfrom
fschade:search-extraction-retry

Conversation

@fschade

@fschade fschade commented Nov 25, 2026

Copy link
Copy Markdown
Member

Description

During a space reindex, an extraction that could not reach Tika or the file is retried up to five times, one second apart. Files Tika cannot parse are not retried here.

After five files in a row are still out of reach, the reindex does not abort. It indexes the remaining files by name, resumes retries once an extraction succeeds, and returns an error with the number of files indexed by name only.

Motivation and Context

A Tika restart during a reindex left the files walked in that window without content.

How Has This Been Tested?

  • unit tests

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation added

@fschade fschade self-assigned this Nov 25, 2026
@github-project-automation github-project-automation Bot moved this to Qualification in OpenCloud Team Board Nov 25, 2026
@fschade fschade moved this from Qualification to In Progress in OpenCloud Team Board Nov 25, 2026
@codacy-production

codacy-production Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 100 complexity

Metric Results
Complexity 100

View in Codacy

🟢 Coverage 87.79% diff coverage · +0.10% coverage variation

Metric Results
Coverage variation ✅ +0.10% coverage variation (-1.00%)
Diff coverage ✅ 87.79% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (9ebb6a7) 95214 29578 31.06%
Head commit (b6a3e39) 95309 (+95) 29707 (+129) 31.17% (+0.10%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4123) 131 115 87.79%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@fschade
fschade requested a review from aduffeck November 25, 2026 10:43

@butonic butonic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isUnreachable treats every error that is not ErrUnparsable as transient, but cs3.Retrieve also returns plain errors for a download that fails for good (InitiateFileDownload answering not found, permission denied, a missing blob ...). Since cf5a087 those files are indexed with Count: 0 and never capped, so each of them now costs 5s of retries on every walk, and five of them in a row make the walk report tika as down although it is fine. Could we only count connection errors, timeouts and 5xx from tika as unreachable?

Related, already the case before but now up to 6 attempts per file: tika uses http.DefaultClient, the cs3 retriever has no timeout either and builds the download request without the ctx. A tika that hangs instead of refusing connections blocks the walk. A context.WithTimeout per attempt would at least cover the tika call.

And since this touches the README paragraph anyway: the retry delays are a lower bound, they are only checked when a walk of the space runs. Could it say "tried again on the first reindex of its space after one hour / one day"?

@fschade
fschade requested a review from butonic November 25, 2026 11:35

@butonic butonic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timeout counts as unreachable, so a file whose OCR always takes longer than 5m gets 1 + 5 attempts of 5m each on every walk, and since unreachable failures are never capped that repeats forever. Five of them in a row hold the walk for ~2.5h before it assumes tika is down. And if tika keeps parsing after we hang up, the retries stack more work on an already slow tika. IMO a timeout on a request tika accepted says more about the file than about tika: could it count as a failure of the file (backoff and cap), and only failed connections and 5xx count as unreachable? If tika really hangs, every file gets one counted failure and an hour of backoff, still a lot cheaper.

Minor: a 429 from the download is not a 5xx, so it counts as a failure of the file although it is clearly transient.

@butonic butonic left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both fixed 👍 One edge left, not a blocker IMO: a tika that accepts connections but never answers now costs the full timeout per file and never trips the streak, so a big space takes ages to walk. Down mode has the same problem since it still does a full extraction per file to notice tika is back. Checking tika with a cheap GET /version and a short timeout while it is considered down would fix both, fine as a follow up.

@fschade
fschade enabled auto-merge November 25, 2026 12:35
Comment thread services/search/pkg/search/service.go Resolved
@fschade
fschade requested a review from aduffeck November 25, 2026 13:08
@fschade
fschade merged commit 301a60e into opencloud-eu:main Nov 25, 2026
61 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenCloud Team Board Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants