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

Avoid POSKeyError when commit occurs and we have savepoint that involves Plone Site #4026

Merged
merged 2 commits into from
Oct 16, 2024

Conversation

wesleybl
Copy link
Member

@wesleybl wesleybl commented Oct 9, 2024

When ZODB handles savepoint and we have changes in Plone Site at that savepoint, it changes the _p_estimated_size attribute of Plone Site. This is an assignment to one of the special persistency attributes (identified by an _p_ name prefix); it should happen without access to any other attributes of obj. But obj._tree is accessed in __setattr__ of PloneSite class and results in a ZODB load which apparently fails.

See: plone/plone.restapi#1823 (comment)

@mister-roboto
Copy link

@wesleybl thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

@wesleybl
Copy link
Member Author

wesleybl commented Oct 9, 2024

@jenkins-plone-org please run jobs

Plone Site

When ZODB handles savepoint and we have changes in Plone Site at that
savepoint, it changes the `_p_estimated_size` attribute of Plone Site.
This is an assignment to one of the special persistency attributes
(identified by an _p_ name prefix); it should happen without access to
any other attributes of obj. But obj._tree is accessed in __setattr__ of
PloneSite class and results in a ZODB load which apparently fails.

See: plone/plone.restapi#1823 (comment)
@wesleybl
Copy link
Member Author

wesleybl commented Oct 9, 2024

@d-maurer FYI

@@ -61,7 +61,7 @@ def __getattr__(self, name):

def __setattr__(self, name, obj):
# handle re setting an item as an attribute
if self._tree is not None and name in self:
if not name.startswith("_") and self._tree is not None and name in self:
Copy link
Member

@ale-rt ale-rt Oct 15, 2024

Choose a reason for hiding this comment

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

Shouldn't we be more strict with this change and check for name.startswith("_p_") or name.startswith("_v_")?

@d-maurer
Copy link

d-maurer commented Oct 15, 2024 via email

@rohnsha0
Copy link
Contributor

@jenkins-plone-org please run jobs

Copy link
Member

@davisagli davisagli left a comment

Choose a reason for hiding this comment

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

@d-maurer @wesleybl Thanks for the analysis and fix. I've seen this error before but hadn't figured out the scenario when it happens.

@davisagli davisagli merged commit 9a1a62b into master Oct 16, 2024
2 of 4 checks passed
@davisagli davisagli deleted the poskeyerror branch October 16, 2024 05:21
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.

6 participants