-
-
Notifications
You must be signed in to change notification settings - Fork 741
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
mtime cache misbehaving on nested backups #1860
Comments
Hi @gleb, some questions: "I am seeing borg mtime cache consistently become ineffective during my backups." - how do you see that? Does the archive of /foo include /foo/a/* and /foo/b/* also? Also, please give the full command sequence you use. |
I am using the very helpful
Yes, all the backups are recursive. Actually a more complete description of directory structure would be something like this
|
Please check with borg list if the full archived pathes of the files you suspect being chunked/hashed again matches completely. The cache key is H(path) with H being a hash function, so we only get a hit if the path is exactly the same. |
Yes, paths are the same. In fact for given file the text that |
In hash function above is path a relative path passed in or true/canonicalized file path? It doesn't affect this issue, but is good to know. |
No, i just checked that: the hash function gets the full, absolute path of the file.
The path join is a bit strange, but it creates the full absolute path of the file, even if you invoke |
I modified borg/archive.py so one sees the pathes used for the path_hash (ph: ...):
|
Besides path not matching, it could be also that borg thinks the file is modified. |
No, nothing is touching the files. I mean /foo/{1-8} show no changed files, and immediately archiving /foo afterwards does. ext4, very vanilla, single file system. It's as if using the cache in /foo/{1-8} invalidates the cache. Is there a python oneliner I can use to dump the cache matching a particular path? Also, I verified that BORG_FILES_CACHE_TTL=10000 makes it into /proc/(pid)/environ |
To my great surprise I was able to reproduce this problem on a standalone test case on the first try:
|
Even weirder, this is timing related. By sticking sleep in different places in this script I am getting different output. Here's a simplified script:
|
ok, I'll try to reproduce / debug this. |
Slightly cleaned up and extended script:
|
Output:
As you see, only latest-mtime.txt has A status and that is expected, see FAQ. So the only remaining question is if your original problem was also just with the "latest mtime" files? |
I'ld appreciate if you base your script changes on my modified script. I had a reason why I removed all the grep and filter and crypto etc. And I don't want to repeat same work again. Also, if some sleeps do not matter, remove them. One sleep definitely matters, it is the one before touching latest-mtime.txt. |
(also remove all posts above that are superceded by your next update) |
I modified your script until it showed the problem. The key seems to be adding I am happy to redo this if necessary based on your feedback. modified borg_cache_bug
@@ -1,2 +1,3 @@
#!/bin/bash
+set -x
export BORG_REPO="test-repo"
@@ -4,3 +5,3 @@ BORG="borg create --list -v"
-borg delete ::
+rm -r test-repo
borg init -e none ::
@@ -19,2 +20,5 @@ sleep 2
touch backup-test/{1,2,3,4}/latest-mtime.txt
+sleep 2
+touch backup-test/latest-mtime.txt # key to changing behavior
+sleep 2 # optional doesn't change behavior
@@ -25,3 +29,3 @@ $BORG ::all_{now} backup-test 2>&1
-sleep 5
+sleep 5 # optional, doesn't change behavior Script: #!/bin/bash
set -x
export BORG_REPO="test-repo"
BORG="borg create --list -v"
rm -r test-repo
borg init -e none ::
# populate data
rm -r backup-test
mkdir backup-test
mkdir backup-test/{1,2,3,4}
touch backup-test/{1,2,3,4}/file.txt
touch backup-test/{1,2,3,4}/file2.txt
touch backup-test/another_file.txt
# this is to avoid the "latest mtime" issue, see FAQ.
# "A" status for latest-mtime.txt is EXPECTED!
sleep 2
touch backup-test/{1,2,3,4}/latest-mtime.txt
sleep 2
touch backup-test/latest-mtime.txt # key to changing behavior
sleep 2 # optional doesn't change behavior
echo "first run"
$BORG ::1_{now} backup-test/1 2>&1
$BORG ::1_{now} backup-test/2 2>&1
$BORG ::all_{now} backup-test 2>&1
sleep 5 # optional, doesn't change behavior
echo "second run"
$BORG ::1_{now} backup-test/1 2>&1
$BORG ::1_{now} backup-test/2 2>&1
$BORG ::all_{now} backup-test 2>&1 Output:
|
Also, I verified that timestamps do not change during this script by running modified borg_cache_bug
@@ -24,2 +24,4 @@ sleep 2 # optional doesn't change behavior
+stat backup-test/1/file.txt
+
echo "first run"
@@ -32,4 +34,8 @@ sleep 5 # optional, doesn't change behavior
echo "second run"
+stat backup-test/1/file.txt
$BORG ::1_{now} backup-test/1 2>&1
+stat backup-test/1/file.txt
$BORG ::1_{now} backup-test/2 2>&1
+stat backup-test/1/file.txt
$BORG ::all_{now} backup-test 2>&1
+stat backup-test/1/file.txt |
the "A" for the 2 latest-mtime files is easy to explain: their cache entry was killed by the first 2 borg commands in the second run. |
Guess I've found the issue: the "latest mtime seen" is not updated for unchanged files, only for added/modified. So, if it is never updated, it is at 0 (its initial value) and that kills all generation 0 cache entries. |
bug: if no files were added/modified, _newest_mtime stayed at its initial 0 value. when saving the files cache, this killed all age 0 entries. Now using None as initial value, so we can spot that circumstance. The 2 ** 63 - 1 value is just so it is MAX_INT on a 64bit platform, for better performance. It can be easily increased when y2262 is coming.
See PR #1864. |
Script output:
|
fix determination of newest mtime, fixes #1860
#1864 merged. |
@gleb thanks for reporting! |
@ThomasWaldmann thank you for fixing it! |
I am seeing borg mtime cache consistently become ineffective during my backups. I am suspecting it has something to do with how these are structured. This is just a guess, but I am hoping somebody will recognize the pattern.
Given file hierarchy:
I am backing it up as 3 archives:
I am running with
export BORG_FILES_CACHE_TTL=10000
Borg Version: 1.0.7-0ubuntu1.16.04.1
This seems related to #1430 but the fix for that was already included in 1.0.7
The text was updated successfully, but these errors were encountered: