Thread: Table dublicates values

Table dublicates values

From
Deniz Atak
Date:
Hi all,

I am using postgresql on Glassfish server. When I restart the server for some reason, one of my databases' tables duplicates the values. For example aTable is from aDatabase:

select * from aTable
 col1                | col2
-----------------------+---------
 text/html         |    1672
 text/javascript |     374
 text/css          |      94
 text/xml          |      21
 text/plain        |      14
 text/html         |    1672
 text/javascript |     374
 text/css          |      94
 text/xml          |      21
 text/plain         |      14

Do you have any opinion why this is happening? I can write a workaround code to handle this situtation but I want to learn the reason for this. If someone has any opinion about this issue it will be highly appreciated. Thanks in advance.

Re: Table dublicates values

From
Rob Sargent
Date:

Deniz Atak wrote:
> Hi all,
>
> I am using postgresql on Glassfish server. When I restart the server
> for some reason, one of my databases' tables duplicates the values.
> For example aTable is from aDatabase:
>
> select * from aTable
>  col1              | col2
> -------------------+---------
>  text/html         |    1672
>  text/javascript   |     374
>  text/css          |      94
>  text/xml          |      21
>  text/plain        |      14
>  text/html         |    1672
>  text/javascript   |     374
>  text/css          |      94
>  text/xml          |      21
>  text/plain        |      14
>
> Do you have any opinion why this is happening? I can write a
> workaround code to handle this situtation but I want to learn the
> reason for this. If someone has any opinion about this issue it will
> be highly appreciated. Thanks in advance.
>

Is any ORM in the picture (TOPLink, hybernate)?  These can be set to
fire DDL automatically.  Turn on sql-logging.

Alternatively, find the code that is supposed to populate it once, and
make sure it only gets called once.  No Postgres feature is going to do
that accidentally.


Re: Table dublicates values

From
Adrian Klaver
Date:
On Saturday, July 16, 2011 1:47:50 am Deniz Atak wrote:
> Hi all,
>
> I am using postgresql on Glassfish server. When I restart the server for
> some reason, one of my databases' tables duplicates the values. For example
> aTable is from aDatabase:
>
> select * from aTable
>  col1                | col2
> -----------------------+---------
>  text/html         |    1672
>  text/javascript |     374
>  text/css          |      94
>  text/xml          |      21
>  text/plain        |      14
>  text/html         |    1672
>  text/javascript |     374
>  text/css          |      94
>  text/xml          |      21
>  text/plain         |      14
>
> Do you have any opinion why this is happening? I can write a workaround
> code to handle this situtation but I want to learn the reason for this. If
> someone has any opinion about this issue it will be highly appreciated.
> Thanks in advance.

If it is possible, put a unique index on the (col1,col2) combination and check
the logs for the action that trips the index. My wild guess is that the
application is caching values that are then flushed to the server on restart.

--
Adrian Klaver
adrian.klaver@gmail.com

Re: Table dublicates values

From
Adrian Klaver
Date:
On 07/18/2011 12:39 AM, Deniz Atak wrote:

CC'ing the list.

> Rob, yes, I have EJB 3.0 for ORM. Do  you know how to turn on sql
> logging? I couldn't find a resource about that up to now.

Google + glassfish sql logging found this:

http://www.java.net/node/700613

To turn on/up Postgres logging see:
http://www.postgresql.org/docs/9.0/interactive/runtime-config-logging.html

>
> Adrian, unfortunately it is not possible to put another column in my case.

Don't know if it makes a difference but I was suggesting adding an index
not a column.

>
> Thanks for your kind support.
> Deniz
>



--
Adrian Klaver
adrian.klaver@gmail.com