Skip to content

fix(dataset): find flaginput files by the time in the update ID - #217

Open
rikvl wants to merge 5 commits into
mainfrom
rvl/dataset-fixes
Open

fix(dataset): find flaginput files by the time in the update ID#217
rikvl wants to merge 5 commits into
mainfrom
rvl/dataset-fixes

Conversation

@rikvl

@rikvl rikvl commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #216

Five commits, reviewable in order (the last two commits are worth reading together with the third):

  • Only dataset IDs present at freq_id are resolved, matching the frequency the comparison is actually made at.
  • Read the loaded flaginput data into a flat {update_id: (acquisition, flags)} map instead of one FlagInputData per acquisition scanned linearly per dataset. No behaviour change; it gives the next commit somewhere to put flags read later.
  • Locate updates by their own timestamp. Update IDs are built as <type>_<YYYYmmddTHHMMSS.ffffffZ>_<sources>, so find_flags parses that and asks the tracker for the flaginput file covering that moment when an update isn't already loaded. The 32 h look-back stays as a pre-load for the common case, but no longer decides what can be found. Hits and misses are both cached, so each update is searched for at most once per acquisition.
  • A missing update is no longer fatal: it increments updateid_not_found and skips that dataset.
  • Stale comments and log wording around the code above.

Notes:

  • Drive-by fix: the flag mismatch warning reported flg_acq left over from the search loop, i.e. whichever acquisition was iterated last rather than the one the flags came from.
  • The UPDATE_ID_SEARCH_MARGIN of 1 h is needed because the tracker selects files with start_time < end and end_time > start. An update that is the last one in its file (which is exactly the case after an outage) falls outside its own file's range with a zero-width window.
  • The tracker only indexes staging and files age out of it, so an update re-sent from far enough back can still be unreachable. That is why the miss is counted rather than raised.

rikvl and others added 4 commits August 18, 2026 09:29
validate_flag_updates collected the unique dataset IDs over every frequency,
but the input flags it compares are not frequency dependent and the comparison
only ever selects frames at freq_id. Dataset IDs from other frequencies select
no frames, so their flags were never compared -- but they were still resolved
against chimedb, and a failure to find their flags could abort the task.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The flags were kept as one FlagInputData per acquisition, and every dataset
looked up its update by scanning each acquisition's update_id list in turn.
Read them into a flat {update_id: (acquisition, flags)} mapping instead, which
makes the lookup a dict hit and gives a place to add flags read later.

Also fixes the mismatch warning naming the wrong acquisition: flg_acq was left
over from the search loop, so it reported whichever acquisition was iterated
last rather than the one the flags came from.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The flaginput files to validate against were selected from the timespan of the
chimestack files being processed, minus a fixed 32h to allow for flag updates
that get re-sent. When the flag broker restarts it re-sends the last update it
knows about under that update's original ID, so after an outage longer than the
allowance the chimestack file references an update that is outside the window,
and the task fails with "Flag ID ... not found" even though the flaginput file
holding it is right there on disk.

Update IDs carry the time they were created, so use that instead of guessing:
if an update isn't among the flags already loaded, ask the tracker for the
flaginput file covering that time and read it. The 32h look-back stays as a
pre-load for the common case, but no longer determines what can be found.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Raising DiasDataError left the chimestack file unregistered, so the next run
selected it again, failed again, and never reached the files behind it. One
unverifiable dataset blocked the task indefinitely.

A missing update is not always someone's fault, either: the tracker only indexes
staging, and files age out of it, so an update that was re-sent from long enough
ago can be genuinely unreachable. Count it in the updateid_not_found metric,
warn, and carry on with the next dataset.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@rikvl

rikvl commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Deployed to nugogo for testing.

The first run should work through the backlog that has accumulated since 2026-07-22.

- The flaginput files are selected with the tracker, not with a ch_util Finder.
  This analyzer never used a Finder; the comment above the new_files call was
  left over from an earlier version.
- Drop "Loop over contiguous periods within this acquisition" from a line that
  just takes the acquisition's file list. Its twin in the flaginput loop went
  away when that loop was replaced.
- The keys of the flags mapping are acquisition directories, as returned by
  get_acquisitions, not acquisition names.

Also reword the log line for the flaginput files being read. "Now processing
acquisition <acq> (1 files)" reads as if the acquisition holds one file, when it
is the number selected out of it -- which is exactly the count that mattered
when the analyzer failed to find an update, and exactly the wrong thing to be
ambiguous about.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@rikvl
rikvl force-pushed the rvl/dataset-fixes branch from d9c0894 to de08a08 Compare August 18, 2026 11:21
@rikvl

rikvl commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

This unblocked the dataset analyzer on nugogo.

Aug 18 02:01:04 nugogo dias[76399]: [2026-08-18 09:01:04,673] dias[dataset]: Start-up.
Aug 18 02:02:35 nugogo dias[76399]: [2026-08-18 09:02:35,946] dias[dataset]: Analyzing data between 1784704146.7453952 and 1787042433.6539776.
Aug 18 02:02:35 nugogo dias[76399]: [2026-08-18 09:02:35,955] dias[dataset]: Now processing acquisition 20260722T070906Z_chimestack_corr (4 files)
Aug 18 02:02:35 nugogo dias[76399]: [2026-08-18 09:02:35,955] dias[dataset]: Finding flags between 1784588946.7453952 and 1784723876.7514112.
Aug 18 02:02:39 nugogo dias[76399]: [2026-08-18 09:02:39,689] dias[dataset]: Reading 1 flaginput files from acquisition /mnt/gong/staging/20260701T000000Z_chime_flaginput
Aug 18 02:03:12 nugogo dias[76399]: 127.0.0.1 - - [18/Aug/2026 09:03:12] "GET /metrics HTTP/1.1" 200 2433
Aug 18 02:03:18 nugogo dias[76399]: [2026-08-18 09:03:18,121] dias[dataset]: Now processing acquisition 20260722T123756Z_chimestack_corr (3 files)
Aug 18 02:03:18 nugogo dias[76399]: [2026-08-18 09:03:18,121] dias[dataset]: Finding flags between 1784608676.7514112 and 1784737073.7095168.
Aug 18 02:03:19 nugogo dias[76399]: [2026-08-18 09:03:19,992] dias[dataset]: Reading 1 flaginput files from acquisition /mnt/gong/staging/20260701T000000Z_chime_flaginput
Aug 18 02:03:47 nugogo dias[76399]: [2026-08-18 09:03:47,925] dias[dataset]: Now processing acquisition 20260723T065020Z_chimestack_corr (7 files)

@rikvl
rikvl marked this pull request as ready for review August 18, 2026 11:31
@rikvl
rikvl requested review from ketiltrout and ljgray August 18, 2026 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dataset task fails permanently on flag updates re-sent from before a long outage

1 participant