Closed olizimmermann closed 1 year ago
Wow, that worked for me too. Thanks all!!
@PVince81 now knowing that the culprit is the unencrypted_size
column makes it possible to check where things could go south, so I did a little digging:
lib/private/File/Cache/Cache.php
has the portion where folder sizes are calculated. I don't see a problem here really because regular size and unencrypted size are not mixed. However, there are multiple checks on unencrypted_size === 0
instead of checking if the file has encrypted !== 0
. But this is likely intended?
https://github.com/nextcloud/server/blob/master/lib/private/Files/Cache/Cache.php#L862-L936
lib/private/File/Cache/Propagator.php
propagates size changes when new files are uploaded. It has some logic towards the end that updates either size
or unencrypted_size
depending on whether the storage is Encryption::class
instance.
https://github.com/nextcloud/server/blob/master/lib/private/Files/Cache/Propagator.php#L117-L132
lib/private/Storage/Wrapper/Encryption.php
has some mentions, among others a recalculation of the size. All doesn't look interesting to this problem.
The few other places where this column is used do not look terribly interesting (FileInfo
, ChacheEntry
, tests).
I tried to understand all the encryption classes but didn't get too far.
Thanks a ton for debugging the issue @PVince81 and @JuliaKirschenheuter! Setting unencrypted_size=0
indeed fixes the issue for us.
But unfortunately the problem prevails even afterwards. When I delete a file from the homefolder of my testuser, the calculated quota size doesn't update. And looking into oc_filecache
I see new entries with unencrypted_size!=0
each time a file is deleted/added.
We indeed have the encryption app enabled but encryption disabled.
Is it save to assume that disabling the encryption app doesn't break anything when we don't have entries with encrypted!=0
in oc_filecache
? Or anything else to consider there?
update oc_filecache set unencrypted_size=0 where encrypted=0; it is working for me......need to disable default encryption & run the command, but all the files will not be readable anymore. Again, you can enable the default encryption module and then fix it. Thanks, it is a solution for the time being but it's a bug.
I run the following command for my user to ensure that unencrypted_size
is set to 0 on non encrypted file on the main storage:
update oc_filecache set unencrypted_size=0 where encrypted=0 and unencrypted_size!=0 and storage=(select numeric_id from oc_storages where id=1);
I then checked that this is correct by running the following request:
select storage, size, unencrypted_size, etag from oc_filecache where storage=1 and path='files';
whic returns:
storage | size | unencrypted_size | etag
---------+------------+------------------+---------------
1 | 6620645422 | 0 | 63cd2f3210742
After a couple of minutes, I rerun the same command and now the unencrypted_size
is again not 0:
storage | size | unencrypted_size | etag
---------+------------+------------------+---------------
1 | 6620645422 | 6620645502 | 63cd3d4950c52
The files with unencrypted_size
!= 0 are the following:
path | size | unencrypted_size
----------------------------------+------------+------------------
files/Nextcloud/Sync/Joplin | 5608590 | 5608599
files/Nextcloud/Sync/Joplin/temp | 45 | 54
files/Nextcloud | 1426060541 | 1426060550
files | 6620645422 | 6620645502
| 7018155246 | 7018155246
files/Nextcloud/Sync | 5608590 | 5608599
I am using Joplin (2.9.17). All the directory mentioned are used by Joplin for Sync.
I will continue to check this a on a regular basis to see if I can find anything else interesting.
Tools creating the issue:
Tools not creating the issue:
Other finding:
unencrypted_size
!= 0 (which might be normal due to bubble up of the information)The difference is quite huge. Server-side encryption is enabled. NC 25.0.3
The total size below the file list also includes shared-in folders that do not count towards your own user's quota. Might this explain the difference for you, @ppfeufer ?
No shared folders.
I have the same issue: quota usage reported by Nextcloud is greater than actual disk usage, and only increases.
sudo -u www-data php occ config:list system
``` { "system": { "instanceid": "***REMOVED SENSITIVE VALUE***", "passwordsalt": "***REMOVED SENSITIVE VALUE***", "secret": "***REMOVED SENSITIVE VALUE***", "cipher": "AES-256-CFB", "login_form_autocomplete": false, "trusted_domains": [ "***REMOVED SENSITIVE VALUE***" ], "datadirectory": "***REMOVED SENSITIVE VALUE***", "dbtype": "mysql", "version": "25.0.4.1", "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***", "htaccess.RewriteBase": "\/", "dbname": "***REMOVED SENSITIVE VALUE***", "dbhost": "***REMOVED SENSITIVE VALUE***", "dbport": "", "dbtableprefix": "oc_", "mysql.utf8mb4": true, "dbuser": "***REMOVED SENSITIVE VALUE***", "dbpassword": "***REMOVED SENSITIVE VALUE***", "installed": true, "enable_previews": true, "preview_max_x": 1024, "preview_max_y": 1024, "preview_max_scale_factor": 10, "enabledPreviewProviders": [ "OC\\Preview\\PNG", "OC\\Preview\\JPEG" ], "filelocking.enabled": true, "memcache.local": "\\OC\\Memcache\\Redis", "memcache.distributed": "\\OC\\Memcache\\Redis", "memcache.locking": "\\OC\\Memcache\\Redis", "redis": { "host": "***REMOVED SENSITIVE VALUE***", "port": "***REMOVED SENSITIVE VALUE***" }, "default_language": "en", "default_locale": "***REMOVED SENSITIVE VALUE***", "default_phone_region": "***REMOVED SENSITIVE VALUE***", "defaultapp": "dashboard,files", "knowledgebaseenabled": true, "skeletondirectory": "", "maintenance": false, "twofactor_enforced": true, "twofactor_enforced_groups": [ "***REMOVED SENSITIVE VALUE***" ], "twofactor_enforced_excluded_groups": [ "***REMOVED SENSITIVE VALUE***" ], "mail_from_address": "***REMOVED SENSITIVE VALUE***", "mail_smtpmode": "smtp", "mail_sendmailmode": "smtp", "mail_domain": "***REMOVED SENSITIVE VALUE***", "mail_smtphost": "***REMOVED SENSITIVE VALUE***", "mail_smtpsecure": "ssl", "mail_smtpport": "465", "mail_smtpauthtype": "LOGIN", "mail_smtpauth": 1, "mail_smtpname": "***REMOVED SENSITIVE VALUE***", "mail_smtppassword": "***REMOVED SENSITIVE VALUE***", "theme": "", "loglevel": 2, "logtimezone": "***REMOVED SENSITIVE VALUE***", "trashbin_retention_obligation": "auto, 180", "versions_retention_obligation": "auto", "updater.release.channel": "stable", "data-fingerprint": "***REMOVED SENSITIVE VALUE***", "connectivity_check_domains": [ "www.eff.org", "www.nextcloud.com" ], "quota_include_external_storage": false } } ```
sudo -u www-data php occ app:list
``` Enabled: - activity: 2.17.0 - admin_audit: 1.15.0 - announcementcenter: 6.5.1 - bookmarks: 12.1.0 - bruteforcesettings: 2.5.0 - calendar: 4.2.4 - checksum: 1.2.0 - circles: 25.0.0 - cloud_federation_api: 1.8.0 - comments: 1.15.0 - contacts: 5.0.3 - contactsinteraction: 1.6.0 - dashboard: 7.5.0 - dav: 1.24.0 - drop_account: 2.1.0 - encryption: 2.13.0 - external: 5.0.2 - federatedfilesharing: 1.15.0 - federation: 1.15.0 - files: 1.20.1 - files_accesscontrol: 1.15.1 - files_antivirus: 4.0.2 - files_automatedtagging: 1.15.2 - files_external: 1.17.0 - files_pdfviewer: 2.6.0 - files_rightclick: 1.4.0 - files_sharing: 1.17.0 - files_trashbin: 1.15.0 - files_versions: 1.18.0 - fileslibreofficeedit: 1.1.0 - firstrunwizard: 2.14.0 - forms: 3.2.0 - gpoddersync: 3.7.3 - guests: 2.3.0 - impersonate: 1.12.0 - integration_github: 1.0.15 - integration_gitlab: 1.0.12 - integration_mastodon: 1.0.6 - integration_reddit: 1.0.7 - logreader: 2.10.0 - lookup_server_connector: 1.13.0 - news: 21.0.0 - nextcloud_announcements: 1.14.0 - notifications: 2.13.1 - oauth2: 1.13.0 - password_policy: 1.15.0 - photos: 2.0.1 - polls: 4.1.8 - privacy: 1.9.0 - provisioning_api: 1.15.0 - quicknotes: 0.8.5 - quota_warning: 1.15.0 - ransomware_protection: 1.14.0 - recommendations: 1.4.0 - related_resources: 1.0.4 - richdocuments: 7.1.1 - richdocumentscode: 22.5.802 - serverinfo: 1.15.0 - settings: 1.7.0 - sharebymail: 1.15.0 - side_menu: 3.7.0 - support: 1.8.0 - survey_client: 1.13.0 - systemtags: 1.15.0 - tasks: 0.14.5 - text: 3.6.0 - theming: 2.0.1 - twofactor_admin: 4.1.9 - twofactor_backupcodes: 1.14.0 - twofactor_totp: 7.0.0 - updatenotification: 1.15.0 - user_status: 1.5.0 - viewer: 1.9.0 - weather_status: 1.5.0 - workflowengine: 2.7.0 Disabled: - suspicious_login: 4.1.0 - user_ldap ```
I'm not sure if the following error is related, but it is flooding my Logging app.
``` {"reqId":"***REMOVED SENSITIVE VALUE***","level":3,"time":"***REMOVED SENSITIVE VALUE***","remoteAddr":"***REMOVED SENSITIVE VALUE***","user":"--","app":"no app in context","method":"GET","url":"/.env","message":"App encryption threw an error during app.php load: No mount for path /files_encryption/OC_DEFAULT_MODULE/pubShare_8c08540b.publicKey existing mounts: ","userAgent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.129 Safari/537.36","version":"25.0.4.1","exception":{"Exception":"OCP\\Files\\NotFoundException","Message":"No mount for path /files_encryption/OC_DEFAULT_MODULE/pubShare_8c08540b.publicKey existing mounts: ","Code":0,"Trace":[{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Files/Filesystem.php","line":320,"function":"find","class":"OC\\Files\\Mount\\Manager","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Files/View.php","line":1166,"function":"resolvePath","class":"OC\\Files\\Filesystem","type":"::"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Files/View.php","line":546,"function":"basicOperation","class":"OC\\Files\\View","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Encryption/Keys/Storage.php","line":269,"function":"file_exists","class":"OC\\Files\\View","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Encryption/Keys/Storage.php","line":229,"function":"getKey","class":"OC\\Encryption\\Keys\\Storage","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Encryption/Keys/Storage.php","line":121,"function":"getKeyWithUid","class":"OC\\Encryption\\Keys\\Storage","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/apps/encryption/lib/KeyManager.php","line":614,"function":"getSystemUserKey","class":"OC\\Encryption\\Keys\\Storage","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/apps/encryption/lib/KeyManager.php","line":170,"function":"getPublicShareKey","class":"OCA\\Encryption\\KeyManager","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/apps/encryption/lib/Users/Setup.php","line":62,"function":"validateShareKey","class":"OCA\\Encryption\\KeyManager","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/apps/encryption/lib/AppInfo/Application.php","line":55,"function":"setupSystem","class":"OCA\\Encryption\\Users\\Setup","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/apps/encryption/appinfo/app.php","line":37,"function":"setUp","class":"OCA\\Encryption\\AppInfo\\Application","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/legacy/OC_App.php","line":306,"args":["***REMOVED SENSITIVE VALUE***/nextcloud/apps/encryption/appinfo/app.php"],"function":"require_once"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/legacy/OC_App.php","line":187,"function":"requireAppFile","class":"OC_App","type":"::"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/legacy/OC_App.php","line":141,"function":"loadApp","class":"OC_App","type":"::"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Files/SetupManager.php","line":132,"function":"loadApps","class":"OC_App","type":"::"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Files/SetupManager.php","line":340,"function":"setupBuiltinWrappers","class":"OC\\Files\\SetupManager","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Files/SetupManager.php","line":380,"function":"setupRoot","class":"OC\\Files\\SetupManager","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Files/Mount/Manager.php","line":95,"function":"setupForPath","class":"OC\\Files\\SetupManager","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Files/View.php","line":1390,"function":"find","class":"OC\\Files\\Mount\\Manager","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Files/Node/Root.php","line":205,"function":"getFileInfo","class":"OC\\Files\\View","type":"->"},{"function":"get","class":"OC\\Files\\Node\\Root","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Files/Node/LazyFolder.php","line":72,"function":"call_user_func_array"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Files/Node/LazyFolder.php","line":149,"function":"__call","class":"OC\\Files\\Node\\LazyFolder","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Files/AppData/AppData.php","line":132,"function":"get","class":"OC\\Files\\Node\\LazyFolder","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Template/JSCombiner.php","line":88,"function":"getFolder","class":"OC\\Files\\AppData\\AppData","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Template/JSResourceLocator.php","line":125,"function":"process","class":"OC\\Template\\JSCombiner","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Template/JSResourceLocator.php","line":77,"function":"cacheAndAppendCombineJsonIfExist","class":"OC\\Template\\JSResourceLocator","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Template/ResourceLocator.php","line":78,"function":"doFind","class":"OC\\Template\\JSResourceLocator","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/TemplateLayout.php","line":379,"function":"find","class":"OC\\Template\\ResourceLocator","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/TemplateLayout.php","line":211,"function":"findJavascriptFiles","class":"OC\\TemplateLayout","type":"::"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/legacy/OC_Template.php","line":184,"function":"__construct","class":"OC\\TemplateLayout","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":"OC_Template","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/base.php","line":817,"function":"printPage","class":"OC\\Template\\Base","type":"->"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/base.php","line":1144,"function":"init","class":"OC","type":"::"},{"file":"***REMOVED SENSITIVE VALUE***/nextcloud/index.php","line":34,"args":["***REMOVED SENSITIVE VALUE***/nextcloud/lib/base.php"],"function":"require_once"}],"File":"***REMOVED SENSITIVE VALUE***/nextcloud/lib/private/Files/Mount/Manager.php","Line":118,"message":"App encryption threw an error during app.php load: No mount for path /files_encryption/OC_DEFAULT_MODULE/pubShare_8c08540b.publicKey existing mounts: ","CustomMessage":"App encryption threw an error during app.php load: No mount for path /files_encryption/OC_DEFAULT_MODULE/pubShare_8c08540b.publicKey existing mounts: "},"id":"***REMOVED SENSITIVE VALUE***"} ```
Thank you!
For cases where encryption is enabled (or was previously enabled) , applying https://github.com/nextcloud/server/pull/36857 and running occ files:scan
should resolve the issue
For anyone still facing the same issue even after applying the fix in #36857, you can try this steps: *Try at your own risk, I am not a developer or expert in this matter.
USE nextcloud;
SELECT path, name, size, encrypted, unencrypted_size FROM oc_filecache WHERE encrypted = 0 AND unencrypted_size != 0;
This will show you the files that are read twice as the column unencryptrd_size has some value causing it to be added twice to the occupied space calculation (quota calculation).UPDATE oc_filecache SET unencrypted_size = 0 WHERE encrypted = 0;
WARNING! only use this commend if you have already disabled server side encryption using the steps mentioned in the offical administrator's guide provided by nextcloud.
This should start showing you the correct quota used. If it doesn't, just clear the cache of the browser or give it some time. Altough this is not a permanent fix but works for the time being as you only have to use the command in step 4 to fix this next time.For anyone working on this bug I have found a few things which migth help. Even after disabling the server side encryption, 'unencrypted_size' is written during the upload of the file. To verify this you could upload a file (around 500 MB for testing) and run the command mentioned in 3 step while the file is being uploaded. This happens on upload from any device meaning even when your phone or laptop auto upload things. And also if you restore any file after applying the fix mentioned above the system again writes the size of that file in both columns 'size' and encrypted_size'.
This is what I have dicovered today with the help of ChatGPT. Please let me know if this was helpful.
Congratulations to ChatGPT, that was able to find a post in the same ticket just a few pages up... :)
Is this fixed in a known release?
Is this fixed in a known release?
The fix related to unencrypted_size
is in 27. Backport to 26 did not make it into the latest 26 release: https://github.com/nextcloud/server/pull/38555
Given that this was mainly about instances with encryption is enabled, let's close this issue as fixed in https://github.com/nextcloud/server/pull/36857.
If anyone still encounters issues with wrong quota calculation (on Nextcloud 27 or newer), please open a new issue about it.
@mejo- I confirm that the issue is not reproducible with NC 27.
Any plans to backport this to Nextcloud 25?
@icewind1991 Is the fix in https://github.com/nextcloud/server/pull/36857 safe to apply to an instance running 25.0.9? Thanks 🫠
How to use GitHub
Steps to reproduce
Expected behaviour
Tell us what should happen Should be 1:1 like all my other users.
Actual behaviour
Tell us what happens instead Real used storage: 9.3 Gb Nextcloud shows me: 18.2
Server configuration
Operating system: FreeBsd Web server: Nginx Database:
PHP version: 7.04 Nextcloud version: (see Nextcloud admin page) 20.0.5 Updated from an older Nextcloud/ownCloud or fresh install:
Where did you install Nextcloud from: TrueNas - Plugin - latest Update via Updater Signing status:
Signing status
``` Login as admin user into your Nextcloud and access http://example.com/index.php/settings/integrity/failed paste the results here. ``` No errors have been found.List of activated apps:
App list
Notes, Decks, Tasks ``` If you have access to your command line run e.g.: sudo -u www-data php occ app:list from within your Nextcloud installation folder ``` ---Nextcloud configuration:
Config report
``` If you have access to your command line run e.g.: sudo -u www-data php occ config:list system from within your Nextcloud installation folder or Insert your config.php content here. Make sure to remove all sensitive content such as passwords. (e.g. database password, passwordsalt, secret, smtp password, …) ``` CONFIG = array ( 'apps_paths' => array ( 0 => array ( 'path' => '/usr/local/www/nextcloud/apps', 'url' => '/apps', 'writable' => true, ), 1 => array ( 'path' => '/usr/local/www/nextcloud/apps-pkg', 'url' => '/apps-pkg', 'writable' => true, ), ), 'logfile' => '/var/log/nextcloud/nextcloud.log', 'passwordsalt' => 'XXXXX', 'secret' => 'XXXXX', 'trusted_domains' => array ( 0 => 'localhost', ), 'datadirectory' => '/usr/local/www/nextcloud/data', 'dbtype' => 'mysql', 'version' => '20.0.5.2', 'overwrite.cli.url' => 'http://localhost', 'overwriteprotocol' => 'https', 'dbname' => 'nextcloud', 'dbhost' => 'localhost', 'dbport' => '', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'XXX', 'dbpassword' => 'XXX', 'installed' => true, 'instanceid' => 'XXX', 'twofactor_enforced' => 'false', 'twofactor_enforced_groups' => array ( 0 => 'admin', ), 'twofactor_enforced_excluded_groups' => array ( ), 'mail_smtpmode' => 'smtp', 'mail_sendmailmode' => 'smtp', 'mail_domain' => 'gmail.com', 'mail_smtphost' => 'smtp.gmail.com', 'mail_smtpport' => '587', 'mail_smtpsecure' => 'tls', 'mail_smtpauthtype' => 'LOGIN'..Are you using external storage, if yes which one: local/smb/sftp/... No Are you using encryption: yes/no No Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/... No
LDAP configuration (delete this part if not used)
LDAP config
``` With access to your command line run e.g.: sudo -u www-data php occ ldap:show-config from within your Nextcloud installation folder Without access to your command line download the data/owncloud.db to your local computer or access your SQL server remotely and run the select query: SELECT * FROM `oc_appconfig` WHERE `appid` = 'user_ldap'; Eventually replace sensitive data as the name/IP-address of your LDAP server or groups. ```Client configuration
Browser: all / also in app Operating system:
Logs
Web server error log
Web server error log
``` Insert your webserver log here ```Nextcloud log (data/nextcloud.log)
Nextcloud log
``` Insert your Nextcloud log here ```Shell:
Online: