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

Remove expire from context cache #32001

Closed
wants to merge 3 commits into from
Closed

Conversation

lunny
Copy link
Member

@lunny lunny commented Sep 6, 2024

Once a request took more than 10s, the warning [W] cache context is expired, may be misused for long-life tasks: &{map[] {{0 0} 0 0 {{} 0} {{} 0}} {13956354484237509102 85424598204433 0x6a66660} false}, ref #31757 (comment) .
The expiration has been introduced in #23330 and I approved. But now I'm suspecting if it's necessary. Since every request has it's own expiration time, the context cache should have the same lifecycle as the request.
So this PR just removed the expire checking, the context cache will still be available even if a SQL took over 10 seconds.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 6, 2024
@lunny lunny requested a review from wolfogre September 6, 2024 20:08
@pull-request-size pull-request-size bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 6, 2024
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Sep 6, 2024
@lunny lunny added the backport/v1.22 This PR should be backported to Gitea 1.22 label Sep 6, 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 Sep 7, 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 Sep 7, 2024
@techknowlogick techknowlogick enabled auto-merge (squash) September 7, 2024 21:37
@techknowlogick techknowlogick added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 7, 2024
@lunny lunny disabled auto-merge September 7, 2024 21:44
@lunny
Copy link
Member Author

lunny commented Sep 7, 2024

Wait for @wolfogre 's review.

@lunny lunny removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Sep 7, 2024
@wolfogre
Copy link
Member

wolfogre commented Sep 8, 2024

Please hold on. Why was the expiration time design introduced, to solve what problem, and why is it safe to remove it now that it is no longer a concern? This PR does not explain these questions. I will check it and review it later.

@wolfogre wolfogre added the lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged label Sep 8, 2024
Copy link
Member

@wolfogre wolfogre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't LGTM. Please read the discussion in the comments of #23218. The expiration is used to avoid the context cache being used for long-term work. It is not really related to the lifecycle of the context itself.

My original idea was 5 minutes, not 10 seconds. So I suggest changing the duration from 10s to 5 minutes to reduce false reports instead of removing it entirely.

@GiteaBot GiteaBot removed the lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. label Sep 8, 2024
@wolfogre
Copy link
Member

wolfogre commented Sep 8, 2024

#32011

@lunny lunny closed this Sep 8, 2024
@lunny lunny deleted the lunny/remove_expire branch September 8, 2024 16:40
@lunny lunny removed the backport/v1.22 This PR should be backported to Gitea 1.22 label Sep 9, 2024
lunny pushed a commit that referenced this pull request Sep 9, 2024
Replace #32001.

To prevent the context cache from being misused for long-term work
(which would result in using invalid cache without awareness), the
context cache is designed to exist for a maximum of 10 seconds. This
leads to many false reports, especially in the case of slow SQL.

This PR increases it to 5 minutes to reduce false reports.

5 minutes is not a very safe value, as a lot of changes may have
occurred within that time frame. However, as far as I know, there has
not been a case of misuse of context cache discovered so far, so I think
5 minutes should be OK.

Please note that after this PR, if warning logs are found again, it
should get attention, at that time it can be almost 100% certain that it
is a misuse.
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Sep 10, 2024
Replace go-gitea#32001.

To prevent the context cache from being misused for long-term work
(which would result in using invalid cache without awareness), the
context cache is designed to exist for a maximum of 10 seconds. This
leads to many false reports, especially in the case of slow SQL.

This PR increases it to 5 minutes to reduce false reports.

5 minutes is not a very safe value, as a lot of changes may have
occurred within that time frame. However, as far as I know, there has
not been a case of misuse of context cache discovered so far, so I think
5 minutes should be OK.

Please note that after this PR, if warning logs are found again, it
should get attention, at that time it can be almost 100% certain that it
is a misuse.
wolfogre added a commit that referenced this pull request Sep 11, 2024
)

Backport #32011 by @wolfogre

Replace #32001.

To prevent the context cache from being misused for long-term work
(which would result in using invalid cache without awareness), the
context cache is designed to exist for a maximum of 10 seconds. This
leads to many false reports, especially in the case of slow SQL.

This PR increases it to 5 minutes to reduce false reports.

5 minutes is not a very safe value, as a lot of changes may have
occurred within that time frame. However, as far as I know, there has
not been a case of misuse of context cache discovered so far, so I think
5 minutes should be OK.

Please note that after this PR, if warning logs are found again, it
should get attention, at that time it can be almost 100% certain that it
is a misuse.

Co-authored-by: Jason Song <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/blocked A maintainer has reservations with the PR and thus it cannot be merged modifies/go Pull requests that update Go code size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants