pg_rewind[1] is supposed to fix this. It's moving into core for 9.5, by the way.
[1] https://github.com/vmware/pg_rewind