Postgres-xc won't uninstall (Fails on Stopping Co-ordinators)

I was doing some rails development and accidentally installed postres-xc instead of the normal postgres package. I immediately went to remove postgres-xc, but apt-get will not uninstall it. I also tried installing the regular postgres, but it fails the same way.

sudo apt-get remove postgres-xc output:

  Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  comerr-dev krb5-multidev libgraphics-magick-perl libgraphicsmagick++1-dev libgraphicsmagick++3 libgraphicsmagick1-dev libgraphicsmagick3 libgssrpc4 libkadm5clnt-mit8 libkadm5srv-mit8
  libkdb5-6 libkrb5-dev libpq-dev libpq5 libssl-dev libssl-doc linux-headers-3.5.0-17
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  postgres-xc
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 17.1 MB disk space will be freed.
Do you want to continue [Y/n]? Y
(Reading database ... 217256 files and directories currently installed.)
Removing postgres-xc ...
 * Stopping Postgres-XC datanodes                                                                                                                                                  [ OK ] 
 * Stopping Postgres-XC coordinators                                                                                                                                               [fail] 
invoke-rc.d: initscript postgres-xc, action "stop" failed.
dpkg: error processing postgres-xc (--remove):
 subprocess installed pre-removal script returned error exit status 1
 * Starting Postgres-XC global transaction management daemons                                                                                                                      [ OK ] 
 * Starting Postgres-XC coordinators                                                                                                                                               [ OK ] 
 * Starting Postgres-XC datanodes                                                                                                                                                  [ OK ] 
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 postgres-xc
E: Sub-process /usr/bin/dpkg returned an error code (1)

EDIT

I've discovered that it is at least partially uninstalling, as I cannot install anything else without using apt-get -f install to repair it.

Also seems to be a known issue

Postgres-xc won't uninstall (Fails on Stopping Co-ordinators) https://bugs.launchpad.net/ubuntu/+source/postgres-xc/+bug/1084849

Is there anyway I can manually get it off my install.

EDIT 2

Fixed it. Solution is to dpkg --purge postgres-xc


Solution 1:

The solution that worked for me was:

  1. Modify postgres-xc.prerm:

    sudo vim /var/lib/dpkg/info/postgres-xc.prerm

    Add "exit 0" after first line (#/bin/sh -e)

  2. Then remove normally:

    sudo apt-get remove postgres-xc

(I found this solution at: https://bugs.launchpad.net/ubuntu/+source/postgres-xc/+bug/1084849)