Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete all pruned persisted info records #39219

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/metabase/task/persist_refresh.clj
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@
(log/info (trs "Unpersisting model with card-id {0}" (:card_id persisted-info)))
(try
(unpersist! refresher database persisted-info)
(when (= "deletable" current-state)
(t2/delete! PersistedInfo :id (:id persisted-info)))
(t2/delete! PersistedInfo :id (:id persisted-info))
(update stats :success inc)
(catch Exception e
(log/info e (trs "Error unpersisting model with card-id {0}" (:card_id persisted-info)))
Expand Down
10 changes: 10 additions & 0 deletions test/metabase/task/persist_refresh_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@
(is (contains? queued-for-deletion (u/the-id deletable-persisted))))))
;; we manually pass in the deleteable ones to not catch others in a running instance
(#'task.persist-refresh/prune-deletables! test-refresher [deletable parchived punmodeled])
(testing "We delete persisted_info records for all of the pruned"
(let [persisted-records (t2/select :model/PersistedInfo :id [:in (map :id [parchived punmodeled deletable])])
existing (map (comp
(update-keys {parchived 'parchived
punmodeled 'punmodeled
deletable 'deletable}
:id)
:id)
persisted-records)]
(is (= [] existing))))
;; don't assert equality if there are any deletable in the app db
(doseq [deletable-persisted [deletable punmodeled parchived]]
(is (contains? @called-on (u/the-id deletable-persisted))))
Expand Down