Skip to content

Conversation

@jglick
Copy link
Member

@jglick jglick commented May 6, 2025

see JENKINS-16341

Tested with the setup in jenkinsci/jenkins#10623 (comment).

@jglick jglick added the bug label May 6, 2025
Comment on lines -263 to +261
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) {
Copy link
Member Author

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) {
Copy link
Member Author

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) {
Copy link
Member Author

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;
Copy link
Member Author

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/

Comment on lines +214 to +223
// 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();
}
}
Copy link
Member Author

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());
Copy link
Member Author

@jglick jglick May 6, 2025

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.

Copy link
Member

@daniel-beck daniel-beck May 8, 2025

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.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member

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 👍

Copy link
Member

@daniel-beck daniel-beck left a 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.

@jglick jglick merged commit 69ae045 into jenkinsci:master Sep 17, 2025
14 checks passed
@jglick jglick deleted the BoundObjectTable-JENKINS-16341 branch September 17, 2025 23:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants