pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Williamson <gwilliamson39@yahoo.com>
To: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Question about ALTER TABLE DROP CONSTRAINT on 9.1 -- psql crashes
Date: Thu, 9 Aug 2012 17:04:42 -0700 (PDT)
Message-ID: <1344557082.43876.YahooMailNeo@web125906.mail.ne1.yahoo.com> (raw)

We have a small database (few hundred megs of data, lass than half that in indexes) that suffers from index bloat. Currently we handle this with an hourly REINDEX command. This works but causes some small issues, so I have been expploring other methods.

When I try to to drop constraints (typically UNIQUE) I sometimes get a crash of the psql client at the ALTER TABLE X DROP CONSTRAINT, and sometimes after I recreate the constraint at a commit. Transcript below:

usher=# BEGIN;
BEGIN
gusher=# ALTER TABLE ourcodes DROP CONSTRAINT IF EXISTS ourcodes_pkey CASCADE;
ALTER TABLE
gusher=# ALTER TABLE ourcodes ADD CONSTRAINT ourcodes_pkey PRIMARY KEY (id);
NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index "ourcodes_pkey" for table "ourcodes"
ALTER TABLE
gusher=# COMMIT;
FATAL:  terminating connection due to administrator command
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: Succeeded.
gusher=# \d ourcodes
                       Unlogged table "public.ourcodes"
   Column    |  Type  |                        Modifiers
-------------+--------+---------------------------------------------------------
 id          | bigint | not null default nextval('ourcodes_id_seq'::regclass)
 source      | bigint | not null
 destination | bigint |
 started_on  | bigint | default (date_part('epoch'::text, now()))::bigint
 type        | text   |
 status      | text   |
 updated_on  | bigint | default date_part('epoch'::text, now())
 worker      | text   |
 version     | text   |
Indexes:
    "ourcodes_pkey" PRIMARY KEY, btree (id)
    "ourcodes_source" btree (source, type)

gusher=# select count(*) from ourcodes;LTER TABLE
gusher=# ALTER TABLE ourcodes ADD CONSTRAINT ourcodes_pkey PRIMARY KEY (id);
NOTICE:  ALTER TABLE / ADD PRIMARY KEY will create implicit index "ourcodes_pkey" for table "ourcodes"
ALTER TABLE
gusher=# COMMIT;
FATAL:  terminating connection due to administrator command
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: Succeeded.
gusher=# \d ourcodes
                       Unlogged table "public.ourcodes"
   Column    |  Type  |                        Modifiers
-------------+--------+---------------------------------------------------------
 id          | bigint | not null default nextval('ourcodes_id_seq'::regclass)
 source      | bigint | not null
 destination | bigint |
 started_on  | bigint | default (date_part('epoch'::text, now()))::bigint
 type        | text   |
 status      | text   |
 updated_on  | bigint | default date_part('epoch'::text, now())
 worker      | text   |
 version     | text   |
Indexes:
    "ourcodes_pkey" PRIMARY KEY, btree (id)
    "ourcodes_source" btree (source, type)

gusher=# select count(*) from ourcodes;
 count
-------
  1626
(1 row)

 count
-------
  1626
(1 row)

gusher=# select version();
                                                    version                                                     
----------------------------------------------------------------------------------------------------------------
 PostgreSQL 9.1.4 on x86_64-unknown-linux-gnu, compiled by gcc-4.4.real (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3, 64-bit
(1 row)

 ========

This table is only updated a few times a minute (mostly inserts and deletes, some updates), others get hit a lot more (many times a second). pgsql is the same version and I am on the same server.

Is this known / documented ? Any suggestions (other than not to do this ; -- )

Thanks,

Greg Williamson

view thread (8+ messages)  latest in thread

Message-ID: <1344557082.43876.YahooMailNeo@web125906.mail.ne1.yahoo.com>
Permalink:  ../1344557082.43876.YahooMailNeo@web125906.mail.ne1.yahoo.com/
Also on:    postgresql.org/message-id/1344557082.43876.YahooMailNeo@web125906.mail.ne1.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: gwilliamson39@yahoo.com
  Subject: Re: Question about ALTER TABLE DROP CONSTRAINT on 9.1 -- psql crashes
  In-Reply-To: <1344557082.43876.YahooMailNeo@web125906.mail.ne1.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox