mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-02-19 04:27:52 -05:00
**Backport:** https://codeberg.org/forgejo/forgejo/pulls/10686 ``` NAME: forgejo doctor cleanup-commit-status - Cleanup extra records in commit_status table USAGE: forgejo doctor cleanup-commit-status DESCRIPTION: Forgejo suffered from a bug which caused the creation of more entries in the "commit_status" table than necessary. This operation removes the redundant data caused by the bug. Removing this data is almost always safe. These reundant records can be accessed by users through the API, making it possible, but unlikely, that removing it could have an impact to integrating services (API: /repos/{owner}/{repo}/commits/{ref}/statuses). It is safe to run while Forgejo is online. On very large Forgejo instances, the performance of operation will improve if the buffer-size option is used with large values. Approximately 130 MB of memory is required for every 100,000 records in the buffer. Bug reference: https://codeberg.org/forgejo/forgejo/issues/10671 OPTIONS: --help, -h show help --custom-path string, -C string Set custom path (defaults to '{WorkPath}/custom') --config string, -c string Set custom config file (defaults to '{WorkPath}/custom/conf/app.ini') --work-path string, -w string Set Forgejo's working path (defaults to the directory of the Forgejo binary) --verbose, -V Show process details --dry-run Report statistics from the operation but do not modify the database --buffer-size int Record count per query while iterating records; larger values are typically faster but use more memory (default: 100000) --delete-chunk-size int Number of records to delete per DELETE query (default: 1000) ``` The cleanup effectively performs `SELECT * FROM commit_status ORDER BY repo_id, sha, context, index, id`, and iterates through the records. Whenever `index, id` changes without the other fields changing, then it's a useless record that can be deleted. The major complication is doing that at scale without bringing the entire database table into memory, which is performed through a new iteration method `IterateByKeyset`. Manually tested against a 455,303 record table in PostgreSQL, MySQL, and SQLite, which was reduced to 10,781 records, dropping 97.5% of the records. ## Checklist The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org). ### Tests - I added test coverage for Go changes... - [x] in their respective `*_test.go` for unit tests. - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server. - I added test coverage for JavaScript changes... - [ ] in `web_src/js/*.test.js` if it can be unit tested. - [ ] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)). ### Documentation - [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change. - Documentation should be via release notes and automatic CLI documentation updates. - [ ] I did not document these changes and I do not expect someone else to do it. ### Release notes - [ ] I do not want this change to show in the release notes. - [x] I want the title to show in the release notes with a link to this pull request. - [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title. Co-authored-by: Mathieu Fenniak <mathieu@fenniak.net> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10781 Reviewed-by: Mathieu Fenniak <mfenniak@noreply.codeberg.org> Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Co-authored-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org> Co-committed-by: forgejo-backport-action <forgejo-backport-action@noreply.codeberg.org> |
||
|---|---|---|
| .. | ||
| TestCleanupCommitStatus | ||
| TestIterateRepositoryIDsWithLFSMetaObjects | ||
| branch.go | ||
| branch_list.go | ||
| branch_test.go | ||
| commit_status.go | ||
| commit_status_summary.go | ||
| commit_status_test.go | ||
| lfs.go | ||
| lfs_lock.go | ||
| lfs_lock_list.go | ||
| lfs_test.go | ||
| main_test.go | ||
| protected_branch.go | ||
| protected_branch_list.go | ||
| protected_branch_list_test.go | ||
| protected_branch_test.go | ||
| protected_tag.go | ||
| protected_tag_test.go | ||