On 5/15/2006 8:39 AM, Gavin Hamill wrote:

Andrew Sullivan wrote:

On Mon, May 15, 2006 at 10:15:13AM +0100, Gavin Hamill wrote:
Hrm.  I'd still bet on data corruption.  You might try walking
through the table, getting all the data, in chunks, and see if you
get a failure.
I just did a "pg_dump -F p"of that table alone in one fell swoop, and it worked perfectly; it's left me a nice

This is a useless test. If the table contains any corruption of the kind we are suspecting, then the dump will simply contain NULL's in a PK. You won't be able to reload that dump into a table that defines that column NOT NULL, but the dump itself would happily work.

I have attached a patch that I am about to commit into REL_1_1_STABLE as well as HEAD. It will cause slon_quote_literal() to return a NULL result for a NULL input and the log trigger will bail out with an ERROR if one of the old key columns contains the NULL value. This will cause a transaction that happens to touch such a row to abort, instead of causing a postgres core dump.


Jan



COPY "RoomNight" ("ID", "BookingID", "RoomID", "Price", "Date", "DateBooked", "Cancelled", "GuestName", "Adults", "Children", "AllocationStatusID", "SmokingRequest", "BedRequested", "Incomplete", "RoomNumber") FROM stdin;

followed by all 800k rows .. no segfaults, no errors at all :/

Why does this happen roughly once a day?

I'd hoped the corefile would've been able to tell me that, but seemingly not :(

gdh

_______________________________________________
Slony1-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/slony1-general


--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== [EMAIL PROTECTED] #
Index: slony1_funcs.c
===================================================================
RCS file: /usr/local/cvsroot/slony1/slony1-engine/src/backend/slony1_funcs.c,v
retrieving revision 1.33.2.4
diff -c -r1.33.2.4 slony1_funcs.c
*** slony1_funcs.c      6 Jan 2006 17:07:46 -0000       1.33.2.4
--- slony1_funcs.c      15 May 2006 14:36:48 -0000
***************
*** 781,786 ****
--- 781,789 ----
                                continue;
                        col_ident = (char 
*)slon_quote_identifier(SPI_fname(tupdesc, i + 1));
                        col_value = slon_quote_literal(SPI_getvalue(old_row, 
tupdesc, i + 1));
+                       if (col_value == NULL)
+                               elog(ERROR, "Slony-I: old key column %s.%s IS 
NULL on UPDATE", 
+                                       
NameStr(tg->tg_relation->rd_rel->relname), col_ident);
  
                        cmddata_need = (cp - (char *)(cs->cmddata_buf)) + 16 +
                                (len_ident = strlen(col_ident)) +
***************
*** 845,850 ****
--- 848,856 ----
                                continue;
                        col_ident = (char 
*)slon_quote_identifier(SPI_fname(tupdesc, i + 1));
                        col_value = slon_quote_literal(SPI_getvalue(old_row, 
tupdesc, i + 1));
+                       if (col_value == NULL)
+                               elog(ERROR, "Slony-I: old key column %s.%s IS 
NULL on DELETE", 
+                                       
NameStr(tg->tg_relation->rd_rel->relname), col_ident);
  
                        cmddata_need = (cp - (char *)(cs->cmddata_buf)) + 16 +
                                (len_ident = strlen(col_ident)) +
***************
*** 1041,1046 ****
--- 1047,1055 ----
        int                     len;
        int                     wl;
  
+       if (str == NULL)
+               return NULL;
+ 
        len = strlen(str);
        result = palloc(len * 2 + 3);
        cp1 = str;
_______________________________________________
Slony1-general mailing list
[email protected]
http://gborg.postgresql.org/mailman/listinfo/slony1-general

Reply via email to