db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jorge Uriarte <jorge.uria...@omelas.net>
Subject IDBROKER generated ids suddenly becomes HUGE
Date Thu, 28 Apr 2005 17:25:12 GMT
Hi there,

out there in Scarab we're facing a strange bug that is driving us crazy.
We're currently using torque-3.1.1 and torque-gen-3.1.1-dev

You can take a look at the bug here (no user required):


The problem, in a few words, is that "sometimes" (recipe still missing)
the ID number returned by the IDBROKER is HUGEEEE.
The value is not the primary key for a table (its the number part of the
issue ID, you know scarab  ;-)  ).

I guess the code below (java, and id_table.xml) is the responsible:
(full code here http://svn.collab.net/viewcvs/scarab/trunk/src

It's *old* code, and I don't really know why did it started failing, but 
I somehow don't dare to change it...
There are several things I don't understand in it:
* It seems to expect the first call to getIdAsInt failing, and then it
tries again synchronizing the call...
* If it fails again, it asumes it does not exist (!) and then starts the
count from 1 (this might be to make sure it finds a record in ID_TABLE
for a new module)

     private int getNextIssueId(Connection con)
         throws Exception
         int id = -1;
         String key = getIdTableKey();
         DatabaseMap dbMap = IssuePeer.getTableMap().getDatabaseMap();
         IDBroker idbroker = dbMap.getIDBroker();
             id = idbroker.getIdAsInt(con, key);
         catch (Exception e)
             synchronized (idbroker)
                     id = idbroker.getIdAsInt(con, key);
                 catch (Exception idRetrievalErr)
                     // a module code entry in the id_table was likely
                     // entered, insert a row into the id_table and try
                         id = 1;
                     catch (Exception badException)
                         getLog().error("Could not get an id, even after
                             +"trying to add a module entry into the
                             .error("Error trying to create ID_TABLE
entry for "
                                    + getIdTableKey(), badException);
                         // throw the original
                         throw new ScarabException(
         return id;

This is the definition of the ID_TABLE:

<database name="scarab">
   <table name="ID_TABLE" idMethod="idbroker">
     <column name="ID_TABLE_ID" required="true" primaryKey="true"
     <column name="TABLE_NAME" required="true" size="255"
     <column name="NEXT_ID" type="INTEGER"/>
     <column name="QUANTITY" type="INTEGER"/>

       <unique-column name="TABLE_NAME"/>


Any hint about where the problem would be?
Any idea about why is this code so *strange*?



To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org

View raw message