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

[Bug]: When running repair steps for the first time, changed classes get not loaded properly #38158

Open
5 of 9 tasks
dartcafe opened this issue May 9, 2023 · 14 comments
Open
5 of 9 tasks

Comments

@dartcafe
Copy link
Contributor

dartcafe commented May 9, 2023

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

When updating an app (here it is Polls) via occ it seems that altered classes, which are used inside a repair step get not updated properly (caching??). A second update run then installs the app with out an exception.

Steps to reproduce

See details here: nextcloud/polls#2900 and nextcloud/polls#2793

Expected behavior

changed classes should be loaded properly while updating an app.

Installation method

Community Web installer on a VPS or web space

Nextcloud Server version

26

Operating system

None

PHP engine version

PHP 8.1

Web server

Apache (supported)

Database engine version

MySQL

Is this bug present after an update or on a fresh install?

None

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "test.yagst.de"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "tempdirectory": "\/tmp\/nextcloud",
        "dbtype": "mysql",
        "version": "26.0.1.1",
        "overwrite.cli.url": "http:\/\/xxx",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "theme": "",
        "loglevel": 0,
        "maintenance": false,
        "ldapIgnoreNamingRules": false,
        "ldapProviderFactory": "OCA\\User_LDAP\\LDAPProviderFactory",
        "app_install_overwrite": [
            "polls"
        ]
    }
}

List of activated Apps

Enabled:
  - activity: 2.18.0
  - admin_audit: 1.16.0
  - bruteforcesettings: 2.6.0
  - circles: 26.0.0
  - cloud_federation_api: 1.9.0
  - comments: 1.16.0
  - contactsinteraction: 1.7.0
  - dashboard: 7.6.0
  - dav: 1.25.0
  - federatedfilesharing: 1.16.0
  - federation: 1.16.0
  - files: 1.21.1
  - files_external: 1.18.0
  - files_pdfviewer: 2.7.0
  - files_rightclick: 1.5.0
  - files_sharing: 1.18.0
  - files_trashbin: 1.16.0
  - files_versions: 1.19.1
  - firstrunwizard: 2.15.0
  - logreader: 2.11.0
  - lookup_server_connector: 1.14.0
  - nextcloud_announcements: 1.15.0
  - notifications: 2.14.0
  - oauth2: 1.14.0
  - password_policy: 1.16.0
  - photos: 2.2.0
  - polls: 5.0.5
  - privacy: 1.10.0
  - provisioning_api: 1.16.0
  - recommendations: 1.5.0
  - related_resources: 1.1.0-alpha1
  - serverinfo: 1.16.0
  - settings: 1.8.0
  - sharebymail: 1.16.0
  - support: 1.9.0
  - survey_client: 1.14.0
  - systemtags: 1.16.0
  - text: 3.7.2
  - theming: 2.1.1
  - twofactor_backupcodes: 1.15.0
  - updatenotification: 1.16.0
  - user_ldap: 1.16.0
  - user_status: 1.6.0
  - viewer: 1.10.0
  - weather_status: 1.6.0
  - workflowengine: 2.8.0
Disabled:
  - encryption: 2.14.0 (installed 2.8.1)
  - suspicious_login: 4.4.0
  - twofactor_totp: 8.0.0-alpha.0

Nextcloud Signing status

Technical information
=====================
The following list covers which files have failed the integrity check. Please read
the previous linked documentation to learn more about the errors and how to fix
them.

Results
=======
- core
	- INVALID_HASH
		- .user.ini

Raw output
==========
Array
(
    [core] => Array
        (
            [INVALID_HASH] => Array
                (
                    [.user.ini] => Array
                        (
                            [expected] => 4843b3217e91f8536cb9b52700efb20300290292cf6286f92794d4cec99df286afeb7dd6c91b1be20bc55eda541eef230a5c5e7dcd46c189edd0ed1e80c6d3f5
                            [current] => 3fecf59adb63f3529c30449b25264e1fd2a447b855afae05821110b50039a5e51f6c4f3349399512602b5544a65cdf6fa3c50b81f16fcbe2e0be175d9f6c4c82
                        )

                )

        )

)

Nextcloud Logs

sudo -u www-data php8.1 ./occ app:update --all
polls new version available: 5.0.5
An unhandled exception has been thrown:
Error: Call to undefined method OCA\Polls\Db\TableManager::deleteAllDuplicates() in /var/www/nc_01/nextcloud/apps/polls/lib/Migration/RepairSteps/DeleteInvalidRecords.php:70
Stack trace:
#0 /var/www/nc_01/nextcloud/lib/private/Repair.php(127): OCA\Polls\Migration\RepairSteps\DeleteInvalidRecords->run()
#1 /var/www/nc_01/nextcloud/lib/private/legacy/OC_App.php(1068): OC\Repair->run()
#2 /var/www/nc_01/nextcloud/lib/private/legacy/OC_App.php(1005): OC_App::executeRepairSteps()
#3 /var/www/nc_01/nextcloud/lib/private/Installer.php(200): OC_App::updateApp()
#4 /var/www/nc_01/nextcloud/core/Command/App/Update.php(107): OC\Installer->updateAppstoreApp()
#5 /var/www/nc_01/nextcloud/apps/recognize/vendor/symfony/console/Command/Command.php(298): OC\Core\Command\App\Update->execute()
#6 /var/www/nc_01/nextcloud/apps/recognize/vendor/symfony/console/Application.php(1040): Symfony\Component\Console\Command\Command->run()
#7 /var/www/nc_01/nextcloud/apps/recognize/vendor/symfony/console/Application.php(301): Symfony\Component\Console\Application->doRunCommand()
#8 /var/www/nc_01/nextcloud/apps/recognize/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#9 /var/www/nc_01/nextcloud/lib/private/Console/Application.php(214): Symfony\Component\Console\Application->run()
#10 /var/www/nc_01/nextcloud/console.php(100): OC\Console\Application->run()
#11 /var/www/nc_01/nextcloud/occ(11): require_once('...')
#12 {main}

Additional info

The method OCA\Polls\Db\TableManager::deleteAllDuplicates() was added in the last Polls version (5.0.5).

The error trace is taken from nextcloud/polls#2900
The system configuration is taken from my test instance, where I could observe this problem too.

@dartcafe dartcafe added bug 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels May 9, 2023
@szaimen
Copy link
Contributor

szaimen commented May 11, 2023

cc @nextcloud/server-backend

@ChristophWurst
Copy link
Member

Same with nextcloud/mail#8146 and nextcloud/calendar#5191

Summary: the app migration/repair step are run with a mix of old app code and new app code.

I think the only possible fix is to run migrations and repair steps in a new process

@ChristophWurst
Copy link
Member

@szaimen
Copy link
Contributor

szaimen commented Jun 8, 2023

@dartcafe

This comment was marked as off-topic.

@ChristophWurst
Copy link
Member

ChristophWurst commented Jun 29, 2023

Let's keep separate issues separate

  1. In-process replacement of code during an app update (this ticket)
  2. Lack of opcache refresh after changed code: [Bug]: OPCache doesn't refresh when code changes #39079

These require two distinct fixes.

@dartcafe

This comment was marked as outdated.

@szaimen
Copy link
Contributor

szaimen commented Sep 10, 2023

Possibky this was fixed with #40349

@dartcafe
Copy link
Contributor Author

Will check it with 28 beta

@ChristophWurst
Copy link
Member

#38158 (comment)

@dartcafe
Copy link
Contributor Author

dartcafe commented Nov 3, 2023

I tried to reproduce this error in 27.1.3 before updating to 28-beta1, but the migration runs thru with new methods. So it seems it is already fixed in 27.

In 28-beta1 the problem does not occur as well.

@dartcafe dartcafe closed this as completed Nov 3, 2023
@ChristophWurst
Copy link
Member

ChristophWurst commented Nov 3, 2023

I do not think this is fixed. See #38158 (comment) for the distinction of the two problems with caching code. One was fixed, the other wasn't.

@dartcafe
Copy link
Contributor Author

dartcafe commented Nov 3, 2023

Funny thing. If it is still present, then I did something weird while trying to reproduce it. I was sure, I provocated the issue by adding and calling new methods to the repais steps. I will try my luck again.

Reopen?

@ChristophWurst
Copy link
Member

calling new methods to the repais steps

It works if the class hasn't been loaded prior to code replacement.

Works:

  1. Nextcloud boots
  2. Nextcloud replaces app code
  3. Nextcloud runs upgrade routine
  4. Upgrade routine loads app class

Doesn't work

  1. Nextcloud boots and loads an app class
  2. Nextcloud replaces app code
  3. Nextcloud runs upgrade routine
  4. Upgrade routine calls new method on the old version of the class

@ChristophWurst ChristophWurst reopened this Nov 6, 2023
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

4 participants