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

SchemaCache is not updated across multiple Plone instances #136

Closed
avoinea opened this issue Oct 2, 2020 · 2 comments · Fixed by #137
Closed

SchemaCache is not updated across multiple Plone instances #136

avoinea opened this issue Oct 2, 2020 · 2 comments · Fixed by #137

Comments

@avoinea
Copy link
Member

avoinea commented Oct 2, 2020

How to reproduce:

  1. Start a ZEO cluster with 2 Plone ZEO clients
  2. Add Plone Site
  3. Go to first Plone instance > Site Setup > Dexterity Content-Types > Page
  4. Add new fieldset and new text field and press "Done"
  5. Go to the second Plone instance > Site Setup > Dexterity Content-Types > Page
  6. Notice the missing custom fieldset / field

Plone version: 5.2.2

See also:

@jensens
Copy link
Member

jensens commented Oct 2, 2020

@avoinea you wrote in plone/plone.schemaeditor#81

My proposal is to also check fti._p_time, somehow

But at
https://github.com/plone/plone.dexterity/blob/master/plone/dexterity/schema.py#L107
the stored mtime from the cache is checked already against the _p_mtime from the FTI. So I dont think that's the problem.

Moreover I suspect the fti_cache on the request itself is the problem and needs invalidation. I guess it contains the old _p_mtime for some reason. Maybe I am wrong, Just a rough shoot.

@avoinea
Copy link
Member Author

avoinea commented Oct 2, 2020

@jensens See https://github.com/plone/plone.dexterity/pull/137/files

The problem is like this:

  1. The first time you access schema for Document a new class called Plone_0_Document is generated and persisted as plone.dexterity.schema.generated.Plone_0_Document
  2. The next time, it is directly imported from plone.dexterity.schema.generated.Plone_0_Document
  3. When you add a new field, it is directly added to plone.dexterity.schema.generated.Plone_0_Document and then serialized to fti model_source XML.

This is OK as a workflow when you have only one Plone instance. When you have multiple, each Plone instance will have it's own version of Plone_0_Document depending on when it was first accessed, and will read and write there.

What I do with this PR, is to also add fti._p_mtime as a variant of generated class name, thus we'll have: Plone_delimiter_ModificationTime_delimiter_PortalType_delimiter_schema

This will ensure that you load the latest version of the schema on each Plone instance as the _p_mtime is persisted to ZODB.

_PS. I couldn't add the timestamp at the end as the _schema is optional, and the code will misinterpret our timestamp as schema

ale-rt pushed a commit that referenced this issue Oct 8, 2020
* Fixes #136 - Update dynamic schema on all ZEO clients on change
mauritsvanrees added a commit that referenced this issue Oct 13, 2020
2.2.x - Refs #136 - Update dynamic schema on all ZEO clients on change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants