Skip to content

fix: Do not convert dataset changed_on to UTC - #33693

Merged
Vitor-Avila merged 2 commits into
masterfrom
fix/remove-timezone-dataset-changed-on
Jun 5, 2025
Merged

Vitor-Avila merged 2 commits into
masterfrom
fix/remove-timezone-dataset-changed-on

Conversation

@Vitor-Avila

Copy link
Copy Markdown
Contributor

SUMMARY

In #33626, we decided to store the dataset's changed_on attribute in UTC, to ensure consistency. This introduced an issue to calculate the changed_on_humanized property (now - item.changed_on). In order to fix this calculation for new edits, we would have to update it to now.utc() - item.changed_on which then would break the calculation for items that were modified before this modification.

Ideally, a long-term solution would be to implement timezone support at the DB level, and then migrate existing columns to use the timezone from the server. This however is not aligned with #33626 original's scope, so this PR just reverts that to store the changed_on using now().

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

No UI changes.

TESTING INSTRUCTIONS

N/A.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@korbit-ai korbit-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Design Naive Datetime Usage ▹ view 🧠 Not in scope
Files scanned ​
File Path Reviewed
superset/daos/dataset.py ✅

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

Comment thread superset/daos/dataset.py

if force_update:
attributes["changed_on"] = datetime.now(tz=timezone.utc)
attributes["changed_on"] = datetime.now()

This comment was marked as resolved.

@betodealmeida betodealmeida 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.

Thanks! Sorry for the extra work in the original PR!

@Vitor-Avila

Copy link
Copy Markdown
Contributor Author

Thanks! Sorry for the extra work in the original PR!

No worries! It was def a good idea and something we should implement. It's just going to take a little bit more work :P

@Vitor-Avila
Vitor-Avila merged commit c951848 into master Jun 5, 2025
@Vitor-Avila
Vitor-Avila deleted the fix/remove-timezone-dataset-changed-on branch June 5, 2025 01:24
ianngech pushed a commit to Pesapal-Ltd/superset that referenced this pull request Jun 10, 2025
LevisNgigi pushed a commit to LevisNgigi/superset that referenced this pull request Jun 18, 2025
alexandrusoare pushed a commit to alexandrusoare/superset that referenced this pull request Jun 19, 2025
@github-actions github-actions Bot added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 6.0.0 First shipped in 6.0.0 labels Dec 18, 2025
mikebridge pushed a commit to mikebridge/superset that referenced this pull request May 8, 2026
Two short documentation additions in models/helpers.py:

* SoftDeleteMixin.soft_delete: note that datetime.now() mirrors
  AuditMixinNullable.changed_on by design (PR apache#33693 reverted UTC
  on the audit columns).

* _add_soft_delete_filter listener: distinguish the per-query
  execution_options bypass (narrow, for non-user-facing paths) from
  the per-request flask.g flag (broad, reserved for user-facing list
  filters that ask to surface soft-deleted rows). Reduces the risk of
  a future code path setting g.skip_visibility_filter and bleeding the
  bypass into incidental queries.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
mikebridge pushed a commit to mikebridge/superset that referenced this pull request Jul 28, 2026
- Revert the retention cutoff to the same naive-local clock
  soft_delete() stamps deleted_at with (PR apache#33693 convention); the
  naive-UTC cutoff shifted the window by the server's timezone offset,
  purging early west of UTC. Document the audit table's deliberate
  divergence instead.
- Explicitly delete embedded_dashboards for a purged dashboard — the
  delete-orphan child carrying the public embed UUID leaked on FK-off
  SQLite, contradicting the cascade's explicit-delete doctrine.
- Commit outside the association-version suppression block so the trim
  runs before Continuum executes pending statements, and pin the
  no-shadow guarantee with an integration test.
- Chunk the orphan-transaction sweep's IN() lists under the SQLite
  bind-variable limit; a long-history entity previously crashed the
  sweep and became permanently unpurgeable. Drop the misattributed
  _BATCH alias/comment.
- Move PurgeAuditLog to superset/models/ so it registers with
  Model.metadata at app init (alembic autogenerate would otherwise
  propose dropping the table), and declare the composite
  status/created_on index on the model.
- Fail closed on write-ahead audit failure in the scheduled purge (skip
  and retry next run); force-purge still proceeds with the operator
  present. Documented in UPDATING.md with the dry-run upper-bound note.
- Make finalize() a conditional UPDATE on status='pending' and lock the
  reconcile scan, closing the delayed-worker/reconcile races.
- Validate --uuid with click.UUID before the irreversible prompt.
- Index dashboard_slices_version(slice_id): chart purges previously
  full-scanned the association shadow history.

Co-Authored-By: Claude Fable 5 <[email protected]>
mikebridge pushed a commit to mikebridge/superset that referenced this pull request Jul 31, 2026
…r's clock

The capstone review's HIGH, found independently by five lenses. deleted_at is
stamped with the server's naive-local datetime.now() -- deliberately, matching
every audit column per the PR apache#33693 revert, and the purge task's cutoff
matches the same clock. The archive UI then undid that consistency on the
other side of the API: it parsed the offset-less serialization as UTC
(extendedDayjs.utc(...).fromNow()) and compared client-UTC toISOString()
cutoffs against the naive-local column, so on any non-UTC deployment both the
"Archived" ages and the Last-7/30/90-day presets shifted by the server's
offset. UTC-based CI can never catch it.

The column and the stamp are correct and unchanged. The fix moves both
interpretations to the clock that did the stamping:

- Display: rows now carry deleted_at_delta_humanized, produced server-side
  like changed_on_delta_humanized on the sibling list pages. The humanizer is
  hoisted from AuditMixinNullable to a module function so the archive's bare
  column projection can reuse it; the mixin delegates. The raw ISO value
  stays for API consumers.

- Filtering: the presets send a day count (7/30/90) through a new per-model
  <type>_deleted_recency filter that resolves the cutoff with the server's
  datetime.now(). Beyond the timezone, this also retires two smaller defects
  three lenses noted in the old shape: the cutoff was frozen when the page
  mounted (a long-lived tab drifted a day per day), and it was persisted into
  ?filters= as an absolute timestamp no regenerated option could ever match.
  Day counts are stable and shareable. A malformed value degrades to the
  unfiltered list, like other FAB filter inputs.

The new backend tests build their own database + dataset rather than assuming
the example fixtures, so they run on a bare schema -- the review flagged the
example-data dependence in these suites, and the shared local DB losing
dataset id=1 mid-session (28 unrelated failures, all environmental) made the
case concretely.

Controls: neutralizing the recency predicate fails the window test;
removing the humanized injection fails the display test; reverting the
frontend presets to absolute cutoffs fails the contract test.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/S 🚢 6.0.0 First shipped in 6.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants