Note that there are some explanatory texts on larger screens.

plurals
  1. POpostgres + hibernate, sequence in database is negative, why?
    primarykey
    data
    text
    <p>we have a very strange behaviour on our productions system.</p> <ol> <li>db: posgres 9.0.13</li> <li>spring: 3.1.2.RELEASE</li> <li>hibernate: 3.5.3-Final</li> <li>clustered tomcat setup with 5 tomcats running the same web app and accessing the same db</li> <li>table 'mails' roundabout 80.000.000 rows</li> </ol> <p>our postgres sequence:</p> <pre><code>\d mails_id_seq Sequence "public.mails_id_seq" Column | Type | Value ---------------+---------+--------------------- sequence_name | name | mails_id_seq last_value | bigint | 64728416 start_value | bigint | 1 increment_by | bigint | 1 max_value | bigint | 9223372036854775807 min_value | bigint | 1 cache_value | bigint | 1 log_cnt | bigint | 12 is_cycled | boolean | f is_called | boolean | t \d mails \d mails Table "public.mails" Column | Type | Modifiers ---------------+-----------------------------+----------- id | integer | not null ....... </code></pre> <p>hibernate mapping of the sequence:</p> <p>in plain old xml</p> <pre><code>&lt;id name="id" column="id" type="integer"&gt; &lt;generator class="sequence"&gt; &lt;param name="sequence"&gt;mails_id_seq&lt;/param&gt; &lt;/generator&gt; &lt;/id&gt; </code></pre> <p>and JPA</p> <pre><code>@Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "mails_id_sequence") private int id; </code></pre> <p>problem:</p> <p>we have loads of negative numbers as id column - and i have no clue where they come from.</p> <p>e.g.</p> <pre><code>SELECT id from mails order by date desc limit 20; id ------------- -1061189751 64675701 64675700 -1061183780 64675699 -1061188135 -1061183781 -1061183782 -1061190524 64675698 64675697 64675696 -1061189086 -1061183783 -1061183784 -1061189752 -1061188136 -1061183785 -1061189753 -1061189087 (20 rows) select date_trunc('month', date), min(id), max(id) from mails where id &lt; 1 group by 1 order by 1; date_trunc | min | max ---------------------+-------------+------------- 2011-11-01 00:00:00 | -1719265246 | -1697584933 2011-12-01 00:00:00 | -1697584932 | -1646904070 2012-01-01 00:00:00 | -1646904069 | -1583272560 2012-02-01 00:00:00 | -1583272559 | -1535772936 2012-03-01 00:00:00 | -1535792803 | -1500721344 2012-04-01 00:00:00 | -1500728054 | -1467115794 2012-05-01 00:00:00 | -1467125218 | -1435499591 2012-06-01 00:00:00 | -1435512613 | -1404295391 2012-07-01 00:00:00 | -1404307470 | -1371674696 2012-08-01 00:00:00 | -1371685552 | -1339094928 2012-09-01 00:00:00 | -1339106811 | -1307258065 2012-10-01 00:00:00 | -1307266574 | -1273922095 2012-11-01 00:00:00 | -1274667945 | -1244428790 2012-12-01 00:00:00 | -1255313231 | -1217789919 2013-01-01 00:00:00 | -1217857051 | -1183437272 2013-02-01 00:00:00 | -1183488949 | -1153262500 2013-03-01 00:00:00 | -1153277010 | -1123106036 2013-04-01 00:00:00 | -1123137957 | -1095481993 2013-05-01 00:00:00 | -1095498223 | -1067058535 2013-06-01 00:00:00 | -1067083223 | -1061174790 select date_trunc('month', date), count(*) from mails where id &lt; 1 group by 1; date_trunc | count ---------------------+-------- 2011-11-01 00:00:00 | 95360 2011-12-01 00:00:00 | 218360 2012-01-01 00:00:00 | 294554 2012-02-01 00:00:00 | 417913 2012-03-01 00:00:00 | 539100 2012-04-01 00:00:00 | 569667 2012-05-01 00:00:00 | 612164 2012-06-01 00:00:00 | 614076 2012-07-01 00:00:00 | 657972 2012-08-01 00:00:00 | 662931 2012-09-01 00:00:00 | 684952 2012-10-01 00:00:00 | 663296 2012-11-01 00:00:00 | 580336 2012-12-01 00:00:00 | 567856 2013-01-01 00:00:00 | 732353 2013-02-01 00:00:00 | 689715 2013-03-01 00:00:00 | 710528 2013-04-01 00:00:00 | 652021 2013-05-01 00:00:00 | 718845 2013-06-01 00:00:00 | 126313 </code></pre> <p>we have no idea if this problem is a postgres, hibernate or a mixture of both.</p> <p>does anybody have any idea where this problem could come from?</p> <p>any help highly appreciated</p> <p>cheers marcel</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload