pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
The connection to the server was lost. Attempting reset: Failed.
10+ messages / 4 participants
[nested] [flat]

* The connection to the server was lost. Attempting reset: Failed.
@ 2019-10-10 15:55 Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 16:14 ` Re: The connection to the server was lost. Attempting reset: Failed. Tom Lane <tgl@sss.pgh.pa.us>
  2019-10-10 16:15 ` Re: The connection to the server was lost. Attempting reset: Failed. Alban Hertroys <haramrae@gmail.com>
  0 siblings, 2 replies; 10+ messages in thread

From: Yessica Brinkmann @ 2019-10-10 15:55 UTC (permalink / raw)
  To: pgsql-general

Good afternoon,
I am doing a thesis from the University. My thesis is the modification of
the Gurjeet Index Adviser, to add some features.
At the moment I am modifying one of the .c files and adding a function
called get_columnames that returns the names of the columns of a table,
passing it the numbers of the attributes.
I really thought a lot, but I don't understand why but the function fails
after the expression is executed:
appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), idxcd->
varattno [i]);
The error appears only to me when entering the cycle:
foreach (cell, candidates) / * foreach cell in candidates * /
more than once, that is, when you have more than one candidate index. If
the cycle is entered only once, the function works correctly.
The error that appears to me is that the connection to the PostgreSQL
server is directly lost. I proved that the error occurs in that statement,
printing some values.
The error that appears to me is the following:
The connection to the server was lost. Attempting reset: Failed.
I attach the source code of the function (function.c) and the log file with
the output of the last executions.
I clarify that the foreach cycle for the c language is defined in #include
"nodes / pg_list.h"
I am using Postgresql 8.3.23.
I clarify that I use that version because it is compatible with the Index
Adviser, which I am modifying for my University thesis.
 I was analyzing and researching on the compilation without optimizations,
with symbols and also on the use of gbd. Very interesting everything.
My query is now if all this can be applied the same if a Makefile is used.
Because the Index Adviser comes with a Makefile that runs for compilation.
That is, as I read it is more or less easy to apply all this if I'm going
to compile from the command line but having the Makefile, the truth is that
I don't know how to apply it. I am new with Linux.
The Linux distribution I use is Debian 9.x 64-bit.
And the version of C (gcc) that I use is 6.3.0
I will greatly appreciate an answer please,
I also attach the Index Adviser Makefile.
I would greatly appreciate a help please. I really am not knowing how to
move forward.
As I commented, my function works for the case in which the foreach is
entered only once. But when you enter more than once, it doesn't work. That
is, when you have more than one candidate index, it gives me that error.
This means that, for example, for a simple Select type statement or that
has an AND it works for me. But for the case where the Select statement has
an OR for example, it doesn't work. Because you already have more than one
candidate index and enter the foreach more than once.
I will be very grateful if anyone can help me please.
I already thought a lot why the mistake could happen but I can't really
find a reason.
Best regards,
Yessica Brinkmann

Attachments:

logfile.txt (text/plain, 4.5K) download FATAL: the database system is in recovery mode LOG: database system is ready to accept connections LOG: autovacuum launcher started LOG: database system was shut down at 2019-10-04 00:58:21 CEST LOG: database system is ready to accept connections LOG: autovacuum launcher started LOG: server process (PID 1245) was terminated by signal 11: Segmentation fault LOG: terminating any other active server processes LOG: all server processes terminated; reinitializing LOG: database system was interrupted; last known up at 2019-10-04 02:08:57 CEST LOG: database system was not properly shut down; automatic recovery in progress FATAL: the database system is in recovery mode LOG: redo starts at 0/BEE6A00 LOG: record with zero length at 0/BEFA848 LOG: redo done at 0/BEFA818 LOG: last completed transaction was at log time 2019-10-04 02:11:33.931119+02 LOG: database system is ready to accept connections LOG: autovacuum launcher started LOG: server process (PID 1388) was terminated by signal 11: Segmentation fault LOG: terminating any other active server processes LOG: all server processes terminated; reinitializing LOG: database system was interrupted; last known up at 2019-10-04 02:11:44 CEST LOG: database system was not properly shut down; automatic recovery in progress LOG: redo starts at 0/BEFA890 LOG: record with zero length at 0/BF0F940 LOG: redo done at 0/BF0F910 LOG: last completed transaction was at log time 2019-10-04 02:17:13.560035+02 FATAL: the database system is in recovery mode LOG: database system is ready to accept connections LOG: autovacuum launcher started LOG: received smart shutdown request LOG: received SIGHUP, reloading configuration files LOG: autovacuum launcher shutting down LOG: shutting down LOG: database system is shut down LOG: database system was shut down at 2019-10-04 02:36:09 CEST LOG: database system is ready to accept connections LOG: autovacuum launcher started LOG: server process (PID 1271) was terminated by signal 11: Segmentation fault LOG: terminating any other active server processes LOG: all server processes terminated; reinitializing LOG: database system was interrupted; last known up at 2019-10-04 15:44:07 CEST LOG: database system was not properly shut down; automatic recovery in progress FATAL: the database system is in recovery mode LOG: redo starts at 0/BF0F9D0 LOG: unexpected pageaddr 0/5F14000 in log file 0, segment 11, offset 15810560 LOG: redo done at 0/BF13140 LOG: last completed transaction was at log time 2019-10-04 15:46:27.151167+02 LOG: database system is ready to accept connections LOG: autovacuum launcher started LOG: server process (PID 1565) was terminated by signal 11: Segmentation fault LOG: terminating any other active server processes LOG: all server processes terminated; reinitializing LOG: database system was interrupted; last known up at 2019-10-04 15:46:53 CEST LOG: database system was not properly shut down; automatic recovery in progress FATAL: the database system is in recovery mode LOG: redo starts at 0/BF13998 LOG: record with zero length at 0/BF2A1C0 LOG: redo done at 0/BF2A190 LOG: last completed transaction was at log time 2019-10-04 16:05:58.835759+02 LOG: database system is ready to accept connections LOG: autovacuum launcher started LOG: server process (PID 1847) was terminated by signal 11: Segmentation fault LOG: terminating any other active server processes LOG: all server processes terminated; reinitializing LOG: database system was interrupted; last known up at 2019-10-04 16:06:07 CEST LOG: database system was not properly shut down; automatic recovery in progress FATAL: the database system is in recovery mode LOG: redo starts at 0/BF2A208 LOG: record with zero length at 0/BF3FAD0 LOG: redo done at 0/BF3FAA0 LOG: last completed transaction was at log time 2019-10-04 16:24:48.038614+02 LOG: database system is ready to accept connections LOG: autovacuum launcher started LOG: received smart shutdown request LOG: received SIGHUP, reloading configuration files LOG: autovacuum launcher shutting down LOG: shutting down LOG: database system is shut down LOG: database system was shut down at 2019-10-04 16:29:42 CEST LOG: database system is ready to accept connections LOG: autovacuum launcher started LOG: received smart shutdown request LOG: received SIGHUP, reloading configuration files LOG: autovacuum launcher shutting down LOG: shutting down LOG: database system is shut down
función.c (application/octet-stream, 4.3K) download
makefile.txt (text/plain, 853B) download # # PostgreSQL Adviser top level makefile # PGFILEDESC = "PostgreSQL Index Advisor" ifdef USE_PGXS PGXS := $(shell pg_config --pgxs) include $(PGXS) else subdir = contrib/adviser top_builddir = ../.. include $(top_builddir)/src/Makefile.global include $(top_srcdir)/contrib/contrib-global.mk endif all: $(MAKE) -C index_adviser $@ $(MAKE) -C pg_advise $@ $(MAKE) -C resources $@ @echo "PostgreSQL Index Advisor successfully made. Ready to install." install: $(MAKE) -C index_adviser $@ $(MAKE) -C pg_advise $@ $(MAKE) -C resources $@ @echo "PostgreSQL Index Advisor installed." uninstall: $(MAKE) -C index_adviser $@ $(MAKE) -C pg_advise $@ $(MAKE) -C resources $@ @echo "PostgreSQL Index Advisor uninstalled." clean: $(MAKE) -C index_adviser $@ $(MAKE) -C pg_advise $@ $(MAKE) -C resources $@
^ permalink raw reply [nested|flat] 10+ messages in thread

* Re: The connection to the server was lost. Attempting reset: Failed.
  2019-10-10 15:55 The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
@ 2019-10-10 16:14 ` Tom Lane <tgl@sss.pgh.pa.us>
  2019-10-10 16:33   ` Re: The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  1 sibling, 1 reply; 10+ messages in thread

From: Tom Lane @ 2019-10-10 16:14 UTC (permalink / raw)
  To: Yessica Brinkmann <yessica.brinkmann@gmail.com>; +Cc: pgsql-general

Yessica Brinkmann <yessica.brinkmann@gmail.com> writes:
> I really thought a lot, but I don't understand why but the function fails
> after the expression is executed:
> appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), idxcd->
> varattno [i]);

I think you're probably shooting yourself in the foot here:

            /* pfree() the memory allocated for the previous candidate. FIXME: Avoid
            * meddling with the internals of a StringInfo, and try to use an API.
            */
            if( cols.len > 0 )
            {
                pfree( cols.data );
                cols.data = NULL;
            } /*IF col.len>0*/

Don't do that, use resetStringInfo() instead.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: The connection to the server was lost. Attempting reset: Failed.
  2019-10-10 15:55 The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 16:14 ` Re: The connection to the server was lost. Attempting reset: Failed. Tom Lane <tgl@sss.pgh.pa.us>
@ 2019-10-10 16:33   ` Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 18:01     ` Re: The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Yessica Brinkmann @ 2019-10-10 16:33 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-general

Thank you so much for your answer. I will be testing the indicated and then
I give you return.
Best regards,
Yessica Brinkmann

El jue., 10 oct. 2019 a las 13:14, Tom Lane (<tgl@sss.pgh.pa.us>) escribió:

> Yessica Brinkmann <yessica.brinkmann@gmail.com> writes:
> > I really thought a lot, but I don't understand why but the function fails
> > after the expression is executed:
> > appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), idxcd->
> > varattno [i]);
>
> I think you're probably shooting yourself in the foot here:
>
>             /* pfree() the memory allocated for the previous candidate.
> FIXME: Avoid
>             * meddling with the internals of a StringInfo, and try to use
> an API.
>             */
>             if( cols.len > 0 )
>             {
>                 pfree( cols.data );
>                 cols.data = NULL;
>             } /*IF col.len>0*/
>
> Don't do that, use resetStringInfo() instead.
>
>                         regards, tom lane
>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: The connection to the server was lost. Attempting reset: Failed.
  2019-10-10 15:55 The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 16:14 ` Re: The connection to the server was lost. Attempting reset: Failed. Tom Lane <tgl@sss.pgh.pa.us>
  2019-10-10 16:33   ` Re: The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
@ 2019-10-10 18:01     ` Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 18:25       ` Re: The connection to the server was lost. Attempting reset: Failed. Jaime Soler <jaime.soler@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Yessica Brinkmann @ 2019-10-10 18:01 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-general

Thank you very much for the reply.
Well, really, resetStringInfo () is a function of the StringInfo data
structure.
What I used at the end was initStringInfo, which is a function of the data
structure StringInfoData, which is what I am using, although I don't know
if they are equivalent.
The code remained as follows:
                       if (cols.len> 0)
                      {
                               initStringInfo (& cols);
                       } / * IF col.len> 0 * /
But it continues giving me the same error.
Best regards,
Yessica Brinkmann

El jue., 10 oct. 2019 a las 13:33, Yessica Brinkmann (<
yessica.brinkmann@gmail.com>) escribió:

> Thank you so much for your answer. I will be testing the indicated and
> then I give you return.
> Best regards,
> Yessica Brinkmann
>
> El jue., 10 oct. 2019 a las 13:14, Tom Lane (<tgl@sss.pgh.pa.us>)
> escribió:
>
>> Yessica Brinkmann <yessica.brinkmann@gmail.com> writes:
>> > I really thought a lot, but I don't understand why but the function
>> fails
>> > after the expression is executed:
>> > appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), idxcd->
>> > varattno [i]);
>>
>> I think you're probably shooting yourself in the foot here:
>>
>>             /* pfree() the memory allocated for the previous candidate.
>> FIXME: Avoid
>>             * meddling with the internals of a StringInfo, and try to use
>> an API.
>>             */
>>             if( cols.len > 0 )
>>             {
>>                 pfree( cols.data );
>>                 cols.data = NULL;
>>             } /*IF col.len>0*/
>>
>> Don't do that, use resetStringInfo() instead.
>>
>>                         regards, tom lane
>>
>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: The connection to the server was lost. Attempting reset: Failed.
  2019-10-10 15:55 The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 16:14 ` Re: The connection to the server was lost. Attempting reset: Failed. Tom Lane <tgl@sss.pgh.pa.us>
  2019-10-10 16:33   ` Re: The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 18:01     ` Re: The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
@ 2019-10-10 18:25       ` Jaime Soler <jaime.soler@gmail.com>
  2019-10-10 18:35         ` Re: The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  0 siblings, 1 reply; 10+ messages in thread

From: Jaime Soler @ 2019-10-10 18:25 UTC (permalink / raw)
  To: Yessica Brinkmann <yessica.brinkmann@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-general

Why don't have a try to gdb ?
https://wiki.postgresql.org/wiki/Developer_FAQ#What_debugging_features_are_available.3F

It might be a extra free memory executions or null pointer accesses .. ,
gdb could help you.

Regards

El jue., 10 oct. 2019 a las 20:01, Yessica Brinkmann (<
yessica.brinkmann@gmail.com>) escribió:

> Thank you very much for the reply.
> Well, really, resetStringInfo () is a function of the StringInfo data
> structure.
> What I used at the end was initStringInfo, which is a function of the data
> structure StringInfoData, which is what I am using, although I don't know
> if they are equivalent.
> The code remained as follows:
>                        if (cols.len> 0)
>                       {
>                                initStringInfo (& cols);
>                        } / * IF col.len> 0 * /
> But it continues giving me the same error.
> Best regards,
> Yessica Brinkmann
>
> El jue., 10 oct. 2019 a las 13:33, Yessica Brinkmann (<
> yessica.brinkmann@gmail.com>) escribió:
>
>> Thank you so much for your answer. I will be testing the indicated and
>> then I give you return.
>> Best regards,
>> Yessica Brinkmann
>>
>> El jue., 10 oct. 2019 a las 13:14, Tom Lane (<tgl@sss.pgh.pa.us>)
>> escribió:
>>
>>> Yessica Brinkmann <yessica.brinkmann@gmail.com> writes:
>>> > I really thought a lot, but I don't understand why but the function
>>> fails
>>> > after the expression is executed:
>>> > appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""),
>>> idxcd->
>>> > varattno [i]);
>>>
>>> I think you're probably shooting yourself in the foot here:
>>>
>>>             /* pfree() the memory allocated for the previous candidate.
>>> FIXME: Avoid
>>>             * meddling with the internals of a StringInfo, and try to
>>> use an API.
>>>             */
>>>             if( cols.len > 0 )
>>>             {
>>>                 pfree( cols.data );
>>>                 cols.data = NULL;
>>>             } /*IF col.len>0*/
>>>
>>> Don't do that, use resetStringInfo() instead.
>>>
>>>                         regards, tom lane
>>>
>>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: The connection to the server was lost. Attempting reset: Failed.
  2019-10-10 15:55 The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 16:14 ` Re: The connection to the server was lost. Attempting reset: Failed. Tom Lane <tgl@sss.pgh.pa.us>
  2019-10-10 16:33   ` Re: The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 18:01     ` Re: The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 18:25       ` Re: The connection to the server was lost. Attempting reset: Failed. Jaime Soler <jaime.soler@gmail.com>
@ 2019-10-10 18:35         ` Yessica Brinkmann <yessica.brinkmann@gmail.com>
  0 siblings, 0 replies; 10+ messages in thread

From: Yessica Brinkmann @ 2019-10-10 18:35 UTC (permalink / raw)
  To: Jaime Soler <jaime.soler@gmail.com>; pgsql-general

Thank you so much for your answer. I will be testing the indicated and then
I give you return.
Best regards,
Yessica Brinkmann

El jue., 10 oct. 2019 a las 15:25, Jaime Soler (<jaime.soler@gmail.com>)
escribió:

> Why don't have a try to gdb ?
> https://wiki.postgresql.org/wiki/Developer_FAQ#What_debugging_features_are_available.3F
>
> It might be a extra free memory executions or null pointer accesses .. ,
> gdb could help you.
>
> Regards
>
> El jue., 10 oct. 2019 a las 20:01, Yessica Brinkmann (<
> yessica.brinkmann@gmail.com>) escribió:
>
>> Thank you very much for the reply.
>> Well, really, resetStringInfo () is a function of the StringInfo data
>> structure.
>> What I used at the end was initStringInfo, which is a function of the
>> data structure StringInfoData, which is what I am using, although I don't
>> know if they are equivalent.
>> The code remained as follows:
>>                        if (cols.len> 0)
>>                       {
>>                                initStringInfo (& cols);
>>                        } / * IF col.len> 0 * /
>> But it continues giving me the same error.
>> Best regards,
>> Yessica Brinkmann
>>
>> El jue., 10 oct. 2019 a las 13:33, Yessica Brinkmann (<
>> yessica.brinkmann@gmail.com>) escribió:
>>
>>> Thank you so much for your answer. I will be testing the indicated and
>>> then I give you return.
>>> Best regards,
>>> Yessica Brinkmann
>>>
>>> El jue., 10 oct. 2019 a las 13:14, Tom Lane (<tgl@sss.pgh.pa.us>)
>>> escribió:
>>>
>>>> Yessica Brinkmann <yessica.brinkmann@gmail.com> writes:
>>>> > I really thought a lot, but I don't understand why but the function
>>>> fails
>>>> > after the expression is executed:
>>>> > appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""),
>>>> idxcd->
>>>> > varattno [i]);
>>>>
>>>> I think you're probably shooting yourself in the foot here:
>>>>
>>>>             /* pfree() the memory allocated for the previous candidate.
>>>> FIXME: Avoid
>>>>             * meddling with the internals of a StringInfo, and try to
>>>> use an API.
>>>>             */
>>>>             if( cols.len > 0 )
>>>>             {
>>>>                 pfree( cols.data );
>>>>                 cols.data = NULL;
>>>>             } /*IF col.len>0*/
>>>>
>>>> Don't do that, use resetStringInfo() instead.
>>>>
>>>>                         regards, tom lane
>>>>
>>>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: The connection to the server was lost. Attempting reset: Failed.
  2019-10-10 15:55 The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
@ 2019-10-10 16:15 ` Alban Hertroys <haramrae@gmail.com>
  2019-10-10 16:38   ` Re: The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 19:43   ` Re: The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  1 sibling, 2 replies; 10+ messages in thread

From: Alban Hertroys @ 2019-10-10 16:15 UTC (permalink / raw)
  To: Yessica Brinkmann <yessica.brinkmann@gmail.com>; +Cc: pgsql-general


> On 10 Oct 2019, at 17:55, Yessica Brinkmann <yessica.brinkmann@gmail.com> wrote:
> 
> I really thought a lot, but I don't understand why but the function fails after the expression is executed:
> appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), idxcd-> varattno [i]);
> The error appears only to me when entering the cycle:
> foreach (cell, candidates) / * foreach cell in candidates * /
> more than once, that is, when you have more than one candidate index. If the cycle is entered only once, the function works correctly.
> The error that appears to me is that the connection to the PostgreSQL server is directly lost. I proved that the error occurs in that statement, printing some values.

There is probably an error in the Postgres log-file providing you more info.

That said, at least the below bit in your code is dangerous:

    foreach( cell, candidates ) /* foreach cell in candidates */
    {

        idxcd = (IndexCandidate*)lfirst( cell );

        if( !idxcd->idxused )
            continue;

        if (idxcd!=NULL)
        {


You should at least check for NULL before referencing an attribute of that structure. Personally, I would invert the test like so (and then move it before the idxused test:

	if (idxcd == NULL) {
            elog( INFO, "idxcd IS NULL" );
	    continue; /* Or is that fatal enough to break instead? */
	)

        if (!idxcd->idxused)
            continue;



Alban Hertroys
--
There is always an exception to always.









^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: The connection to the server was lost. Attempting reset: Failed.
  2019-10-10 15:55 The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 16:15 ` Re: The connection to the server was lost. Attempting reset: Failed. Alban Hertroys <haramrae@gmail.com>
@ 2019-10-10 16:38   ` Yessica Brinkmann <yessica.brinkmann@gmail.com>
  1 sibling, 0 replies; 10+ messages in thread

From: Yessica Brinkmann @ 2019-10-10 16:38 UTC (permalink / raw)
  To: Alban Hertroys <haramrae@gmail.com>; pgsql-general

Thank you so much for your answer. I will be testing the indicated and then
I give you return.
Best regards,
Yessica Brinkmann

El jue., 10 oct. 2019 a las 13:15, Alban Hertroys (<haramrae@gmail.com>)
escribió:

>
> > On 10 Oct 2019, at 17:55, Yessica Brinkmann <yessica.brinkmann@gmail.com>
> wrote:
> >
> > I really thought a lot, but I don't understand why but the function
> fails after the expression is executed:
> > appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), idxcd->
> varattno [i]);
> > The error appears only to me when entering the cycle:
> > foreach (cell, candidates) / * foreach cell in candidates * /
> > more than once, that is, when you have more than one candidate index. If
> the cycle is entered only once, the function works correctly.
> > The error that appears to me is that the connection to the PostgreSQL
> server is directly lost. I proved that the error occurs in that statement,
> printing some values.
>
> There is probably an error in the Postgres log-file providing you more
> info.
>
> That said, at least the below bit in your code is dangerous:
>
>     foreach( cell, candidates ) /* foreach cell in candidates */
>     {
>
>         idxcd = (IndexCandidate*)lfirst( cell );
>
>         if( !idxcd->idxused )
>             continue;
>
>         if (idxcd!=NULL)
>         {
>
>
> You should at least check for NULL before referencing an attribute of that
> structure. Personally, I would invert the test like so (and then move it
> before the idxused test:
>
>         if (idxcd == NULL) {
>             elog( INFO, "idxcd IS NULL" );
>             continue; /* Or is that fatal enough to break instead? */
>         )
>
>         if (!idxcd->idxused)
>             continue;
>
>
>
> Alban Hertroys
> --
> There is always an exception to always.
>
>
>
>
>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: The connection to the server was lost. Attempting reset: Failed.
  2019-10-10 15:55 The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 16:15 ` Re: The connection to the server was lost. Attempting reset: Failed. Alban Hertroys <haramrae@gmail.com>
@ 2019-10-10 19:43   ` Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 19:56     ` Re: The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  1 sibling, 1 reply; 10+ messages in thread

From: Yessica Brinkmann @ 2019-10-10 19:43 UTC (permalink / raw)
  To: Alban Hertroys <haramrae@gmail.com>; pgsql-general

Thank you very much for your answer.
It helped me.
Really now the get_columnnames function is already working and ends cleanly.
I have an error in the following function to be executed that generates the
same error: The connection to the server was lost. Attempting reset:
Failed. I will try to solve it alone and if I cannot write another new mail
thread.
Because this problem of get_columnnames is already solved.
Many thanks,
Best regards,
Yessica Brinkmann

El jue., 10 oct. 2019 a las 13:15, Alban Hertroys (<haramrae@gmail.com>)
escribió:

>
> > On 10 Oct 2019, at 17:55, Yessica Brinkmann <yessica.brinkmann@gmail.com>
> wrote:
> >
> > I really thought a lot, but I don't understand why but the function
> fails after the expression is executed:
> > appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""), idxcd->
> varattno [i]);
> > The error appears only to me when entering the cycle:
> > foreach (cell, candidates) / * foreach cell in candidates * /
> > more than once, that is, when you have more than one candidate index. If
> the cycle is entered only once, the function works correctly.
> > The error that appears to me is that the connection to the PostgreSQL
> server is directly lost. I proved that the error occurs in that statement,
> printing some values.
>
> There is probably an error in the Postgres log-file providing you more
> info.
>
> That said, at least the below bit in your code is dangerous:
>
>     foreach( cell, candidates ) /* foreach cell in candidates */
>     {
>
>         idxcd = (IndexCandidate*)lfirst( cell );
>
>         if( !idxcd->idxused )
>             continue;
>
>         if (idxcd!=NULL)
>         {
>
>
> You should at least check for NULL before referencing an attribute of that
> structure. Personally, I would invert the test like so (and then move it
> before the idxused test:
>
>         if (idxcd == NULL) {
>             elog( INFO, "idxcd IS NULL" );
>             continue; /* Or is that fatal enough to break instead? */
>         )
>
>         if (!idxcd->idxused)
>             continue;
>
>
>
> Alban Hertroys
> --
> There is always an exception to always.
>
>
>
>
>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread

* Re: The connection to the server was lost. Attempting reset: Failed.
  2019-10-10 15:55 The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
  2019-10-10 16:15 ` Re: The connection to the server was lost. Attempting reset: Failed. Alban Hertroys <haramrae@gmail.com>
  2019-10-10 19:43   ` Re: The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
@ 2019-10-10 19:56     ` Yessica Brinkmann <yessica.brinkmann@gmail.com>
  0 siblings, 0 replies; 10+ messages in thread

From: Yessica Brinkmann @ 2019-10-10 19:56 UTC (permalink / raw)
  To: Alban Hertroys <haramrae@gmail.com>; pgsql-general

That is,
It worked by changing the code to:

 if (idxcd == NULL) {
            elog( INFO, "idxcd IS NULL" );
            continue; /* Or is that fatal enough to break instead? */
        }

        if (!idxcd->idxused)
            continue;

Very thanks,
Yessica Brinkmann

El jue., 10 oct. 2019 a las 16:43, Yessica Brinkmann (<
yessica.brinkmann@gmail.com>) escribió:

> Thank you very much for your answer.
> It helped me.
> Really now the get_columnnames function is already working and ends
> cleanly.
> I have an error in the following function to be executed that generates
> the same error: The connection to the server was lost. Attempting reset:
> Failed. I will try to solve it alone and if I cannot write another new mail
> thread.
> Because this problem of get_columnnames is already solved.
> Many thanks,
> Best regards,
> Yessica Brinkmann
>
> El jue., 10 oct. 2019 a las 13:15, Alban Hertroys (<haramrae@gmail.com>)
> escribió:
>
>>
>> > On 10 Oct 2019, at 17:55, Yessica Brinkmann <
>> yessica.brinkmann@gmail.com> wrote:
>> >
>> > I really thought a lot, but I don't understand why but the function
>> fails after the expression is executed:
>> > appendStringInfo (& cols, "% s a.attnum =% d", (i> 0? "OR": ""),
>> idxcd-> varattno [i]);
>> > The error appears only to me when entering the cycle:
>> > foreach (cell, candidates) / * foreach cell in candidates * /
>> > more than once, that is, when you have more than one candidate index.
>> If the cycle is entered only once, the function works correctly.
>> > The error that appears to me is that the connection to the PostgreSQL
>> server is directly lost. I proved that the error occurs in that statement,
>> printing some values.
>>
>> There is probably an error in the Postgres log-file providing you more
>> info.
>>
>> That said, at least the below bit in your code is dangerous:
>>
>>     foreach( cell, candidates ) /* foreach cell in candidates */
>>     {
>>
>>         idxcd = (IndexCandidate*)lfirst( cell );
>>
>>         if( !idxcd->idxused )
>>             continue;
>>
>>         if (idxcd!=NULL)
>>         {
>>
>>
>> You should at least check for NULL before referencing an attribute of
>> that structure. Personally, I would invert the test like so (and then move
>> it before the idxused test:
>>
>>         if (idxcd == NULL) {
>>             elog( INFO, "idxcd IS NULL" );
>>             continue; /* Or is that fatal enough to break instead? */
>>         )
>>
>>         if (!idxcd->idxused)
>>             continue;
>>
>>
>>
>> Alban Hertroys
>> --
>> There is always an exception to always.
>>
>>
>>
>>
>>

^ permalink  raw  reply  [nested|flat] 10+ messages in thread


end of thread, other threads:[~2019-10-10 19:56 UTC | newest]

Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-10-10 15:55 The connection to the server was lost. Attempting reset: Failed. Yessica Brinkmann <yessica.brinkmann@gmail.com>
2019-10-10 16:14 ` Tom Lane <tgl@sss.pgh.pa.us>
2019-10-10 16:33   ` Yessica Brinkmann <yessica.brinkmann@gmail.com>
2019-10-10 18:01     ` Yessica Brinkmann <yessica.brinkmann@gmail.com>
2019-10-10 18:25       ` Jaime Soler <jaime.soler@gmail.com>
2019-10-10 18:35         ` Yessica Brinkmann <yessica.brinkmann@gmail.com>
2019-10-10 16:15 ` Alban Hertroys <haramrae@gmail.com>
2019-10-10 16:38   ` Yessica Brinkmann <yessica.brinkmann@gmail.com>
2019-10-10 19:43   ` Yessica Brinkmann <yessica.brinkmann@gmail.com>
2019-10-10 19:56     ` Yessica Brinkmann <yessica.brinkmann@gmail.com>

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