PostgreSQL wal archive name collision
The archive command starts with test, as is recommended on the documentation page: https://www.postgresql.org/docs/11/continuous-archiving.html


To quote the following sentence from that page "This is an example, not a recommendation"

Most likely the file had been copied, and it had been (unknown to PostgreSQL) persisted to disk, but for some reason the copy command returned an error, or didn't return anything at all, because of a crash or an unclean shutdown, or storage was detached unexpectedly from underneath it.  So as far as PostgreSQL is concerned, the archival was not successful and so needed to be repeated.  But when it tried to repeat it, it finds a file with same name already exists.  You could move the existing file to new name, let the archival proceed, then compare the two files to see if they are identical and if so delete the first one.  There is no way to atomically coordinate the filesystem with PostgreSQL, so these things do happen.  If you used a dedicated product to do the archiving rather than rolling your own script, it might take these steps for you.

If you have two clusters archiving to the same place, you will find the files are not identical in their headers.  You will have to figure out whether the other cluster is still valid, and if so where it is supposed to be archiving, fix it going forward, and move the old version of the file to the correct location.

If you are absolutely certain you can't have two instances trying to archive to the same place, then you can remove the 'test' from the archive_command.  Its only useful function is guard against that eventuality.  And as you see, it complicates the case when a archive operation was unsuccessful (either actually unsuccessful, or was not reported up to PostgreSQL as being successful) but did create the named file before failing.