Repository: borgbackup/borg

Issue:
Error "self test failed" sometimes reported
## Have you checked borgbackup docs, FAQ, and open Github issues?

Yes. Maybe related issues : #4836

## Is this a BUG / ISSUE report or a QUESTION?

BUG 

## System information. For client/server mode post info for both machines.

#### Your borg version (borg -V).

```
# borg --version
borg 1.1.11
```

#### Operating system (distribution) and version.

```
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.7 LTS
Release:        16.04
Codename:       xenial
```

#### Hardware / network configuration, and filesystems used.

- file system : ext4
- CPU : Intel(R) Atom(TM) CPU D425   @ 1.80GHz

#### How much data is handled by borg?

```
                       Original size      Compressed size    Deduplicated size
All archives:                9.01 GB              2.85 GB            525.23 MB

                       Unique chunks         Total chunks
Chunk index:                    4316               113943
```

#### Full borg commandline that lead to the problem (leave away excludes and passwords)

`borg create --stats --show-rc --compression zlib --list --filter AME "$BORG_REPO"::'{hostname}_{now:%Y-%m-%d_%H-%M-%S}'`


## Describe the problem you're observing.

The backup fails with "self test failed This is a bug either in Borg or in the package / distribution you use.".

#### Can you reproduce the problem? If so, describe how. If not, describe troubleshooting steps you took before opening the issue.

No. But, it is the third time it occurs on this server (18th of August 2020, 25th of August 2020 and 14th of September 2020).

Backups are done every hour (24 times per day), so it is very rare.

#### Include any warning/errors/backtraces from the system logs

```
self test test_chunkify (borg.testsuite.chunker.ChunkerTestCase) FAILED:
Traceback (most recent call last):
  File "borg/testsuite/chunker.py", line 17, in test_chunkify
AssertionError: b'000[6683080 chars]0000000000000000000000000000000000000000000000[5899780 chars]000Y' != b'000[6683080 chars]00000 0000000000000000000000000000000000000000[5899780 chars]000Y'

self test failed
This is a bug either in Borg or in the package / distribution you use.
```



Discussion:
Can you run some passes of `memtest86+`?
```
1. 0000000000000000000000000000000000000000000000
2. 00000 0000000000000000000000000000000000000000
diff ---^
```
That is exactly 1 bit difference between ascii 0 (== 0x30) and ascii space (== 0x20).

So the easiest explanation is that your RAM is not working reliable (or cpu or bus in between).
Thanks ! 

> Can you run some passes of memtest86+?

It is a production server, but we will try to plan it.

What do you think about updating the "This is a bug either in Borg or in the package / distribution you use." message to signal it can also be a hardware problem ?
If it is a prod server and it might eat your data (corrupt them), it's rather urgent I guess.

Yeah, the message should be more general.
any news?
Hello ! We have just had the opportunity to test today and you are right : it is a RAM problem. Thanks for your advice !
closing, hw issue.
ehrm, reopening - wanted to add something to the error msg / docs.

Resolving patch:
diff --git a/src/borg/selftest.py b/src/borg/selftest.py
--- a/src/borg/selftest.py
+++ b/src/borg/selftest.py
@@ -72,7 +72,7 @@ def selftest(logger):
                      successful_tests, SELFTEST_COUNT)
     if not result.wasSuccessful() or count_mismatch:
         logger.error("self test failed\n"
-                     "This is a bug either in Borg or in the package / distribution you use.")
+                     "Could be a bug either in Borg, the package / distribution you use, your OS or your hardware.")
         sys.exit(2)
         assert False, "sanity assertion failed: ran beyond sys.exit()"
     selftest_elapsed = time.perf_counter() - selftest_started


Test patch: