-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
libindex: fix manifest_index unique constraint
This commit adds a migration to fix the missing unique constraint on the `manifest_index` table. Without this constraint, the `manifest_index` table can bloat to absurd size. In order to deal with tables which have already bloated to absurd size, we simply truncate the `manifest_index` table. We also truncate the `manifest_scanned` table which allows all subsequent manifests submitted to clair to be re-indexed. This re-index will rebuild the `manifest_index` for the manifest being submitted, but perform no other work since all layer data still exists for a previously seen manifest. Signed-off-by: ldelossa <[email protected]>
- Loading branch information
Showing
3 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package migrations | ||
|
||
const ( | ||
// This migration truncates the manifest_index and scanned_manifest tables | ||
// and adds a unique index to manifest_index. This is required since the | ||
// manifest_index table currently bloats with duplicate records. | ||
// | ||
// After this migration is complete manifests will need to be re-indexed | ||
// for notifications on these manifests to work correctly. | ||
// | ||
// Index reports will still be served without a re-index being necessary. | ||
migration3 = ` | ||
LOCK manifest_index; | ||
LOCK scanned_manifest; | ||
TRUNCATE manifest_index; | ||
TRUNCATE scanned_manifest; | ||
CREATE UNIQUE INDEX manifest_index_unique ON manifest_index (package_id, COALESCE(dist_id, 0), COALESCE(repo_id, 0), manifest_id); | ||
` | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters