Is there the explicit reason why --slot option that pg_receivexlog already has has not been added into pg_basebackup? If not, I'd like to support that option to eliminate the need to increase wal_keep_segments for pg_basebackup. Thought?
That seems rather cumbersome. pg_basebackup is a run once, and then it dies. The slot would have to be created before running pg_basebackup, and destroyed manually.
It would make sense to provide a new option that would tell the server to recycle segments until they've been sent to this client, or until the client disconnects. But that would look quite different from pg_receivexlog's --slot option.
I started working on that at some point long ago, but never got far enough.
Right now, it seems the right way to do that is to somehow reimplement it on top of a "lightweight slot" that gets automatically destroyed when pg_basebackup stops.
But as Andres said, there's a little more to it. You'd want the slot to be created in the connection that does BASE_BACKUP, then used by the replication client side, and then destroyed by BASE_BACKUP. But you also want it auto-destroyed if the BASE_BACKUP connection gets terminated for example..