![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
We have an intermittent bug that occurs on a table which is updated several times per second. The bug occurs every few days/weeks. It is usually preceeded by a "tuple concurrently updated" messages, but I could not swear it is always preceeded by it. The result of the bug is demonstrated by: select id,count(*) from xxx group by id having count(*)>1; id | count -------+------- 24613 | 6 (1 row) |
#2
| |||
| |||
|
|
Please do a SELECT xmin, xmax, cmin, cmax FROM xxx where id = 24613; if you still have that particular manifestation. |
#3
| |||
| |||
|
|
On Thu, Apr 06, 2006 at 08:12:31AM -0400, Alvaro Herrera wrote: Please do a SELECT xmin, xmax, cmin, cmax FROM xxx where id = 24613; # set enable_indexscan=off; |
#4
| |||
| |||
|
|
# set enable_indexscan=off; # SELECT xmin, xmax, cmin, cmax FROM xxx where id = 24613; xmin | xmax | cmin | cmax ----------+----------+------+---------- 32902771 | 0 | 20 | 32902872 32902771 | 0 | 20 | 32902872 32902771 | 0 | 20 | 32902872 32902771 | 0 | 20 | 32902872 32902771 | 0 | 20 | 32902872 32902771 | 33048159 | 20 | 20 (6 rows) |
#5
| |||
| |||
|
|
# set enable_indexscan=off; # SELECT xmin, xmax, cmin, cmax FROM xxx where id = 24613; xmin | xmax | cmin | cmax ----------+----------+------+---------- 32902771 | 0 | 20 | 32902872 32902771 | 0 | 20 | 32902872 32902771 | 0 | 20 | 32902872 32902771 | 0 | 20 | 32902872 32902771 | 0 | 20 | 32902872 32902771 | 33048159 | 20 | 20 (6 rows) |
#6
| |||
| |||
|
|
For completeness, could we also see ctid in that query? mail=# set enable_indexscan=off; |
#7
| |||
| |||
|
|
Do the triggers involved have EXCEPTION clauses? (I assume they are written in PL/pgSQL -- are there any in other languages?) Triggers that update this table are in pl/pgsql, and can *raise* |
#8
| |||
| |||
|
|
mail=# set enable_indexscan=off; mail=# SELECT xmin, xmax, cmin, cmax,ctid FROM xxx where id = 24613; xmin | xmax | cmin | cmax | ctid ----------+----------+------+----------+--------- 32902771 | 0 | 20 | 32902872 | (0,7) 32902771 | 0 | 20 | 32902872 | (2,27) 32902771 | 0 | 20 | 32902872 | (58,27) 32902771 | 0 | 20 | 32902872 | (60,28) 32902771 | 0 | 20 | 32902872 | (69,3) 32902771 | 33048159 | 20 | 20 | (72,27) (6 rows) |
#9
| ||||
| ||||
|
|
Philip Warner <pjw (AT) rhyme (DOT) com.au> writes: mail=# set enable_indexscan=off; mail=# SELECT xmin, xmax, cmin, cmax,ctid FROM xxx where id = 24613; xmin | xmax | cmin | cmax | ctid ----------+----------+------+----------+--------- 32902771 | 0 | 20 | 32902872 | (0,7) 32902771 | 0 | 20 | 32902872 | (2,27) 32902771 | 0 | 20 | 32902872 | (58,27) 32902771 | 0 | 20 | 32902872 | (60,28) 32902771 | 0 | 20 | 32902872 | (69,3) 32902771 | 33048159 | 20 | 20 | (72,27) (6 rows) The "cmax" values in the first 5 rows are evidently really xvac values, ie, these have all been moved by VACUUM FULL. (I assume you run VACUUM FULL regularly on this table?) Yes, every minute. Table has about 1500 rows and grows *very* fast due |
|
The thing that is striking though is that the xmin/cmin values are all the same, indicating that all six tuples were inserted by the same command. That seems pretty odd. Can you show us the procedure by which rows are inserted in this table? The original insertion is probably not relevant (it happened months |
|
Also, the last tuple has either been deleted or locked-for-update by transaction 33048159; if it were an attempted deletion we'd have to conclude that 33048159 failed to commit. Do you use SELECT FOR UPDATE on this table? No. But when a new row is added, I do lock the table in exclusive mode: |
|
BTW, which of these rows is selected by an indexscan-enabled query, ie, set enable_indexscan=on then repeat same query? |
#10
| |||
| |||
|
|
Tom Lane wrote: The thing that is striking though is that the xmin/cmin values are all the same, indicating that all six tuples were inserted by the same command. That seems pretty odd. Can you show us the procedure by which rows are inserted in this table? The original insertion is probably not relevant (it happened months ago); there are many places that update the table. |
|
Updates happen regularly from many sources, but the procedure that does the most updates is a trigger. Do you want to see that? |
![]() |
| Thread Tools | |
| Display Modes | |
| |