Обсуждение: problem inserting tuples with access methods

Поиск
Список
Период
Сортировка

problem inserting tuples with access methods

От
Alice Lottini
Дата:
Hi everybody,
we wrote a dynamically loaded function using the
Access Methods but we have a problem we don't know how
to tackle. 
Our function reads data from an existing table (with a
simple table scan) and, for each tuple, it performs
several recursive (and memory-intensive) operations
producing quite a huge amount of results, which are
then stored on two existing heap tables. Each time a
result is produced it is immediately stored so as to
free as much memory as possible.
The storage of the resulting tuples is done through a
call to simple_heap_insert.

Here you have the routine handling the insertion and,
following, the error which occurs at its execution.

It should be an XLog error, but what is the reason?
Could the XLog file be too large to be handled?

We're sorry to bother you but we really can't solve
this problem by ourselves :(

Thanks a lot for your help!!

alice and lorena


**** Insertion Code ****
 tidset++;
 /* first table storage code */
tupdesc=CreateTupleDescCopy(RelationGetDescr(itemset_rel)); nattrs=tupdesc->natts; values=(Datum
*)palloc(nattrs*sizeof(*values));nulls=(char *)palloc(nattrs*sizeof(*nulls)); memset(values,0,nattrs*sizeof(*values));
for(i=0;i<nattrs;i++)    nulls[i]=' ';
 
 values[0]=UInt32GetDatum(tidset); item=condition->head; while(item!=NULL) {   values[1]=UInt32GetDatum(item->item_id);
 htup=heap_formtuple(tupdesc,values,nulls);   simple_heap_insert(itemset_rel,htup);   CommandCounterIncrement();
heap_freetuple(htup);  item=item->next; } pfree(values); pfree(nulls);
 
 /* second table storage code */
tupdesc=CreateTupleDescCopy(RelationGetDescr(setsupp_rel));
 nattrs=tupdesc->natts; values=(Datum *)palloc(nattrs*sizeof(*values)); nulls=(char *)palloc(nattrs*sizeof(*nulls));
memset(values,0,nattrs*sizeof(*values));memset(nulls,0,nattrs*sizeof(*nulls));
 
 for(i=0;i<nattrs;i++)     nulls[i]=' ';
 values[0]=UInt32GetDatum(tidset); values[1]=UInt32GetDatum(condition->supp);
 htup=heap_formtuple(tupdesc,values,nulls); simple_heap_insert(setsupp_rel,htup); CommandCounterIncrement();
heap_freetuple(htup); pfree(values); pfree(nulls);
 
   ....

**** Error recorded in /home/postgres/logfile ****

SupporLOG:  server process (pid 1581) was terminated
by signal 11
LOG:  terminating any other active server processes
LOG:  all server processes terminated; reinitializing
shared memory and semaphores
LOG:  database system was interrupted at 2003-05-23
12:25:37 CEST
LOG:  checkpoint record is at 0/1C7E125C
LOG:  redo record is at 0/1C7E125C; undo record is at
0/0; shutdown FALSE
LOG:  next transaction id: 5791; next oid: 2616805
LOG:  database system was not properly shut down;
automatic recovery in progress
FATAL:  The database system is starting up
LOG:  redo starts at 0/1C7E129C
LOG:  ReadRecord: invalid magic number 0000 in log
file 0, segment 28, offset 8495104
LOG:  redo done at 0/1C819F90
LOG:  database system is ready


______________________________________________________________________
Yahoo! Mail: 6MB di spazio gratuito, 30MB per i tuoi allegati, l'antivirus, il filtro Anti-spam
http://it.yahoo.com/mail_it/foot/?http://it.mail.yahoo.com/


Re: problem inserting tuples with access methods

От
Tom Lane
Дата:
Alice Lottini <alice_lottini@yahoo.it> writes:
> Here you have the routine handling the insertion and,
> following, the error which occurs at its execution.

The most likely bet is a simple coding error leading to dereferencing
an invalid pointer.  I'd suggest getting out your debugger to find out
exactly where the crash occurs.

A CommandCounterIncrement() after every tuple insertion is surely
overkill, but beyond that I don't see anything obviously wrong with the
code ... unless perhaps that it assumes without proof that the relations
have exactly two columns --- if they don't, that could lead to the core
dump.
        regards, tom lane