Cockpit-HQ / Cockpit

Cockpit Core - Content Platform
https://getcockpit.com
Other
388 stars 48 forks source link

Updates disappearing every other time I update model #202

Closed leijoninna closed 3 months ago

leijoninna commented 3 months ago

Creating a new model the first time works well, but it got a bit confusing when trying to update existing models.

At first I was a bit perplexed when small updates such as change of display name or field info did not seem to be saved, and I figured I had to to the same change twice for it to update properly.

But it quickly turned into a real big issue when I realized that big changes could disappear and then come back the next time I update the model. I can reproduce this every time.

I can do this over and over again. When the fields are missing, I can add new fields that will only be there every other time, but not when the first fields are there. When fields are missing, I cannot add new model objects with these fields, so I have to go to update the model to get the fields back. If I add new fields with exactly the same info as the missing ones they will be there every time, but only because it seems to be alternating between them (and I realize that is what happened when my small updates only worked after I did them twice). It goes for every type of update, not just adding fields.

Seems like a major issue, since I will not always be completely done with the model the first time it is created.

I am using the mongolite db, if that matters.

aheinze commented 3 months ago

Hi! Which version are you using?

leijoninna commented 3 months ago

Hi! Which version are you using?

I'm using 2.8.6, updated from settings view. I installed with 2.8.5, which also had the same issue.

aheinze commented 3 months ago

I can't re-produce the issue. Can you you maybe create a video? Also, do you see any JS errors in the js console?

leijoninna commented 3 months ago

This is a video of the issue. I created a testmodel with one field, which stays put. Any other change after that is only there every other update.

https://github.com/user-attachments/assets/b8a46fc6-399c-4938-ad70-0eceb585b246

Tested on Google Chrome for Mac and on Safari with the same result. Goes for any type of update, both for collections and singletons. The only way to make the updates permanent is to make the exact same update twice, so it alternates between them.

As I mentioned, this is a mongolite db.

There are no errors in the regular web console. Is there any other console? I can see in the system info that Debug mode is 'Disabled' but I cannot see how to enable it either.

aheinze commented 3 months ago

Thank you for providing the video. Unfortunately I still can't verify the issue. To me it looks like an opcache issue or setup on your server. Do you have any chance to test this on another environment?

leijoninna commented 3 months ago

I managed to disable the opcache on the server which seems to have solved the issue.

Is opcache not recommended or Cockpit? I cannot find any information about it. This cache is on by default and seems to be on most hosting providers. I had to dig deep to find how to disable it.

aheinze commented 3 months ago

It is highly recommended. But it looks like your server is so configured that the function opcache_invalidate isn't available or is disabled. This function is called (if available) to invalidate the filecache on a model update.

aheinze commented 3 months ago

Another option is to store the models in the database. Therefore you have to adjust your config (config/config.php):

<?php

return [

    ...

    # store model schema in database instead of filesystem (default)
    'content' => [
        'models' => ['storage' => 'database']
    ],
];