Search Postgresql Archives

Re: Insert query hangs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Greg,

Sending few discussions with one of the postgres person. You will understand what is the problem.

Regards
Tarkeshwar 



Can this be of help [1]?

[1] http://www.postgresql.org/docs/9.2/static/sql-createindex.html#SQL-CREATEINDEX-CONCURRENTLY

Regards,
Niklas
________________________________________
From: M Tarkeshwar Rao
Sent: Wednesday, 09 July 2014 1:41 PM
To: Niklas Andersson; Leo Zhou; postgres-discuss@xxxxxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [postgres-discuss] Insert query hangs
CREATE TABLE eventlogentry
(
   tableindex integer,
   object character varying(80),
   method character varying(80),
   bgwuser character varying(80),
   "time" character(23),
   realuser character varying(80),
   host character varying(80),
   application character varying(80)
)
WITH (
   OIDS=FALSE
)
TABLESPACE mmdata;
ALTER TABLE eventlogentry
   OWNER TO mmsuper;
GRANT ALL ON TABLE eventlogentry TO mmsuper; GRANT SELECT ON TABLE eventlogentry TO report;
 
CREATE UNIQUE INDEX ind1_eventlogentry
   ON eventlogentry
   USING btree
   (tableindex )
TABLESPACE mmindex;
 
I am sharing the table structure. When we removed the unique index it is working fine.
And when created normal index(not unique) it is working fine.
 
After removing unique index we tried to recreate it but it is giving following infinite logs :
 
concurrent insert in progress within table "eventlogentry"
 
caveat when building a unique index concurrently is that the uniqueness constraint is already being enforced against other transactions when the second table scan begins
 
 
Regards
Tarkeshwar
 
 
From: Niklas Andersson 
Sent: 09 July 2014 16:10
To: M Tarkeshwar Rao; Leo Zhou; postgres-discuss@xxxxxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [postgres-discuss] Insert query hangs
 
Hi,

 You have some info on checking on corrupt tables here [1], but I am pretty sure you'll be helped by using the REINDEX option [2].

 If you have lots of data, and lots of inserts sometimes you can run into performance issues. I.e the server doesn't have the time to rebuild the index at the speed you're sending inserts. But then the app still wouldn't hang, but almost grind to a halt and give you sluggish performance.

 Now, I don't know if this database has lots of deletes, but sometimes it makes sense to clean it up a bit. (Think: defrag), then VACUUM is helpful [3]

[1] http://blog.apptamers.com/post/32050443731/corrupted-postgres-table
[2] http://www.postgresql.org/docs/8.1/static/sql-reindex.html
[3] http://www.postgresql.org/docs/9.1/static/sql-vacuum.html

Regards,
Niklas
________________________________________
From: M Tarkeshwar Rao
Sent: Wednesday, 09 July 2014 12:32 PM
To: Niklas Andersson; Leo Zhou; postgres-discuss@xxxxxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [postgres-discuss] Insert query hangs
Actually problem is in customer site in their production environment. 
They have their database MDB. In that db they have insert issue with one table.
 
They shared the data folder with us.
 
We past the same data folder in our local DB which has the same name MDB and reproduced the issue.
 
After reproducing the issue we run pg_dump(with data) on corrupted table and restore it on another local db.
After restoring in another db we tested the insert operation and found it is working fine.
 
We analysed one more thing when we removed the unique index from the table it is working fine.
Is there any issue in indexing?
 
Is there any option to repair the table or its indexing?
 
Regards
Tarkeshwar
 
From: Niklas Andersson 
Sent: 09 July 2014 15:44
To: M Tarkeshwar Rao; Leo Zhou; postgres-discuss@xxxxxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [postgres-discuss] Insert query hangs
 
Ah, then it sounds like you had corrupt data in that first table. When you did the pgdump, did you also export and import the data and not only the structure?

Regards,
Niklas
________________________________________
From: M Tarkeshwar Rao
Sent: Wednesday, 09 July 2014 12:05 PM
To: Niklas Andersson; Leo Zhou; postgres-discuss@xxxxxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [postgres-discuss] Insert query hangs
You mean to say diff in the name of the table?
I have done one more thing I imported(using pgdump) the 2nd table(which have the hang issue) in another DB.
 
In the 2nd DB it is working fine.
 
Regards
Tarkeshwar
 
From: Niklas Andersson 
Sent: 09 July 2014 15:21
To: M Tarkeshwar Rao; Leo Zhou; postgres-discuss@xxxxxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [postgres-discuss] Insert query hangs
 
Well...in that case I would export the database schema and run a diff on the tables.

If the structure is identical, the only thing left is the actual naming. If you have non-ascii characters or some unicode-stuff, doing a diff would tell you that. Sometimes it is hard to see issues like that with the eye.

Regards,
Niklas
________________________________________
From: M Tarkeshwar Rao
Sent: Wednesday, 09 July 2014 11:46 AM
To: Niklas Andersson; Leo Zhou; postgres-discuss@xxxxxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [postgres-discuss] Insert query hangs
It just a plain insert statement. We are not using triggers in it.
Just a simple table with 6 columns one integer and rest are varchar(80) fields.
 
We are firing insert from command prompt. Two tables with same structure and same data.
 
Insert on one table working fine but for 2nd table it is going in hanging state.
 
Regards
Tarkeshwar
 
From: Niklas Andersson 
Sent: 09 July 2014 15:03
To: M Tarkeshwar Rao; Leo Zhou; postgres-discuss@xxxxxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [postgres-discuss] Insert query hangs
 
Can it be a trigger [1] or some PL/SQL statement that hangs? If the table structure is identical that is?

[1] http://www.postgresql.org/docs/9.0/static/trigger-definition.html

Regards,
Niklas
________________________________________
From: postgres-discuss-bounces@xxxxxxxxxxxxxxxxxxxxxxxxx [postgres-discuss-bounces@xxxxxxxxxxxxxxxxxxxxxxxxx] on behalf of M Tarkeshwar Rao
Sent: Wednesday, 09 July 2014 11:13 AM
To: Leo Zhou; postgres-discuss@xxxxxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [postgres-discuss] Insert query hangs
Hi Leo,
 
 
We have a table in a database DB1 with name Test. We imported this database from another machine.
When I fire insert statement it is going in the hang state.
 
Then I created another table with same structure and with same data within it as in table Test. 
Then I fired the insert statement. It is working fine.
 
I am not able find the reason for this. Can you please help me out on this. This scenario easily reproducible.
 
I have a standalone system and postgresql  9.1 installed on it.
 
Regards
Tarkeshwar
 
From: Leo Zhou 
Sent: 19 June 2014 15:40
To: M Tarkeshwar Rao; postgres-discuss@xxxxxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [postgres-discuss] Insert query hangs
 
Hi Tarkeshwar,
 
   According to my experience, if you are using standalone PG server, it could be transaction confliction. For example one session insert data into table, but other session lock table or change table.
  You can check the pg_lock system view. Refer to : https://wiki.postgresql.org/wiki/Lock_Monitoring. 
 
 
BRs,
Leo
 
 
 
From: postgres-discuss-bounces@xxxxxxxxxxxxxxxxxxxxxxxxx [mailto:postgres-discuss-bounces@xxxxxxxxxxxxxxxxxxxxxxxxx] On Behalf Of M Tarkeshwar Rao
Sent: Thursday, June 19, 2014 5:13 PM
To: postgres-discuss@xxxxxxxxxxxxxxxxxxxxxxxxx
Subject: [postgres-discuss] Insert query hangs
Importance: High
 
Hi,
 
Insert query hangs, what could be the reason. Is there any way to find out?
Any timeout feature is there with query which can be set at client or server end?
 
We need Postgres debug steps. How can we set the debugging option?
 
Regards
Tarkeshwar


-----Original Message-----
From: gsstark@xxxxxxxxx [mailto:gsstark@xxxxxxxxx] On Behalf Of Greg Stark
Sent: 09 July 2014 16:42
To: M Tarkeshwar Rao
Cc: pgsql-general@xxxxxxxxxxxxxx
Subject: Re: Insert query hangs

On Wed, Jul 9, 2014 at 11:34 AM, M Tarkeshwar Rao <m.tarkeshwar.rao@xxxxxxxxxxxx> wrote:
>
> We analysed one more thing when we removed the unique index from the table it is working fine.
> Is there any issue in indexing?
>
> Is there any option to repair the table or its indexing?

REINDEX is useful for indexes.

From the sounds of it you had an uncommitted transaction that had inserted a conflicting id. If you were able to drop the index the other transaction had committed (or aborted) by that time.

It's possible there was corruption but that doesn't usually lead to a hang and you haven't provided enough information to think that was the case.


--
greg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux