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

WICKET-6558 no lock after detach #380

Closed
wants to merge 2 commits into from

Conversation

svenmeier
Copy link
Contributor

A possible solution:
Session can prevent creating of locks after it has been detached for the end of the request.

pageManager = internalGetPageManager();
}
pageManager.detach();
internalGetPageManager().detach();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sufficient to detach the page manager only. No need to detach the session here, RequestCycle#onDetach() does it already.


if (Application.exists())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Left over when this code was copied over from a request listener.

@@ -670,6 +676,9 @@ public void detach()
{
detachFeedback();

pageAccessSynchronizer.get().unlockAllPages();
RequestCycle.get().setMetaData(PAGES_UNLOCKED, true);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

MetaData is set on request cycle, so no need to clear the flag.

@@ -915,6 +924,10 @@ public int nextPageId()
*/
public final IPageManager getPageManager()
{
if (Boolean.TRUE.equals(RequestCycle.get().getMetaData(PAGES_UNLOCKED))) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When detached, Session no longer gives access to it's access-synchronizing manager.

getLastRenderedPage().detach();
getSession().detach();
applicationSettings.setFeedbackMessageCleanupFilter(old);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We cannot detach the session, otherwise it will block access to its page manager afterwards. Actually detachment isn't needed anyways, just the message have to be cleared. For symmetry don't call detach on components either.

@seminolas
Copy link

Looks good to me. We had some custom logging asking for the name of the page class after the session had already been detached. We only noticed it in production with locked page exceptions - this would have made debugging much easier.
@svenmeier I wonder if you can comment on why we only saw it very rarely. My theory was to do with unmounted pages: most of our pages are mounted and presumably resolving the page class uses some shortcut in code - without requiring a page lock. Resolving the name for unmounted pages does require a lock and caused the LockedPage exception on subsequent request. Does that sound reasonable? Our current fix only disables that (unnecessary) bit of logging -- and it seems to work -- but I wonder if I'm merely fixing a symptom of the real issue.

@svenmeier
Copy link
Contributor Author

Hard to tell what might increase the likelihood of that happening. Perhaps you can pinpoint a specific version upgrade?

@@ -915,6 +924,10 @@ public int nextPageId()
*/
public final IPageManager getPageManager()
{
if (Boolean.TRUE.equals(RequestCycle.get().getMetaData(PAGES_UNLOCKED))) {
throw new WicketRuntimeException("pages have already been unlocked - synchronized access is no longer possible");
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure how understandable this message would be for the average developer. Maybe something like "The request [cycle] has been processed. Access to the pages is no more allowed" ?

@asfgit asfgit closed this in c3a3e78 Aug 23, 2019
@solomax solomax deleted the WICKET-6558-prevent-lock-after-detach branch May 5, 2022 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants