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

Move from max( id ) to max( index ) for latest commit statuses (#30076) #30155

Merged
merged 2 commits into from
Mar 28, 2024

Conversation

stevapple
Copy link
Contributor

@stevapple stevapple commented Mar 28, 2024

Backport #30076.

This PR replaces the use of max( id ), and instead using max( `index` ) for determining the latest commit status. Building business logic over an auto_increment primary key like id is risky and there’re already plenty of discussions on the Internet.

There‘s no guarantee for auto_increment values to be monotonic, especially upon failures or with a cluster. In the specific case, we met the problem of commit statuses being outdated when using TiDB as the database. As being
documented
, auto_increment values assigned to an insert statement will only be monotonic on a per server (node) basis.

Closes #30074.

…o-gitea#30076)

This PR replaces the use of `max( id )`, and instead using ``max(
`index` )`` for determining the latest commit status. Building business
logic over an `auto_increment` primary key like `id` is risky and
there’re already plenty of discussions on the Internet.

There‘s no guarantee for `auto_increment` values to be monotonic,
especially upon failures or with a cluster. In the specific case, we met
the problem of commit statuses being outdated when using TiDB as the
database. As [being
documented](https://docs.pingcap.com/tidb/stable/auto-increment),
`auto_increment` values assigned to an `insert` statement will only be
monotonic on a per server (node) basis.

Closes go-gitea#30074.
@GiteaBot GiteaBot added this to the 1.21.11 milestone Mar 28, 2024
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 28, 2024
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 28, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Mar 28, 2024
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 28, 2024
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 28, 2024
@silverwind silverwind enabled auto-merge (squash) March 28, 2024 16:07
@silverwind silverwind merged commit b1dae9f into go-gitea:release/v1.21 Mar 28, 2024
27 checks passed
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jun 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/go Pull requests that update Go code size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants