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 #81

Closed
avoinea opened this issue Sep 30, 2020 · 9 comments
Closed

SchemaCache is not updated across multiple Plone instances #81

avoinea opened this issue Sep 30, 2020 · 9 comments

Comments

@avoinea
Copy link
Member

avoinea commented Sep 30, 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: https://community.plone.org/t/dynamic-schema-is-not-synced-across-zeo-clients/12923

@avoinea
Copy link
Member Author

avoinea commented Sep 30, 2020

@avoinea
Copy link
Member Author

avoinea commented Oct 1, 2020

@jensens
Copy link
Member

jensens commented Oct 1, 2020

So, the schema cache is not invalidated on the other client?

@avoinea
Copy link
Member Author

avoinea commented Oct 1, 2020

@jensens Indeed. I did some digging and now I'm not that sure that the issue is generated by SCHEMA_CACHE.

@jensens
Copy link
Member

jensens commented Oct 1, 2020

You may write a simple view that invalidates the schema cache - and if it works afterwards it is the cache ;)

@avoinea
Copy link
Member Author

avoinea commented Oct 2, 2020

You may write a simple view that invalidates the schema cache - and if it works afterwards it is the cache ;)

I commented the caching part in volatile and the issue is still there.

That's why I suspect the issue is in EditableSchema

Thus, when you add a new field, it is directly added in the schema _InterfaceClass__attrs and then serialized and saved to portal_types as model_source XML. But this value is never deserialized on get (only on Zope start).

I still don't have the whole picture, thus I may be wrong on that.

@avoinea
Copy link
Member Author

avoinea commented Oct 2, 2020

ftiModified is supposed to re-sync schema, but:

  1. ObjectModified is not triggered on schema edit (add field, add fieldset, save defaults)
  2. This wouldn't fix our issue as the event is triggered only on the ZEO client where the action took place.

We need to re-sync schema from model_source on get (based on fti modification time, or something). See also https://github.com/plone/plone.dexterity/blob/master/plone/dexterity/schema.py#L409-L410. This code is executed only once per ZEO client, when you first access that schema.

@avoinea
Copy link
Member Author

avoinea commented Oct 2, 2020

Yap. Removing https://github.com/plone/plone.dexterity/blob/master/plone/dexterity/schema.py#L409-L415 solved the issue.

My proposal is to also check fti._p_time, somehow 😄

Suggestions are welcome.

@avoinea
Copy link
Member Author

avoinea commented Oct 2, 2020

See plone/plone.dexterity#136

@avoinea avoinea closed this as completed Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants