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

Cookbook don't work with Redis #871

Closed
borsti87 opened this issue Dec 22, 2021 · 11 comments
Closed

Cookbook don't work with Redis #871

borsti87 opened this issue Dec 22, 2021 · 11 comments
Labels
Backend Issue or PR related to the backend code bug Something isn't working stale The PR/issue is marked as stale stalebot-enabled The PR/issue is marked to go stale over time

Comments

@borsti87
Copy link

Description
when I activate Redis in the Nextcloud config, Cookbook no longer works

Reproduction
I insert following lines to the Nextcloud coinfig.php:

  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'password' => 'password',
  ),
everything works fine, but Cookbook causes an internal server error

For error details see the snipped of nextcloud.log

Browser
Firefox 95.0.1 & Opera 82.0.4227.33

Versions
Nextcloud server version: 22.2.3
Cookbook version: 0.9.8
Database system: MySQL
PHP version: 7.3.31

Thanks in advance

@borsti87 borsti87 added the bug Something isn't working label Dec 22, 2021
@coatmaker618
Copy link

I am super curious to see what would cause this. I was interested in installing REDIS on my NC server, so I'll be curious to see what apps break--especially this one.

@christianlupus
Copy link
Collaborator

Hello @borsti87,

first of all, the cookbook app does not use Redis directly. So, I was a bit confused about what might be the reason for the trouble. I did not find anything yet, that I can mark as the root cause.

From your log, I extracted a few pieces of information. It seems to me, you are using the group folder app to share (?) the recipe folder. I found also some traces that you are using some sort of guest mode (I honestly just pick on clues here).

My analysis so far is that upon opening the cookbook the app tries to update the cache in the database. This is normal and typically done in intervals of 5 to 15 min. During these processes all files in the cookbook folder are iterated and looked for changes. To do so, all files need to be read and parsed. The reading is handled by the NC internal core structures (not the app) together with some safety nets like locking.
The locking is one of the things that are outsourced to Redis by the core. For some reason, the locking seems to be broken, and the server uses a non-initialized memcache (see here). I do not know the glory details of the locking mechanism but this seems for me to be a configuration issue with the main server.

I second that also as most of the errors in the log do not reference any file within the cookbook app itself in the trace. We cannot do anything related to this problem when it is not triggered by the app's code 😄.

A side remark: I am using Redis + cookbook productively myself and I did not find this a problem so far. Either, you have some special configuration, that we would need to tackle, or there is something wrong with the instance as far as I guess.

Two things you could try out:

  1. Disable only locking via Redis but keeping the distributed cache. Let's see if that works.
  2. Open the developer tools in the browser and browse through other apps (e.g. the files app in the Cookbook folder). Have close look if any other requests result in 5xx HTTP status codes. This would be a good indicator that more is broken than the cookbook app.

Sorry, apart from that, I am a bit lost on your case. Maybe you can share a bit more of your setup/configuration. Maybe we find something there. If not, I only see the option to build a test environment where we can play together.

@borsti87
Copy link
Author

Hello @christianlupus,

I will check this within a few days.

@christianlupus christianlupus added Backend Issue or PR related to the backend code stalebot-enabled The PR/issue is marked to go stale over time labels Jan 18, 2022
@borsti87
Copy link
Author

Hello @christianlupus,

here are some answers:

I extracted some information from your log. It seems to me that you are using the group folder app to share the recipe folder (?).

Yes, I have shared my recipes in a group folder with my family.

I also found evidence that you are using some sort of guest mode.

I don't know what you mean 😕 I wouldn't know that I have anything like a guest mode configured/installed.

I have now disabled filelocking in config.php

'filelocking.enabled' => false,

With this, the cookbook now works, but file locking is now disabled.

I have not been involved with developing for Nextcloud yet. Where can I brows to the developer tools you mentioned?

@christianlupus
Copy link
Collaborator

I also found evidence that you are using some sort of guest mode.

I don't know what you mean 😕 I wouldn't know that I have anything like a guest mode configured/installed.

Are all users regular users of the Nextcloud instance or are these eventually just added using guest app? Are there any other plugins installed that might interfere or indicate a guest mode?

I have now disabled filelocking in config.php
[...]
With this, the cookbook now works, but file locking is now disabled.

That at least narrowed down the problem further. We are not yet there but the narrower the problem the better.

I have not been involved with developing for Nextcloud yet. Where can I brows to the developer tools you mentioned?

Typically simply press F12 in your browser. This is not Nextcloud-specific but just a way to see if the browser reports issues with javascript, network connections and also to see the current structure of the homepage you are visiting.

@borsti87
Copy link
Author

borsti87 commented Jan 18, 2022

Are all users regular users of the Nextcloud instance or are these eventually just added using guest app? Are there any other plugins installed that might interfere or indicate a guest mode?

All users are regular users and guests app is not installed.

Here are a list off installed apps: app_list_2022-01-18.txt

To test filelocking, I have temporarly enabled it again

on Cookbook app I get following 5xx response:
at first run Cookbook after enabeling I get:
500 Internal Server Error /index.php/apps/cookbook/api/recipes
When I call further I get the following response
500 Internal Server Error /index.php/apps/cookbook/

I have opened a few other apps, but no other gives me a 5xx response

@christianlupus christianlupus removed the stalebot-enabled The PR/issue is marked to go stale over time label Feb 21, 2022
@christianlupus
Copy link
Collaborator

I am not yet sure, where the culprit lies. To allow easier reading of the issue, I extract some relevant information from the logs.

To allow easier reading of the log file, I extracted 3 relevant lines (as there are three different types of errors in the logs) and inserted them here.

The first offending line is here.

First error in the logs
{
  "reqId": "abc",
  "level": 3,
  "time": "12-22-2021 10:07:52",
  "remoteAddr": "127.0.0.1",
  "user": "user",
  "app": "index",
  "method": "GET",
  "url": "/index.php/apps/cookbook/",
  "message": "Call to a member function exec() on bool",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36 OPR/82.0.4227.33",
  "version": "22.2.3.0",
  "exception": {
    "Exception": "Exception",
    "Message": "Call to a member function exec() on bool",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
        "line": 156,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          {
            "__class__": "OCA\\Cookbook\\Controller\\MainController"
          },
          "index"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Route/Router.php",
        "line": 302,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::",
        "args": [
          "OCA\\Cookbook\\Controller\\MainController",
          "index",
          {
            "__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"
          },
          {
            "_route": "cookbook.main.index"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/base.php",
        "line": 1006,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->",
        "args": [
          "/apps/cookbook/"
        ]
      },
      {
        "file": "/var/www/nextcloud/index.php",
        "line": 36,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": []
      }
    ],
    "File": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
    "Line": 158,
    "Previous": {
      "Exception": "Error",
      "Message": "Call to a member function exec() on bool",
      "Code": 0,
      "Trace": [
        {
          "file": "/var/www/nextcloud/lib/private/Lock/MemcacheLockingProvider.php",
          "line": 104,
          "function": "cad",
          "class": "OC\\Memcache\\Redis",
          "type": "->",
          "args": [
            "files/dd1f08c3248f2c55d1af89480614146a",
            1
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Storage/Common.php",
          "line": 785,
          "function": "releaseLock",
          "class": "OC\\Lock\\MemcacheLockingProvider",
          "type": "->",
          "args": [
            "files/dd1f08c3248f2c55d1af89480614146a",
            1
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php",
          "line": 602,
          "function": "releaseLock",
          "class": "OC\\Files\\Storage\\Common",
          "type": "->",
          "args": [
            "__groupfolders/1/Antipastiplatte à la NRW/recipe.json",
            1,
            {
              "__class__": "OC\\Lock\\MemcacheLockingProvider"
            }
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Jail.php",
          "line": 463,
          "function": "releaseLock",
          "class": "OC\\Files\\Storage\\Wrapper\\Wrapper",
          "type": "->",
          "args": [
            "__groupfolders/1/Antipastiplatte à la NRW/recipe.json",
            1,
            {
              "__class__": "OC\\Lock\\MemcacheLockingProvider"
            }
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php",
          "line": 602,
          "function": "releaseLock",
          "class": "OC\\Files\\Storage\\Wrapper\\Jail",
          "type": "->",
          "args": [
            "Antipastiplatte à la NRW/recipe.json",
            1,
            {
              "__class__": "OC\\Lock\\MemcacheLockingProvider"
            }
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php",
          "line": 602,
          "function": "releaseLock",
          "class": "OC\\Files\\Storage\\Wrapper\\Wrapper",
          "type": "->",
          "args": [
            "Antipastiplatte à la NRW/recipe.json",
            1,
            {
              "__class__": "OC\\Lock\\MemcacheLockingProvider"
            }
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Storage/Wrapper/Wrapper.php",
          "line": 602,
          "function": "releaseLock",
          "class": "OC\\Files\\Storage\\Wrapper\\Wrapper",
          "type": "->",
          "args": [
            "Antipastiplatte à la NRW/recipe.json",
            1,
            {
              "__class__": "OC\\Lock\\MemcacheLockingProvider"
            }
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/View.php",
          "line": 2054,
          "function": "releaseLock",
          "class": "OC\\Files\\Storage\\Wrapper\\Wrapper",
          "type": "->",
          "args": [
            "Antipastiplatte à la NRW/recipe.json",
            1,
            {
              "__class__": "OC\\Lock\\MemcacheLockingProvider"
            }
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/View.php",
          "line": 2106,
          "function": "unlockPath",
          "class": "OC\\Files\\View",
          "type": "->",
          "args": [
            "/user/files/Kochbuch Gerdtoberens/Antipastiplatte à la NRW/recipe.json",
            1,
            false
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/View.php",
          "line": 1219,
          "function": "unlockFile",
          "class": "OC\\Files\\View",
          "type": "->",
          "args": [
            "/user/files/Kochbuch Gerdtoberens/Antipastiplatte à la NRW/recipe.json",
            1
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/View.php",
          "line": 601,
          "function": "basicOperation",
          "class": "OC\\Files\\View",
          "type": "->",
          "args": [
            "file_get_contents",
            "/user/files/Kochbuch Gerdtoberens/Antipastiplatte à la NRW/recipe.json",
            [
              "read"
            ]
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Files/Node/File.php",
          "line": 56,
          "function": "file_get_contents",
          "class": "OC\\Files\\View",
          "type": "->",
          "args": [
            "/user/files/Kochbuch Gerdtoberens/Antipastiplatte à la NRW/recipe.json"
          ]
        },
        {
          "file": "/var/www/nextcloud/apps/cookbook/lib/Service/DbCacheService.php",
          "line": 121,
          "function": "getContent",
          "class": "OC\\Files\\Node\\File",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/apps/cookbook/lib/Service/DbCacheService.php",
          "line": 102,
          "function": "parseJSONFile",
          "class": "OCA\\Cookbook\\Service\\DbCacheService",
          "type": "->",
          "args": [
            {
              "__class__": "OC\\Files\\Node\\File"
            }
          ]
        },
        {
          "file": "/var/www/nextcloud/apps/cookbook/lib/Service/DbCacheService.php",
          "line": 47,
          "function": "parseJSONFiles",
          "class": "OCA\\Cookbook\\Service\\DbCacheService",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/apps/cookbook/lib/Service/DbCacheService.php",
          "line": 373,
          "function": "updateCache",
          "class": "OCA\\Cookbook\\Service\\DbCacheService",
          "type": "->",
          "args": [
            "*** sensitive parameters replaced ***"
          ]
        },
        {
          "file": "/var/www/nextcloud/apps/cookbook/lib/Service/DbCacheService.php",
          "line": 362,
          "function": "checkSearchIndexUpdate",
          "class": "OCA\\Cookbook\\Service\\DbCacheService",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/apps/cookbook/lib/Controller/MainController.php",
          "line": 63,
          "function": "triggerCheck",
          "class": "OCA\\Cookbook\\Service\\DbCacheService",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
          "line": 217,
          "function": "index",
          "class": "OCA\\Cookbook\\Controller\\MainController",
          "type": "->",
          "args": []
        },
        {
          "file": "/var/www/nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
          "line": 126,
          "function": "executeController",
          "class": "OC\\AppFramework\\Http\\Dispatcher",
          "type": "->",
          "args": [
            {
              "__class__": "OCA\\Cookbook\\Controller\\MainController"
            },
            "index"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/AppFramework/App.php",
          "line": 156,
          "function": "dispatch",
          "class": "OC\\AppFramework\\Http\\Dispatcher",
          "type": "->",
          "args": [
            {
              "__class__": "OCA\\Cookbook\\Controller\\MainController"
            },
            "index"
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/private/Route/Router.php",
          "line": 302,
          "function": "main",
          "class": "OC\\AppFramework\\App",
          "type": "::",
          "args": [
            "OCA\\Cookbook\\Controller\\MainController",
            "index",
            {
              "__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"
            },
            {
              "_route": "cookbook.main.index"
            }
          ]
        },
        {
          "file": "/var/www/nextcloud/lib/base.php",
          "line": 1006,
          "function": "match",
          "class": "OC\\Route\\Router",
          "type": "->",
          "args": [
            "/apps/cookbook/"
          ]
        },
        {
          "file": "/var/www/nextcloud/index.php",
          "line": 36,
          "function": "handleRequest",
          "class": "OC",
          "type": "::",
          "args": []
        }
      ],
      "File": "/var/www/nextcloud/lib/private/Memcache/Redis.php",
      "Line": 173
    },
    "CustomMessage": "--"
  }
}

The second and third errors seem to be triggered somehow by the app but the backtrace does not indicate the exact problem location.

Second error in the logs
{
  "reqId": "abc",
  "level": 3,
  "time": "12-22-2021 10:07:52",
  "remoteAddr": "127.0.0.1",
  "user": "user",
  "app": "PHP",
  "method": "GET",
  "url": "/index.php/apps/cookbook/",
  "message": "json_decode() expects parameter 1 to be string, object given at /var/www/nextcloud/lib/private/Memcache/Redis.php#59",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36 OPR/82.0.4227.33",
  "version": "22.2.3.0",
  "exception": {
    "Exception": "Error",
    "Message": "json_decode() expects parameter 1 to be string, object given at /var/www/nextcloud/lib/private/Memcache/Redis.php#59",
    "Code": 0,
    "Trace": [
      {
        "function": "onError",
        "class": "OC\\Log\\ErrorHandler",
        "type": "::",
        "args": [
          2,
          "json_decode() expects parameter 1 to be string, object given",
          "/var/www/nextcloud/lib/private/Memcache/Redis.php",
          59,
          {
            "key": "core-merged-template-prepend.js.deps",
            "result": {
              "__class__": "Redis"
            }
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Memcache/Redis.php",
        "line": 59,
        "function": "json_decode",
        "args": [
          {
            "__class__": "Redis"
          },
          true
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Template/JSCombiner.php",
        "line": 122,
        "function": "get",
        "class": "OC\\Memcache\\Redis",
        "type": "->",
        "args": [
          "core-merged-template-prepend.js.deps"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Template/JSCombiner.php",
        "line": 102,
        "function": "isCached",
        "class": "OC\\Template\\JSCombiner",
        "type": "->",
        "args": [
          "merged-template-prepend.js.deps",
          {
            "__class__": "OC\\Files\\SimpleFS\\SimpleFolder"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Template/JSResourceLocator.php",
        "line": 115,
        "function": "process",
        "class": "OC\\Template\\JSCombiner",
        "type": "->",
        "args": [
          "/var/www/nextcloud",
          "core/js/merged-template-prepend.json",
          "core"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Template/JSResourceLocator.php",
        "line": 71,
        "function": "cacheAndAppendCombineJsonIfExist",
        "class": "OC\\Template\\JSResourceLocator",
        "type": "->",
        "args": [
          "/var/www/nextcloud",
          "core/js/merged-template-prepend.json"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Template/ResourceLocator.php",
        "line": 78,
        "function": "doFind",
        "class": "OC\\Template\\JSResourceLocator",
        "type": "->",
        "args": [
          "js/merged-template-prepend"
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/TemplateLayout.php",
        "line": 374,
        "function": "find",
        "class": "OC\\Template\\ResourceLocator",
        "type": "->",
        "args": [
          [
            "core/js/dist/main",
            "js/dist/files_fileinfo",
            "js/dist/files_client",
            "js/merged-template-prepend",
            "core/l10n/de_DE",
            "And 6 more entries, set log level to debug to see all entries"
          ]
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/TemplateLayout.php",
        "line": 202,
        "function": "findJavascriptFiles",
        "class": "OC\\TemplateLayout",
        "type": "::",
        "args": [
          [
            "core/js/dist/main",
            "js/dist/files_fileinfo",
            "js/dist/files_client",
            "js/merged-template-prepend",
            "core/l10n/de_DE",
            "And 6 more entries, set log level to debug to see all entries"
          ]
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/legacy/OC_Template.php",
        "line": 182,
        "function": "__construct",
        "class": "OC\\TemplateLayout",
        "type": "->",
        "args": [
          "error",
          ""
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Template/Base.php",
        "line": 132,
        "function": "fetchPage",
        "class": "OC_Template",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/lib/private/legacy/OC_Template.php",
        "line": 331,
        "function": "printPage",
        "class": "OC\\Template\\Base",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/nextcloud/index.php",
        "line": 74,
        "function": "printExceptionErrorPage",
        "class": "OC_Template",
        "type": "::",
        "args": [
          {
            "__class__": "Exception"
          },
          500
        ]
      }
    ],
    "File": "/var/www/nextcloud/lib/private/Log/ErrorHandler.php",
    "Line": 92,
    "CustomMessage": "--"
  }
}
Third error in the logs
{
  "reqId": "abc",
  "level": 3,
  "time": "12-22-2021 10:07:52",
  "remoteAddr": "127.0.0.1",
  "user": "user",
  "app": "PHP",
  "method": "GET",
  "url": "/index.php/apps/cookbook/",
  "message": "Object of class Redis could not be converted to int at /var/www/nextcloud/lib/private/Lock/MemcacheLockingProvider.php#114",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.93 Safari/537.36 OPR/82.0.4227.33",
  "version": "22.2.3.0",
  "exception": {
    "Exception": "Error",
    "Message": "Object of class Redis could not be converted to int at /var/www/nextcloud/lib/private/Lock/MemcacheLockingProvider.php#114",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/lib/private/Lock/MemcacheLockingProvider.php",
        "line": 114,
        "function": "onError",
        "class": "OC\\Log\\ErrorHandler",
        "type": "::",
        "args": [
          8,
          "Object of class Redis could not be converted to int",
          "/var/www/nextcloud/lib/private/Lock/MemcacheLockingProvider.php",
          114,
          {
            "path": "files/dd1f08c3248f2c55d1af89480614146a",
            "type": 1,
            "ownSharedLockCount": 1,
            "newValue": {
              "__class__": "Redis"
            },
            "removed": false
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/lib/private/Lock/AbstractLockingProvider.php",
        "line": 120,
        "function": "releaseLock",
        "class": "OC\\Lock\\MemcacheLockingProvider",
        "type": "->",
        "args": [
          "files/dd1f08c3248f2c55d1af89480614146a",
          1
        ]
      },
      {
        "function": "releaseAll",
        "class": "OC\\Lock\\AbstractLockingProvider",
        "type": "->",
        "args": []
      }
    ],
    "File": "/var/www/nextcloud/lib/private/Log/ErrorHandler.php",
    "Line": 92,
    "CustomMessage": "--"
  }
}

@christianlupus
Copy link
Collaborator

Crossreference: I posted this question on the forum.

@christianlupus
Copy link
Collaborator

Is this issue still present?

@christianlupus christianlupus added the stalebot-enabled The PR/issue is marked to go stale over time label May 14, 2022
@github-actions
Copy link

This issue was not updated for 45 days. It is therefore marked as stale. When no update occurs within the next 7 days, this issue will be closed automatically in the next 7 days.

@github-actions github-actions bot added the stale The PR/issue is marked as stale label Jun 29, 2022
@github-actions
Copy link

github-actions bot commented Jul 6, 2022

This issue was not updated since it was marked as stale. It will be closed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backend Issue or PR related to the backend code bug Something isn't working stale The PR/issue is marked as stale stalebot-enabled The PR/issue is marked to go stale over time
Projects
None yet
Development

No branches or pull requests

3 participants