Hello,
Our customer reported that pg_rewind took many hours to synchronize 400GB of data, even if the new primary doesn't perform any updates. The attached patch fixes that.
The cause was that pg_rewind failed to recognize data files in tablespace directories, resulting in the full copy of those files instead of WAL replay.
Regards
Takayuki Tsunakawa