Re: Fix for a problem with auto reconnection

From: Dave Page <dpage(at)pgadmin(dot)org>
To: Christoph Zwerschke <cito(at)online(dot)de>, Ashesh Vashi <ashesh(dot)vashi(at)enterprisedb(dot)com>
Cc: pgadmin-hackers <pgadmin-hackers(at)postgresql(dot)org>
Subject: Re: Fix for a problem with auto reconnection
Date: 2013-11-15 01:13:51
Message-ID: CA+OCxoz+sPdtx-Rw-ScvQszzPTSr_YBf3jm+=NxFsuT1Tqg_Cw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

Ashesh, can you look at this please?

Thanks for the report and investigation Christoph.

On Thu, Nov 14, 2013 at 7:04 PM, Christoph Zwerschke <cito(at)online(dot)de> wrote:
> My colleagues and I recently stumbled over a quite perplexing issue with
> pgadmin3 (1.18.1), namely that the pgadmin query tool sometimes did not show
> values in the database which were definitely set.
>
> After further investigation it turned out that this happened when the values
> contained non-ascii characters and after the database connection had been
> reset by pgadmin (which happened sometimes when the database was restarted
> or there was a timeout in the firewall), and if that reset happened via the
> query tool window, not via the main window.
>
> The explanation for this behavior is obvious: The connection is reset with
> conn->Reset() in frm/frmQuery.cpp, but the Reset() method does not set the
> client side encoding for the connection to match the encoding of the
> database, as is done in DoConnect(). It also fails to do some other things
> that DoConnect() cares about, such as setting the DateStyle to ISO and
> setting the default role. This could cause additional problems.
>
> So my solution was to replace the call to conn->Reset() with a call to
> conn->Reconnect() which essentially does the same, but calls DoConnect()
> internally so that everything gets initialized.
>
> This fix works nicely for me. Another solution would be to add the
> initialization code in DoConnect() to the Reset() method as well.
>
> Here are the steps to reproduce the problem:
>
> * Open the SQL query tool and create a test table like this:
>
> create table t(a varchar , b varchar);
> insert into t values ('Wurst', 'Käse');
>
> * Query the table with "select * from t".
> You should get "Wurst" and "Käse".
>
> * Kill the server process for the connection
>
> * Query the table again with "select * from t".
> You should get a Fatal error: connection lost.
>
> * Rerun the query.
> You should now get a dialog box asking
> "... attempt to reconnect ... ?"
>
> * Answer "Yes".
> You should get the message "Connection reset."
>
> * Rerun the query.
> Now you get the query result again,
> but this time only with the cell "Wurst";
> the cell that should say "Käse" stays empty.
>
>
> --
> Sent via pgadmin-hackers mailing list (pgadmin-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers

--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Ashesh Vashi 2013-11-15 05:13:53 Re: Fix for a problem with auto reconnection
Previous Message Dave Page 2013-11-15 01:08:00 Re: Support for non standard SSH port