core icon indicating copy to clipboard operation
core copied to clipboard

Files on external SMB storage keep reloading repeatedly.

Open ktuulos opened this issue 10 years ago • 20 comments

I'm reporting this bug, as it was asked to be re-opened in case the bug still exists. The old bug is here: https://github.com/owncloud/core/issues/18214

Steps to reproduce

  1. Mount Samba drive using External storage module as SMB/CIFS, using log-in credentials.
  2. Client is installed to Windows computer, there are no existing files.
  3. After all files from external Samba drive have been synchronized to Windows client, the ownCloud client gives following warning box: Backup detected This sync would reset the files to an earlier time in the sync folcer "....". This might be because a backup was restored on the server ..... Selection given: Keep Local Files as Conflict or Normal Synchronization. --> Normal Synchronization selected, synchronization continues.
    1. Step 3 repeates again and again, many times.

Expected behaviour

Files should be synchronized just once

Actual behaviour

Files keep re-synchronizing again and again

Server configuration

Operating system: Ubuntu 16.04.01 LTS

ownCloud server: 9.1 ownCloud client: Windows 10, Version 2.2.3 build 6307 External storage support module 0.6.0

Web server: Apache 2.4.18

Database: MariaDB 10.0

PHP version: 7.0

ownCloud version: (see ownCloud admin page) 9.1.0-1.1

Updated from an older ownCloud or fresh install: Fresh install

Where did you install ownCloud from: apt-get from owncloud's own repository

Signing status (ownCloud 9.0 and above):

No errors have been found.

List of activated apps:

kalle@XXXX:/var/www/owncloud$ sudo -u www-data php occ app:list Enabled:

  • activity: 2.3.2
  • comments: 0.3.0
  • dav: 0.2.5
  • federatedfilesharing: 0.3.0
  • federation: 0.1.0
  • files: 1.5.1
  • files_external: 0.6.0
  • files_pdfviewer: 0.8.1
  • files_sharing: 0.10.0
  • files_texteditor: 2.1
  • files_trashbin: 0.9.0
  • files_versions: 1.3.0
  • files_videoplayer: 0.9.8
  • firstrunwizard: 1.1
  • gallery: 15.0.0
  • notifications: 0.3.0
  • provisioning_api: 0.5.0
  • systemtags: 0.3.0
  • templateeditor: 0.1
  • updatenotification: 0.2.1 Disabled:
  • encryption
  • external
  • files_antivirus
  • user_external
  • user_ldap

The content of config/config.php: kalle@XXXX:/var/www/owncloud$ sudo -u www-data php occ config:list system { "system": { "updatechecker": false, "instanceid": "oce2bi3eqqh1", "passwordsalt": "_REMOVED SENSITIVE VALUE", "secret": "_REMOVED SENSITIVE VALUE", "trusted_domains": [ "localhost", "XXX", "XXXX" ], "datadirectory": "/var/www/owncloud/data", "overwrite.cli.url": "http://localhost/owncloud", "dbtype": "mysql", "version": "9.1.0.15", "dbname": "owncloud", "dbhost": "localhost", "dbtableprefix": "oc_", "dbuser": "_REMOVED SENSITIVE VALUE", "dbpassword": "_REMOVED SENSITIVE VALUE", "logtimezone": "UTC", "installed": true, "mail_smtpmode": "sendmail", "mail_from_address": "owncloud", "mail_domain": "XXXXXX", "memcache.local": "\OC\Memcache\Redis", "memcache.locking": "\OC\Memcache\Redis", "redis": { "host": "localhost", "port": 6379 } } }

Are you using external storage, if yes which one: local/smb/sftp/... smb

Are you using encryption: yes/no no

Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/... no

Client configuration

Browser: N/A

Operating system: Windows 10 64bit

Logs

Web server error log

[Thu Sep 08 19:11:13.414018 2016] [authz_core:error] [pid 20028] [client XX.XX.XX.XX:53381] AH01630: client denied by server configuration: /var/www/owncloud/data/htaccesstest.txt [Thu Sep 08 19:13:37.592757 2016] [authz_core:error] [pid 20936] [client XX.XX.XX.XX:53504] AH01630: client denied by server configuration: /var/www/owncloud/data/htaccesstest.txt [Thu Sep 08 19:14:45.818804 2016] [authz_core:error] [pid 2964] [client XX.XX.XX.XX:53524] AH01630: client denied by server configuration: /var/www/owncloud/data/htaccesstest.txt [Thu Sep 08 19:16:15.814746 2016] [authz_core:error] [pid 20944] [client XX.XX.XX.XX:53563] AH01630: client denied by server configuration: /var/www/owncloud/data/htaccesstest.txt [Thu Sep 08 20:02:59.757969 2016] [authz_core:error] [pid 1109] [client XX.XX.XX.XX:51230] AH01630: client denied by server configuration: /var/www/owncloud/data/htaccesstest.txt [Thu Sep 08 20:23:02.516618 2016] [authz_core:error] [pid 989] [client XX.XX.XX.XX:51560] AH01630: client denied by server configuration: /var/www/owncloud/data/htaccesstest.txt [Thu Sep 08 20:24:41.227324 2016] [authz_core:error] [pid 19171] [client XX.XX.XX.XX:51628] AH01630: client denied by server configuration: /var/www/owncloud/data/htaccesstest.txt [Thu Sep 08 20:25:40.964995 2016] [mpm_prefork:notice] [pid 7946] AH00169: caught SIGTERM, shutting down [Thu Sep 08 20:28:27.522573 2016] [authz_core:error] [pid 21990] [client XX.XX.XX.XX:51758] AH01630: client denied by server configuration: /var/www/owncloud/data/htaccesstest.txt [Thu Sep 08 20:28:59.158980 2016] [authz_core:error] [pid 21990] [client XX.XX.XX.XX:51772] AH01630: client denied by server configuration: /var/www/owncloud/data/htaccesstest.txt [Thu Sep 08 23:23:03.938630 2016] [authz_core:error] [pid 23303] [client XX.XX.XX.XX:55212] AH01630: client denied by server configuration: /var/www/owncloud/data/htaccesstest.txt [Thu Sep 08 23:37:31.395124 2016] [autoindex:error] [pid 23303] [client XX.XX.XX.XX:55389] AH01276: Cannot serve directory /var/www/owncloud/core/doc/user/_static/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive, referer: https://YYYYY/owncloud/core/doc/user/index.html [Thu Sep 08 23:39:39.752964 2016] [authz_core:error] [pid 20522] [client XX.XX.XX.XX:55439] AH01630: client denied by server configuration: /var/www/owncloud/data/htaccesstest.txt [Thu Sep 08 23:41:34.781667 2016] [authz_core:error] [pid 5874] [client XX.XX.XX.XX:55505] AH01630: client denied by server configuration: /var/www/owncloud/data/htaccesstest.txt

ownCloud log (data/owncloud.log)

{"reqId":"JWdPKMTLWZg7hzb6BrR+","remoteAddr":"XX.XX.XX.XX","app":"PHP","message":"Undefined offset: 1 at /var/www/owncloud/core/Controller/LoginController.php#117","level":3,"time":"2016-09-08T17:02:41+00:00","method":"GET","url":"/owncloud/index.php/login?user=kalle","user":"--"} {"reqId":"JWdPKMTLWZg7hzb6BrR+","remoteAddr":"XX.XX.XX.XX","app":"PHP","message":"Invalid argument supplied for foreach() at /var/www/owncloud/core/templates/login.php#23","level":3,"time":"2016-09-08T17:02:41+00:00","method":"GET","url":"/owncloud/index.php/login?user=kalle","user":"--"}

Browser log

N/A

ktuulos avatar Sep 08 '16 21:09 ktuulos

Backup detected

@guruz is that the new feature about restore detection with the fingerprint ? CC @jvillafanez

@ktuulos can you confirm that you didn't restore your OC from backup just now ?

PVince81 avatar Sep 09 '16 07:09 PVince81

Confirmed - the backup feature was not used.

ktuulos avatar Sep 09 '16 07:09 ktuulos

Same issue here with SMB storage, no backup used.

rawbertl avatar Sep 09 '16 10:09 rawbertl

Could you check the mtime of the file / folder / share using smbclient? Maybe the servers aren't synchronized and the mtime that the SMB server reports is different than the one expected.

In addition, please provide the version of the desktop client you're using because it might be involved.

jvillafanez avatar Sep 12 '16 12:09 jvillafanez

I think I could if I knew what file(s) is/are causing the problem - where would I get that information from?

BTW, OC and smbd are running on the same machine, hence I doubt there is a time gap between these components but still, happy to check that out once I know what file is causing it. :)

The client's version is 2.2.3.

rawbertl avatar Sep 12 '16 12:09 rawbertl

In my case, the client version is Windows 10, Version 2.2.3 build 6307.

Servers (Zyxel NSA325v2 and Ubuntu 16.10) are synchronized to the same ntp server and they have pretty much the same time.

I fetched "storage_mtime" values for some random files from the "oc_filecache". I tried to compare them using smbclient, but it gave an error message, that server doesn't support UNIX CIFS calls. So I compared them against the file's timestamp given by NSA325v2's file browser interface. Timestamps matched for all checked files.

ktuulos avatar Sep 12 '16 13:09 ktuulos

@rawbertp Could you verify what @ktuulos said about UNIX CIFS calls? I think there are some changes regarding in the 9.0.5 RC2 and 9.1.1 RC2 versions that could solve this issue. @ktuulos really apreciated if you could try one of those versions and check if the problem is solved or mitigated.

jvillafanez avatar Sep 12 '16 14:09 jvillafanez

Hmm.. not sure how to get all the files' modification timestamps using smbclient in order to compare them with those from the DB. :-/ If I did a "mount -t cifs ..." would that be the same?

rawbertl avatar Sep 12 '16 14:09 rawbertl

@rawbertp I think the "allinfo" smbclient command is the one being used to get the stat info of the file (if you're not using the php-smbclient library)

$ smbclient -U user%password '//server/share'
> allinfo .
> allinfo folder

jvillafanez avatar Sep 12 '16 14:09 jvillafanez

Alright, two more question:

1.) What's the idea behind the two columns "mtime" and "storage_mtime"? I found 96 records where these values differ... should I be worried about those? 2.) Which of the two columns should I use for comparing with smbclient's mtime?

rawbertl avatar Sep 12 '16 14:09 rawbertl

UPDATE 1: I just realized that there are a lot of "false positives" because sometimes the FS mod time is +0200, and sometimes it is +0100. I need to find out if they can be somehow converted to UTC... Still, there are a lot of occurrences where the minutes don't match, e.g. <2016-09-12 10:03:52> vs. <2016-09-12 10:46:58>.

This is how I converted/retrieved the timestamps:

   db_date_wo_quotes=`echo $storage_mtime | sed -e 's/^"//' -e 's/"$//'`
   db_mtime=`date +"%Y-%m-%d %H:%M:%S" -d @${db_date_wo_quotes=}`
   smbclient_mtime=`smbclient -A "$AUTHFILE" "//nas/$SHARE" -c "stat $filepath" 2>&1 | grep Modify | grep -oP "(?<=Modify: ).*(?=\+0.00)" | sed -e 's/[[:space:]]*$//'`

UPDATE 2:

I had a look at one specific example and these are my observations. As you can see the datetime in the database is completely different from the filesystem/smbclient data:

smbclient: 2016-09-12 10:46:58

Access: (0770/drwxrwx---)   Uid: 1000   Gid: 1000
Access: 2016-09-12 10:46:58 +0200
Modify: 2016-09-12 10:46:58 +0200
Change: 2016-09-12 10:46:58 +0200


MariaDB> select mtime, storage_mtime from oc_filecache where storage=24 and path = 'Work';
+------------+---------------+
| mtime      | storage_mtime |
+------------+---------------+
| 1473667432 |    1473420979 |
+------------+---------------+

1473667432: 12.09.2016, 10:03:52 GMT+2:00 DST
1473420979: 09.09.2016, 13:36:19 GMT+2:00 DST


# stat /.../Work/
  File: '.../Work/'
  Size: 4096        Blocks: 8          IO Block: 4096   directory
Device: 900h/2304d  Inode: 64487433    Links: 14
Access: (0770/drwxrwx---)  Uid: ( 1000/  robert)   Gid: ( 1000/  robert)
Access: 2016-09-12 10:46:57.921776429 +0200
Modify: 2016-09-12 10:46:57.861776484 +0200
Change: 2016-09-12 10:46:57.861776484 +0200

UPDATE 3:

I was able to reproduce that with 9.1.0RC4. However, the two occurrences I found do make much more sense now.

File 1 ("rounding" issue?!):

DB: <2015-08-27 11:19:16>/<"1440667156"> | SMB: <2015-08-27 11:19:17>

smbclient:
change_time:    Thu Aug 27 11:19:17 AM 2015 CEST

Linux stat:
Modify: 2015-08-27 11:19:16.604396640 +0200

File 2 (TZ issue!?):

DB: <2008-12-01 11:31:10>/<"1228127470"> | SMB: <2008-12-01 12:31:10>

smbclient:
change_time:    Mon Dec  1 12:31:10 PM 2008 CET

Linux stat:
Modify: 2008-12-01 12:31:10.000000000 +0100

Q: Could it be that OC is just taking the date time part without taking the TZ offset into consideration?

rawbertl avatar Sep 12 '16 15:09 rawbertl

@jvillafanez - I'm sorry, I can't test RC versions in the current server. I'll set up a virtual machine, where I'll try to reproduce the error and see, whether versions you suggested would have the problem corrected. It will anyway take couple of days, due to my limited schedule, I'll get back to this.

ktuulos avatar Sep 13 '16 05:09 ktuulos

Q: Could it be that OC is just taking the date time part without taking the TZ offset into consideration?

I don't really know how the mtime is being parsed, and there might be issues there specially if the timezones between the OC server and the SMB server are different.

I suggest to change the strategy here and try the native library. Since you're using ubuntu 16.04 and php7, the php-smbclient library should be usable. Just install the package and make sure ownCloud uses it (*)

(*) The library wasn't properly installed in ubuntu 16.04 last time I checked. You might need to create a link to the proper location and then restart everything. Latest stable9.1 package (and very likely 9.1.1 RC2 package) contains a log to help to know if the native library is being used: just set the logging level to "debug" and add a new configuration option 'wnd.logging.enable' => true in the config.php file (you can revert these changes afterwards)

jvillafanez avatar Sep 13 '16 09:09 jvillafanez

I did not get the 'wnd.logging' work but following these instructions:

apt install php-smbclient php-smb php-streams
cd /etc/php/7.0/apache2/conf.d/
ln -s /etc/php/mods-available/smbclient.ini 20-smbclient.ini
service apache2 restart

... the issue seems to be gone. At least I wasn't able to reproduce it yet... ;)

rawbertl avatar Sep 13 '16 17:09 rawbertl

I activated the php-smbclient, as described above, but it did not effect anything - files on Windows client keep re-syncing.

As next step, I created a virtual machine with Ubuntu 16.04 Desktop and installed ownCloud client (version 2.1.1). It seems, that this problem does not exist in the Linux desktop client.

There was difference on timestamps in files synchronized from SMB drive: Windows desktop client had set the "file created" timestamp as the moment, when the file was synchronized. Instead, on Linux client, timestamps were the same as in database and as in SMB drive.

For other files i.e. those files, which were stored "inside" ownCloud server, there were no problems in timestamps.

In these experiments, server version was still the 16.04 official version.

ktuulos avatar Sep 14 '16 10:09 ktuulos

@ktuulos could you check with the latest versions of server and desktop client? Does the desktop client have a different timezone than the server?

Notice that there are 3 machines involved: the desktop client, the ownCloud server and the SMB server. Ideally each of them should have the same timezone. As said above, the native library should fix some issues regarding different timezones among the 3 machines.

@ktuulos you might still be using the "cli" library (the non-native one). We need to verify what library are you using. Ideally the "debug" log level + the wnd.logging.enable trick should show something (please notice that this is available for 9.1.1 RC2, but not previous versions). The other thing you could check is a exception trace in the logs: again with "debug" log level, force an error in the SMB app and post the exception log here.

jvillafanez avatar Sep 14 '16 11:09 jvillafanez

Any update on the requested info ?

PVince81 avatar Jan 13 '17 16:01 PVince81

closing due to lack of feedback

PVince81 avatar Apr 06 '17 11:04 PVince81

Hey, this issue has been closed because the label needs info is set and there were no updates for 14 days. Feel free to reopen this issue if you deem it appropriate.

(This is an automated comment from GitMate.io.

ownclouders avatar Dec 21 '17 01:12 ownclouders

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jul 31 '19 16:07 lock[bot]