File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 77 "os"
88
99 "github.com/fly-apps/postgres-flex/internal/flypg"
10+ "github.com/fly-apps/postgres-flex/internal/flypg/admin"
1011 "github.com/fly-apps/postgres-flex/internal/utils"
1112)
1213
@@ -48,5 +49,20 @@ func processUnregistration(ctx context.Context) error {
4849 return fmt .Errorf ("failed to unregister member: %v" , err )
4950 }
5051
52+ slots , err := admin .ListReplicationSlots (ctx , conn )
53+ if err != nil {
54+ return fmt .Errorf ("failed to list replication slots: %v" , err )
55+ }
56+
57+ targetSlot := fmt .Sprintf ("repmgr_slot_%d" , member .ID )
58+ for _ , slot := range slots {
59+ if slot .Name == targetSlot {
60+ if err := admin .DropReplicationSlot (ctx , conn , targetSlot ); err != nil {
61+ return fmt .Errorf ("failed to drop replication slot: %v" , err )
62+ }
63+ break
64+ }
65+ }
66+
5167 return nil
5268}
You can’t perform that action at this time.
0 commit comments