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

Conversation

dpsutton
Copy link
Contributor

@dpsutton dpsutton commented Feb 27, 2024

We prune persisted info records if they meet any of the following criteria:

(or (contains? (persisted-info/prunable-states) current-state)
    (:archived card-info)
    (not (:dataset card-info)))

But we only deleted the record when:

(when (= "deletable" current-state)
  (t2/delete! PersistedInfo :id (:id persisted-info)))

So any records that were in a "creating" state (persist a model, but before it first gets persisted, make it not a model, or archive the underlying model), we constantly pruned them but never removed the persisted info record.

Leading to task results like:

{"success": 21, "error": 0, "skipped": 0}

Because 21 things were queued up for pruning, were attempted to be pruned, but the persisted info record never removed. And so we "remove" 21 persisted_info records every hour. But we actually aren't doing anything.

If the test looks a little weird it is to get output like:

persist-refresh-test=> (clojure.test/run-test refresh-tables!'-test)

Testing metabase.task.persist-refresh-test

FAIL in (refresh-tables!'-test) (persist_refresh_test.clj:194)

 We delete persisted_info records for all of the pruned
expected: []
  actual: (parchived punmodeled)
    diff: + [parchived punmodeled]

Ran 1 tests containing 12 assertions.
1 failures, 0 errors.
{:test 1, :pass 11, :fail 1, :error 0, :type :summary}

We prune persisted info records if they meet any of the following
criteria:

```clojure
(or (contains? (persisted-info/prunable-states) current-state)
    (:archived card-info)
    (not (:dataset card-info)))
```

But we only deleted the record when:

```clojure
(when (= "deletable" current-state)
  (t2/delete! PersistedInfo :id (:id persisted-info)))
```

So any records that were in a "creating" state (persist a model, but
before it first gets persisted, make it not a model, or archive the
underlying model), we constantly pruned them but never removed the
persisted info record.

Leading to task results like:

```javascript
{"success": 21, "error": 0, "skipped": 0}
```

Because 21 things were queued up for pruning, were attempted to be
pruned, but the persisted info record never removed.
@dpsutton dpsutton requested a review from snoe February 27, 2024 18:29
@dpsutton dpsutton added the backport Automatically create PR on current release branch on merge label Feb 27, 2024
Copy link

replay-io bot commented Feb 27, 2024

Status Complete ↗︎
Commit b580021
Results
⚠️ 3 Flaky
2321 Passed

@dpsutton dpsutton merged commit f2d279c into master Feb 28, 2024
121 of 128 checks passed
@dpsutton dpsutton deleted the fix-pruning-persisted-info branch February 28, 2024 02:07
Copy link

@dpsutton Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone?

@dpsutton dpsutton added this to the 0.49 milestone Feb 28, 2024
github-actions bot pushed a commit that referenced this pull request Feb 28, 2024
We prune persisted info records if they meet any of the following
criteria:

```clojure
(or (contains? (persisted-info/prunable-states) current-state)
    (:archived card-info)
    (not (:dataset card-info)))
```

But we only deleted the record when:

```clojure
(when (= "deletable" current-state)
  (t2/delete! PersistedInfo :id (:id persisted-info)))
```

So any records that were in a "creating" state (persist a model, but
before it first gets persisted, make it not a model, or archive the
underlying model), we constantly pruned them but never removed the
persisted info record.

Leading to task results like:

```javascript
{"success": 21, "error": 0, "skipped": 0}
```

Because 21 things were queued up for pruning, were attempted to be
pruned, but the persisted info record never removed.
dpsutton added a commit that referenced this pull request Feb 28, 2024
If they are off, they are "eligible" models for persistence that we do
not want to persist. And to remember that use choice to not persist them
we need to keep the record around. This was handled previously, but
#39219 was a bit too blunt. We
had a bunch of records in a "creating" state that we weren't removing,
so i deleted them regardless of state. But we want to make sure that the
"off" ones are not deleted.

On stats, a bunch of ones that were set to off are now slated to be
persisted after the prune job deleted the persisted_info records.
dpsutton added a commit that referenced this pull request Feb 29, 2024
We prune persisted info records if they meet any of the following
criteria:

```clojure
(or (contains? (persisted-info/prunable-states) current-state)
    (:archived card-info)
    (not (:dataset card-info)))
```

But we only deleted the record when:

```clojure
(when (= "deletable" current-state)
  (t2/delete! PersistedInfo :id (:id persisted-info)))
```

So any records that were in a "creating" state (persist a model, but
before it first gets persisted, make it not a model, or archive the
underlying model), we constantly pruned them but never removed the
persisted info record.

Leading to task results like:

```javascript
{"success": 21, "error": 0, "skipped": 0}
```

Because 21 things were queued up for pruning, were attempted to be
pruned, but the persisted info record never removed.

Co-authored-by: dpsutton <dan@dpsutton.com>
dpsutton added a commit that referenced this pull request Feb 29, 2024
* Don't delete "off" persisted_info records

If they are off, they are "eligible" models for persistence that we do
not want to persist. And to remember that use choice to not persist them
we need to keep the record around. This was handled previously, but
#39219 was a bit too blunt. We
had a bunch of records in a "creating" state that we weren't removing,
so i deleted them regardless of state. But we want to make sure that the
"off" ones are not deleted.

On stats, a bunch of ones that were set to off are now slated to be
persisted after the prune job deleted the persisted_info records.

* unused local. whoops
dpsutton added a commit that referenced this pull request Feb 29, 2024
* Don't delete "off" persisted_info records

If they are off, they are "eligible" models for persistence that we do
not want to persist. And to remember that use choice to not persist them
we need to keep the record around. This was handled previously, but
#39219 was a bit too blunt. We
had a bunch of records in a "creating" state that we weren't removing,
so i deleted them regardless of state. But we want to make sure that the
"off" ones are not deleted.

On stats, a bunch of ones that were set to off are now slated to be
persisted after the prune job deleted the persisted_info records.

* unused local. whoops
perivamsi pushed a commit that referenced this pull request Feb 29, 2024
* Don't delete "off" persisted_info records

If they are off, they are "eligible" models for persistence that we do
not want to persist. And to remember that use choice to not persist them
we need to keep the record around. This was handled previously, but
#39219 was a bit too blunt. We
had a bunch of records in a "creating" state that we weren't removing,
so i deleted them regardless of state. But we want to make sure that the
"off" ones are not deleted.

On stats, a bunch of ones that were set to off are now slated to be
persisted after the prune job deleted the persisted_info records.

* unused local. whoops

Co-authored-by: dpsutton <dan@dpsutton.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Automatically create PR on current release branch on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants