Repository navigation
Is it safe to un-delete the raw heart-rate samples that the dense-intraday fold soft-deleted? #1111
Replies: 1 comment
|
Thanks for asking before running it, and for testing on a copy first. I went through each point in the code and then reproduced the whole sequence on a test database (fold, your swap, rollup rebuild, fold switched back on, purge), and checked the current iPhone app build for the sync questions, so the answers below are observed, not just read. Short answer: yes, it is safe, with four changes to what you posted. 1. Narrow the un-delete to the fold's own tombstones. 2. Bump 3. Rebuild the rollups afterwards. The fold recomputes the DAY bucket from the raw rows before it runs, which is why your DAY counts match. WEEK, MONTH and YEAR are rebuilt afterwards from whatever is live, so today they are means of the hourly rows; in the reproduction a day with a workout hour read 91 bpm at the week level against 137 at the day level. After the swap, run 4. Keep To your other questions:
There is no supported route for this today, only SQL. A setting that keeps raw rows (the switch you already use does that from now on) plus an admin action to restore folded samples for a date range would be worth having. If you'd like to send that as a PR, I'd welcome it; it would also take care of points 1 to 3 for whoever needs this next. |
Uh oh!
There was an error while loading. Please reload this page.
This is a question, not a bug report. I am not asking for a change. I would like to know whether something I am considering on my own instance is safe, before I run it.
The question
Is it safe to un-delete (
deleted_at = NULL) the raw heart-rate, SpO₂ and HRV samples that the dense-intraday fold soft-deleted, and to hide the hourly means that replaced them, directly in the database? If not, what would break?Context
export.xmlon 29 September.PULSErows (also 31,002OXYGEN_SATURATIONand 15,271HEART_RATE_VARIABILITY) and replaced them with hourlystats:<HK>:<day>T<HH>rows (38,600, 20,917 and 14,975). That is the intended behaviour.DENSE_INTRADAY_RETENTION_ENABLED=falseso no further rows are folded. I would also like the per-sample history from before the window back (see why below).measurementsare not partial, so tombstoned rows still occupy their identities, and the import's update path does not cleardeletedAt(import-apple-health-export.ts). Is that reading right?What I tested (on a copy, not on the live database)
pg_dumpof the database and restored it into a separate throwaway Postgres. Row counts match the live database on measurements, deleted rows, rollups, workouts and users.measurements.deleted_atandupdated_aton those rows (sync_versionis still 1 on both the hidden and the visible ones).DAYtier) have counts matching the hidden raw rows, so they appear to have been built from the raw rows and not from the hourly ones. Recomputing daily means from the restored rows agrees with the rollups closely (a fraction of a bpm on average).It took about four to five minutes on a small container.
What I would like to know
deleted_atandupdated_at, do any other tables, caches or derived data (rollups, stored series, insights) assume the raw rows are gone?/api/sync/changespages on an(updatedAt, id)watermark per domain (route.ts). Bumpingupdated_aton about 841,000 rows would present them as changed again. Does the iPhone app mirrorPULSE,OXYGEN_SATURATIONandHEART_RATE_VARIABILITYhistory, so that it would page through all of them? Would you rather I leaveupdated_atuntouched, and what happens to a client that already received the fold's tombstones?measurement-tombstone-cleanupjob hard-deletes soft-deleted rows older thanTOMBSTONE_RETENTION_DAYS(native-client.ts, 75 days, as you mentioned on fix(labs): refuse a reading whose unit differs from its marker's #1096). I read that as covering the fold's tombstones too, so mine would be gone for good around 13 to 17 December. Is that right, and is there a supported way to keep them?hr-series.ts), and the intraday pulse view has a "coarser fallback" for old days. Would restored raw rows be used by anything, or would I mainly gain raw fidelity for exports? I would like to know whether it is worth doing.State of my instance right now
Nothing from the statement above has been run on the live database. I hold a verified backup (checksummed) and have
DENSE_INTRADAY_RETENTION_ENABLED=falseset. I will not run anything until I hear back.Related: #1107 (how the pulse chart averages), #1096.
All reactions