-
-
Notifications
You must be signed in to change notification settings - Fork 113
[JENKINS-16341] Automatically expire entries from BoundObjectTable
#663
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
[JENKINS-16341] Automatically expire entries from BoundObjectTable
#663
Conversation
| private synchronized Ref release(String id) { | ||
| return entries.remove(id); | ||
| /** | ||
| * Releases a particular id from the table. | ||
| * Normally would be called via {@link #releaseMe} which infers the id from the current request. | ||
| */ | ||
| public void release(String id) { |
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.
Making this public so we can clean up the reflection in jenkinsci/jenkins@aac8c23.
| return resolve(false); | ||
| } | ||
|
|
||
| private Bound bind(Ref ref) { |
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.
inlined for clarity
| /** | ||
| * Binds an object temporarily and returns its URL. | ||
| */ | ||
| public Bound bindWeak(Object o) { |
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.
Apparently never used.
| */ | ||
| public static class Table implements Serializable { | ||
| private final Map<String, Ref> entries = new HashMap<>(); | ||
| private boolean logging; |
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.
Unnecessary, just use regular tools like https://plugins.jenkins.io/log-cli/
| // Before adding a new entry, clean up any old ones: | ||
| var it = entries.entrySet().iterator(); | ||
| while (it.hasNext()) { | ||
| var entry = it.next(); | ||
| if (!entry.getValue().valid()) { | ||
| LOGGER.fine(() -> "removing stale " + entry.getKey() + ": " | ||
| + entry.getValue().get()); | ||
| it.remove(); | ||
| } | ||
| } |
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.
The fix.
| public static boolean DEBUG_LOGGING = Boolean.getBoolean(BoundObjectTable.class.getName() + ".debugLog"); | ||
| private static final long EXPIRATION_TIME = Long.getLong( | ||
| BoundObjectTable.class.getName() + ".EXPIRATION_TIME", | ||
| Duration.ofMinutes(15).toMillis()); |
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.
Seems long enough for practical purposes. After this point, unused render-on-demand fragments will not work. For example, if you opened a project config form and came back 15m later and selected a parameter type from the dropdown, it will not render the per-parameter config snippet.
ProgressiveRendering, for example the agent build history screen, is unaffected since that already releases its binding as soon as it can. Similarly, used RoD fragments, such as build artifacts in jenkinsci/jenkins#10623, are released promptly anyway.
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.
Are we prepared to revert this based on user feedback? Because I'd be surprised if this didn't happen with some regularity:
For example, if you opened a project config form and came back 15m later and selected a parameter type from the dropdown, it will not render the per-parameter config snippet.
In particular, nontrivial freestyle or Pipeline (non-Jenkinsfile) configuration forms (with large inline scripts) could easily be open for 15 minutes while being worked on.
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.
WDYT about #665 + jenkinsci/jenkins#10631?
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.
If it works, sure. Or we can just increase the timeout to several hours, at which point your session is likely to have expired anyway so this would just be a fallback defense.
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.
Or a combination of the 2?
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.
Good point, cleaning up after 24 hrs or so (this approach) should not affect users while my PR keeps memory use low in the mean time, allowing for the greater timeout 👍
daniel-beck
left a comment
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.
Looks like a reasonable change to me. The current 1d timeout should be safe enough, and if that still accomplishes the goal, that's great.
see JENKINS-16341
Tested with the setup in jenkinsci/jenkins#10623 (comment).