CLUSTER statement fails with 'server closed the connection unexpectedly'

Posted on 2006-04-05
Last Modified: 2010-08-05
The following command use to work:

wts1=# CLUSTER inv_search4_idx ON Invoice ;

But now I am getting the following error:

server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

OS Info:
  Postrgesql 7.4.7
  Fedora Core 2

The actual script looks like:

# Knock off any users.  They shouldn't be up this late!

/sbin/service postgresql restart

echo -e "\n-->Re-Clustering Orderdate Index on Invoice Table"

/usr/bin/psql -h wts1 <<EOF
CLUSTER inv_search4_idx ON Invoice ;

echo -e "\nDone"

Thanks in advance

Question by:canyonsw
    LVL 61

    Expert Comment

    Your firewall(or NAT router) in the middle closed connection...
    LVL 22

    Accepted Solution

    Maybe you have found a bug in PostgreSQL 7.4.7

    Try instead

    CREATE TABLE newtable AS
        SELECT columnlist FROM table ORDER BY columnlist;

    which uses the PostgreSQL sorting code in the ORDER BY clause to create the desired order; this is usually much faster than an index scan for unordered data. You then drop the old table, use ALTER TABLE ... RENAME to rename newtable to the old name, and recreate the table's indexes. However, this approach does not preserve OIDs, constraints, foreign key relationships, granted privileges, and other ancillary properties of the table — all such items must be manually recreated.

    Maybe you could upgrade to the latest version of PostgreSQL and the problem MAY go away.

    Author Comment

    To gheist:

    I thought of this.  The sql fails on the local machine.

    Author Comment

    To earthman2:

    I am getting ready to upgrade to Fedora Core 4 ... I'm not quite ready to jump to 5.  I have scripts that create my index and reset the OID.  I can use your solution in the interim without much effort.

    LVL 61

    Expert Comment

    If you can get new machine then try any distribution with 8.x.y, if it works prepare to jump.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: ( This requires some add-o…
    Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
    Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now