core icon indicating copy to clipboard operation
core copied to clipboard

Files on External storage (SMB) keep on downloading repeatedly

Open caguiar opened this issue 11 years ago • 27 comments

I reported this problem in the client issues and was asked to re-open here: https://github.com/owncloud/client/issues/3581

ownCloud Client: 1.8.4 (Mac OS) ownCloud Server: 8.1.0 Server OS: uBuntu Server 14.04.2 LTS

Lately (I would say since the upgrade of ownCloud server to 8.1) my desktop client repeatedly downloads files which are on my desktop already. It seems that for no particular reason it just downloads all the files (and subfolders) of a particular folder. This seems to happen only with files/folders which reside on SMB shares that are configured as External storage.

Another symptom is, for instance, a file which I just put in the client folder, the client uploads to the server and a few minutes later gets downloaded (replacing the file which was initially put there). Also because of this I now get a lot of "conflicts" on files I am working on the client side.

If you require any further details, please let me know.

caguiar avatar Aug 11 '15 16:08 caguiar

can you pleae post a full bug report using the issue template please? thanks a lot.

karlitschek avatar Aug 12 '15 00:08 karlitschek

Is there a timezone difference between the SMB mount and the OC server ? Are the times in sync ? Are you using the SMB mount exclusively through ownCloud or also outside of ownCloud ?

PVince81 avatar Aug 12 '15 08:08 PVince81

Answering questions of PVince81.

  1. Is there a timezone difference between the SMB mount and the OC server? No, as you can see from output bellow.

The SMB server: hera:~$ cat /etc/timezone Europe/Lisbon hera:~$ date Fri Aug 14 15:46:49 WEST 2015

The ownCloud Sever: azevinho:~$ cat /etc/timezone Europe/Lisbon azevinho:~$ date Fri Aug 14 15:46:12 WEST 2015

  1. Are the times in sync ? They are in sync, i.e. both servers use ntp server, however they where using different sources. I have now changed so that the owncloud ntp server syncs from the SMB server.

  2. Are you using the SMB mount exclusively through ownCloud or also outside of ownCloud? Not using exclusively through owncloud, they are SMB shares also used directly from PCs.

caguiar avatar Aug 14 '15 15:08 caguiar

Used the issue template as requested:

Steps to reproduce

Files on a folder which resides on External Storage get downloaded even though they are up to date, and these are the symptoms I detected.

Symptom 1

  1. Look at the ownClient sync activity
  2. Lots of files get downloaded even though files exist in the client and are up to date

Symptom 2

  1. Create a new file on the client PC
  2. The file gets uploaded
  3. The file gets downloaded

Symptom 3

  1. Create a new file on the client PC, example test.txt
  2. The file gets uploaded
  3. Edit the file and save (do this one or two times)
  4. After a while conflict files appear, example test_conflict-20150818-115220.txt

Expected behaviour

Symptom 1 Files should not download if they are up to date.

Symptom 2 The file should not download since if it is up to date.

Symptom 3 There should not be a conflict since the files on the client are newer, so they should just be uploaded.

Server configuration

Operating system: uBuntu Server 14.04.2 LTS Web server: Apache 2 (v. 2.4.7) Database: MySQL (v. 5.5.44) PHP version: 5.5.9 ownCloud version: 8.1.1

Updated from an older ownCloud or fresh install: updated

List of activated apps: $ sudo -u www-data php occ app:list Enabled:

  • activity: 2.0.1
  • files: 1.1.10
  • files_external: 0.2.3
  • files_pdfviewer: 0.7
  • files_sharing: 0.6.2
  • files_texteditor: 0.4
  • files_trashbin: 0.6.3
  • files_versions: 1.0.6
  • files_videoviewer: 0.1.3
  • firstrunwizard: 1.1
  • gallery: 0.6.0
  • user_ldap: 0.6.1 Disabled:
  • encryption
  • external
  • files_locking
  • provisioning_api
  • templateeditor
  • user_external
  • user_webdavauth

The content of config/config.php: $ cat config.php

'oc4d0cd5ee97', 'passwordsalt' => '', 'datadirectory' => '/var/www/owncloud/data', 'dbtype' => 'mysql', 'version' => '8.1.1.3', 'dbname' => 'owncloud', 'dbhost' => 'localhost', 'dbtableprefix' => 'oc_', 'dbuser' => 'oc_admin', 'dbpassword' => '', 'installed' => true, 'loglevel' => '3', 'ldapIgnoreNamingRules' => false, 'theme' => '', 'maintenance' => false, 'trusted_domains' => array ( 0 => 'owncloud.arditi.pt', ), 'mail_domain' => 'arditi.pt', 'mail_smtpmode' => 'php', 'mail_from_address' => 'owncloud', 'secret' => '', ); Are you using external storage, if yes which one: smb Are you using encryption: no Are you using an external user-backend, if yes which one: LDAP LDAP configuration: $ sudo -u www-data php occ ldap:show-config +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ | Configuration | s01 | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ | hasMemberOfFilterSupport | 1 | | hasPagedResultSupport | | | homeFolderNamingRule | | | lastJpegPhotoLookup | 0 | | ldapAgentName | cn=LDAP user,cn=Users,DC=arditi,DC=pt | | ldapAgentPassword | **\* | | ldapAttributesForGroupSearch | | | ldapAttributesForUserSearch | | | ldapBackupHost | | | ldapBackupPort | | | ldapBase | DC=arditi,DC=pt | | ldapBaseGroups | OU=Groups,DC=arditi,DC=pt | | ldapBaseUsers | cn=Users,DC=arditi,DC=pt | | ldapCacheTTL | 600 | | ldapConfigurationActive | 1 | | ldapEmailAttribute | | | ldapExperiencedAdmin | 0 | | ldapExpertUUIDGroupAttr | | | ldapExpertUUIDUserAttr | | | ldapExpertUsernameAttr | | | ldapGroupDisplayName | cn | | ldapGroupFilter | (&(|(objectclass=group))(|(cn=sg-ARDITI)(cn=sg-Atividades)(cn=sg-CA)(cn=sg-DAF)(cn=sg-DPI)(cn=sg-Informatica)(cn=sg-RH)(cn=sg-Secretariado))) | | ldapGroupFilterGroups | sg-ARDITI;sg-Atividades;sg-CA;sg-DAF;sg-DPI;sg-Informatica;sg-RH;sg-Secretariado | | ldapGroupFilterMode | 0 | | ldapGroupFilterObjectclass | group | | ldapGroupMemberAssocAttr | member | | ldapHost | 192.168.6.230 | | ldapIgnoreNamingRules | | | ldapLoginFilter | (&(&(|(objectclass=person))(|(memberof=CN=sg-OwnCloud,OU=Groups,DC=arditi,DC=pt)))(samaccountname=%uid)) | | ldapLoginFilterAttributes | | | ldapLoginFilterEmail | 0 | | ldapLoginFilterMode | 0 | | ldapLoginFilterUsername | 1 | | ldapNestedGroups | 0 | | ldapNoCase | 0 | | ldapOverrideMainServer | 0 | | ldapPagingSize | 500 | | ldapPort | 389 | | ldapQuotaAttribute | | | ldapQuotaDefault | | | ldapTLS | 0 | | ldapUserDisplayName | displayname | | ldapUserFilter | (&(|(objectclass=person))(|(memberof=CN=sg-OwnCloud,OU=Groups,DC=arditi,DC=pt))) | | ldapUserFilterGroups | sg-OwnCloud | | ldapUserFilterMode | 0 | | ldapUserFilterObjectclass | person | | ldapUuidGroupAttribute | auto | | ldapUuidUserAttribute | auto | | turnOffCertCheck | 0 | | useMemberOfToDetectMembership | 1 | +-------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------+ ### Client configuration Desktop Client version: 1.8.4 Operating system: Mac OSX 10.10 and Linux (Gentoo) ### Logs #### ownCloud log (data/owncloud.log) I did $ tail -f owncloud.log while I was doing the tests (SYMPTOMS 1 to 3 above) and nothing got displayed

caguiar avatar Aug 18 '15 11:08 caguiar

@caguiar Thanks for the details.

So if the file is redownloaded directly after upload, it means that there must be an etag mismatch. Whenever the sync client tries to find out whether the file has changed, it notices that the remote etag isn't the same as the time where it was uploaded.

It is still not clear what could be causing that.

Something to try: pick an SMB storage for testing and then set the option "Check for changes" to "Never". Then try uploading a file again. When you're done testing, make sure to set it back to "Once every direct access" to make sure it can still detect remote changes (changes done on the SMB mount outside of ownCloud).

Let us know if the redownload still happens when the option is set to "Never".

@icewind1991 how to find out whether SMB is using libsmbclient or smbclient ? I'd like @caguiar to check this to find out which implementation is being used.

PVince81 avatar Aug 18 '15 12:08 PVince81

One symptom I forgot to mention on my previous post: Symptom 4

  1. Delete a file on the client PC
  2. File gets downloaded back to the client

(actually sometimes to get rid of a file I have to delete it several times)

caguiar avatar Aug 18 '15 13:08 caguiar

@PVince81 I tried what you mentioned, that is, on the same SMB storage I used for testing, I set the option "Check for changes" to "Never", none of the 4 symptoms I reported happened. No symptom 1: no files get downloaded out of the blue. No symptom 2: the created file does not get redownloaded No symptom 3: when I edit the file, no conflict files get created No symptom 4: when I delete the file, it goes away (does not get redownloaded)

caguiar avatar Aug 18 '15 13:08 caguiar

Aha, interesting.

So this means that it's the file scanner that mistakenly believes that the remote file has changed. I know that you already synchronized the timestamps but there still seems to be something making it detect changes even though there aren't.

@icewind1991 any idea ?

PVince81 avatar Aug 18 '15 13:08 PVince81

Maybe timezone or clock differences between the smb and oc servers

icewind1991 avatar Aug 18 '15 13:08 icewind1991

@icewind1991 already suggested here https://github.com/owncloud/core/issues/18214#issuecomment-131145043

PVince81 avatar Aug 18 '15 13:08 PVince81

As written here I'm having the same issue. Apart from "random" up-/downloads I noticed that a) the whole folder gets uploaded if only one of the files gets changed (the "etag" in the database changes as well) and b) the same file gets downloaded again (as a result e.g. the Mac text editor complains that someone else has changed the file in the meantime and asks if you want to overwrite these changes... annoying!).

There are no time (zone) differences in my setup as the SMB and OC are running on the same server.

rawbertl avatar Aug 27 '15 17:08 rawbertl

I have also another symptom in my own setup: host: Ubuntu 15.10, owncloud 8.2.0, synchronizing to Zyxel NAS 325v2 over Samba client: Windows 10, owncloud version 2.0.2 build 5569 Zyxel NAS, host and client are all on the same timezone, and their time is updated though NTP. Amount of data synchronized to external storage: 14.1 GB in 2225 files, 243 folders

When I store a new file to client, it gets uploaded to Samba drive after appx 15-20 minutes of waiting. This waiting is due to client all the time downloading and uploading the same, unchanged, files back and forth to host.

After the new file has appeared on Zyxel NAS box, it takes a few minutes and the same file gets downloaded back to client.

This ping-pong effect can be easily seen on both NAS box and client, as file timestamps are constantly being updated.

ktuulos avatar Nov 18 '15 10:11 ktuulos

Are you using the SMB storage outside of ownCloud ? If not, you can change the mount options for the mount point and set "Check fo changes" to "Never". That's only a workaround though.

It doesn't explain why it would detect files as changed on the SMB.

PVince81 avatar Nov 18 '15 10:11 PVince81

Yes, the same SMB storage is used outside of ownClud, with many clients, from many operating systems. But for this current test, SMB storage was not write-accessed by anyone else than ownCloud, meaning files were not changed. I also took MD5SUM of files from client's directory, both before and after ping-pong effect, and it was a proof that files were binary identical.

ktuulos avatar Nov 18 '15 10:11 ktuulos

The update detection doesn't use the contents but the mtime of the folders.

Every time the SMB storage is accessed, it calls a method hasUpdated which will check if the mtime that is in the database (storage_mtime) is different than the one returned for the root of the SMB storage. If they are different, it will assume that it changed. Same happens for subdirectories.

PVince81 avatar Nov 18 '15 10:11 PVince81

OK, then this is just a bug in core ownCloud behaviour - it should not rely just on mtime to detect, whether files have been changed.

ktuulos avatar Nov 18 '15 10:11 ktuulos

@ktuulos there is no other way unfortunately. Downloading the contents every time is a no go (for checksum).

The mtime approach already works, not sure why it doesn't in your environment.

PVince81 avatar Nov 18 '15 10:11 PVince81

Something to try: pick a folder that gets redownloaded often. Let's call it "folder"

Check it: select * from oc_storages, find the numeric_id of your SMB storage.

Then do select * from oc_filecache where storage=$numeric_id and path='%folder%'. Replace $numeric_id with the one from before. Check the "storage_mtime" column, copy the value. For example "1417696735" Run date -d @1417696735 with the timestamp to get a human-readable timestamp.

Then run smbclient '\\host\sharename' against your SMB storage, and type "stat folder" for the folder in question. It will show you some timestamps.

The timestamps must be the same. If they are different, then it might explain why the folder gets detected as changed.

PVince81 avatar Nov 18 '15 10:11 PVince81

I am having the same problem on my setup, and am looking for more on this issue. I have checked the servers and they seem to have the same time. Following the instructions here, I've got the following for a test file:

$ date -d @1449184517 Thu Dec 3 16:15:17 MST 2015

as the file listing in smbclient: file1 N 14 Thu Dec 3 16:15:16 2015

The timestamps are 1 second apart. Is this the cause? Not sure what would cause this difference as all fo the owncloud server, the file server, and my client appear to be running the same time. Note that this behaviour did not occur prior to version 8 on the same systems.

mlwruble avatar Dec 04 '15 20:12 mlwruble

On further testing, I have noticed that there is a condition where these times are out of sync!

As I save a new version of the file, if the existing timestamps are the same, then the file does upload properly. Unfortunately, at this point the timestamps become different, where the oc database retains the old timestamp, the server gets the new timestamp.

When I save another new version of the file, then prior to uploading, owncloud initiates a file sync, but instead of uploading the new version, it renames the new version as the conflicting file, and downloads the old version as current.

So it seems that the problem occurs because the oc_filecache storage time doesn't get updated when a version of the file is synced/uploaded. The question is, why does this not get updated?

The following shows the state after a successful upload sync. smb: \users\mlwruble\test> ls . D 0 Fri Dec 4 15:11:56 2015 .. D 0 Fri Dec 4 15:11:56 2015 file1 A 24 Fri Dec 4 15:11:56 2015

select select fileid, path, storage_mtime from oc_filecache where storage =39 and path like '%file1%'; +---------+---------------------------+---------------+ | fileid | path | storage_mtime | +---------+---------------------------+---------------+ | 3147160 | Users/mlwruble/test/file1 | 1449264510 | +---------+---------------------------+---------------+

$ date -d @1449264510 Fri Dec 4 14:28:30 MST 2015

mlwruble avatar Dec 04 '15 22:12 mlwruble