-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Conversation
Wait for @wolfogre 's review. |
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. |
There was a problem hiding this 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.
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.
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.
) 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]>
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.