{
  "markdown": "DS/OP/07 \u00b7 Data services Page 1 of 3\nTarnbeck Institute of Hydrology \u00b7 Data Services\nReloading a station export after a gauge reset\nOperations note DS/OP/07 \u00b7 Data services \u00b7 Reviewed 14 January 2026\nSymptoms\nThe station's daily total is short and the loader's own log says nothing is wrong. In the log the day\nlooks like a clean run: the export was fetched, every block was read, and the summary line reports\nfewer readings than the station's counter did. The gap is always at the end of the day rather than\nthe beginning, and it is always a whole number of blocks.\nThe other sign is a duplicate warning in the block log, with two entries carrying the same sequence\nnumber and different checksums. One warning is normal after a reset. A run of them means the\nreset happened part way through the day and everything after it is being rejected block by block.\nWhy the loader rejects the second block\nBlock sequence numbers come from the station and not from the loader. The loader keeps the\nhighest number it has committed for the day and treats anything at or below it as a repeat, which is\nthe right thing to do on a poor link: a station that retransmits sends the same block twice, and the\nloader must not count it twice.\nA reset returns the counter to zero, so the blocks after it carry sequence numbers the loader has\nalready committed. Nothing about them looks new and the loader discards them for exactly the\nreason it should. The reset time is the only thing that distinguishes a continuation from a repeat,\nand the loader does not know it unless it is told.\nThe fix\nWhen a gauge is reset in the field the station's counter returns to zero, and the export for that day\ncontains two blocks carrying the same sequence number. The loader accepts the first and rejects the\nsecond. That is the right behaviour for a duplicated transmission and the wrong behaviour here, and\nthe day's record ends up short by however much arrived after the reset.\nThe fix is to requeue the affected blocks with the reset time supplied, so that the loader treats the\nsecond block as a continuation rather than a repeat. The function below is the one to call. It lives in\ntarnbeck.stations.maintenance and is safe to run more than once: a block that already carries a\ngood checksum is skipped.\n\n-- 1 of 3 --\n\nTarnbeck Institute of Hydrology \u00b7 Data Services DS/OP/07\nDS/OP/07 \u00b7 Data services Page 2 of 3\nfrom tarnbeck.stations import Export, reload_window\ndef reload_after_reset(station, reset_at):\nexport = Export.open(station)\nwindow = reload_window(reset_at, margin_minutes=45)\nfor block in export.blocks(window):\nif block.checksum_ok():\ncontinue\nexport.requeue(block, reason=\"gauge reset\")\nreturn export.commit(dry_run=False)\nRun it from the loader host and not from a workstation, and take the reset time from the field log\nrather than from the station clock, which is the thing that was wrong. The margin defaults to\nforty-five minutes either side of the reset; widen it only if the field log is vague about the time,\nbecause a wide window requeues blocks that were never in doubt.\nIf commit returns a count lower than the number of blocks in the window, stop there and raise it\nwith data services before running anything again. A short count means blocks were rejected for a\nsecond reason, and requeuing them repeatedly will not find out what it was.\nRunning it\nRun it from the loader host, in the maintenance environment, with the station code and the reset\ntime as they appear in the field log:\n$ ssh loader-01.tarnbeck.example\n$ tarnbeck-maint reload-after-reset --station VQ1 \\\n--reset-at '2026-01-29T09:15' --confirm\nThe command prints the window it will use, the number of blocks in it and the number it intends to\nrequeue, and then waits. Read the three numbers before answering. If the window is wider than the\nfield log justifies, stop and narrow it rather than letting it run.\nWithout --confirm the command does everything except commit, which is the safe way to see\nwhat it would do. The dry run takes a few seconds and there is no reason to skip it.\nAfterwards\nCheck the day's totals against the gauge's own counter before closing the ticket. The loader reports\nthe number of blocks committed and not the number of readings, and a day can come back with\nthe right number of blocks and the wrong number of readings if a block was truncated in the field.\nNote the reset in the station log, with the time taken from the field log and not the time the reload\nran. The next person to look at a gap in the series will look there first, and a reload with nothing\nwritten beside it is indistinguishable from a gap nobody has dealt with.\n\n-- 2 of 3 --\n\nTarnbeck Institute of Hydrology \u00b7 Data Services DS/OP/07\nDS/OP/07 \u00b7 Data services Page 3 of 3\nIf the count is short\nA short count means blocks were rejected for a second reason and the reload has not found out\nwhat it was. Do not run it again: a second pass requeues the same blocks, reports the same count,\nand fills the log with attempts that bury the original failure.\nTake the sequence numbers the command reports as rejected and look them up in the block log. A\nchecksum failure on a block truncated in the field cannot be fixed by reloading and needs the\nstation visited. A rejection with no reason recorded is a loader fault, and goes to data services with\nthe run's log attached.\nThe block header, for reference\nEach block in an export begins with a fixed header, which is what the loader reads to decide\nwhether it has seen the block before:\nSEQ=00184 STATION=VQ1 START=2026-01-29T08:45Z\nCOUNT=0180 INTERVAL=15s CRC=8f2a41d6\nSEQ is the station's counter and is the field a reset returns to zero. START is the station clock, which\nis not to be trusted after a reset - which is why the reset time comes from the field log and not from\nthe export.\nCRC covers the readings and not the header, so a block with a good checksum and a wrong\nsequence number is possible and is exactly what a reset produces. Nothing in the header says a\nreset happened.\nRolling back\nA committed reload can be undone within the same day by reverting the station's day to the\nsnapshot the loader takes before it commits. The snapshot is kept for seven days and is named for\nthe run.\nAfter seven days the only route back is a fresh fetch of the export from the station, which is possible\nwhile the station's own buffer still holds the day - about three weeks - and impossible afterwards. A\nreload that has committed and cannot be rolled back is an incident and is raised as one, whatever\nthe size of the gap.\n\n-- 3 of 3 --\n\n",
  "pageCount": 3,
  "model": "nano",
  "credits": 3,
  "requestId": 272373
}