QUEUE locking problem

I just made 2 sample programs, the first one writes in a queue and the other reads from the queue. It seem when one of the process die (ex kill -9) between a put or get operation, the locks persist blocking all the operations (corrupting the database). The sample programs I made are the followings.
Writer program
#include <db.h>
#include <string.h>
#include <stdio.h>
#define OP_SIZE 80
main(int argc, char *argv[])
DB *dbp;
DBT clave, dato;
DB_ENV *env;
u_int32_t flags;
db_recno_t rn=0;
int ret, i=0,locks;
int maxins=10;
long id=0;
char szOp[SIZE_OP+1];
ret = db_env_create(&env, 0);
ret = env->open(env, "/disk9/tqueue", DB_CREATE | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN | DB_REGISTER|DB_THREAD, 0);
if(ret)
printf("ERROR : Abriendo ambiente %s",db_strerror(ret));
if (argc > 1)
maxins = atoi(argv[1]);
ret = db_create(&dbp, env, 0);
if(ret != 0) {
printf("ERROR : Creando bdd %s", db_strerror(ret));
flags = DB_CREATE;
ret = dbp->set_re_len(dbp, SIZE_OP);
ret = dbp->open(dbp, NULL, "mi_bdd.db", NULL, DB_QUEUE, flags, 0);
if(ret != 0) {
dbp->err(dbp, ret, "Falla en apertura");
memset(szOp, 0, SIZE_OP+1);
memset(&clave, 0, sizeof(clave));
memset(&dato, 0, sizeof(dato));
while(i < maxins) {
sprintf(szOp, "%020d", id);
clave.data = &rn;
clave.size = sizeof(rn);
dato.data = szOp;
dato.size = strlen(szOp);
printf("Insertando par (%d, %s)\n", id, szOp);
ret = dbp->put(dbp, NULL, &clave, &dato, DB_APPEND);
printf("clave: %d\n", rn);
if(ret) {
switch(ret) {
case DB_KEYEXIST:
dbp->err(dbp, ret, "Falla en escritura, llave %d existe", id);
break;
case EINVAL:
dbp->err(dbp, ret, "Falla en escritura, llave %d EINVAL", id);
break;
default:
dbp->err(dbp, ret, "ERROR:");
id++;
i++;
dbp->close(dbp, 0);
env->close(env, 0);
Reader Program
#include <db.h>
#include <string.h>
#include <stdio.h>
#define OP_SIZE 80
main(int argc, char *argv[])
DB *dbp;
DBT clave, dato;
DB_ENV *env;
u_int32_t flags;
int ret, i=0,locks;
long id=0;
char szOp[OP_SIZE+1];
memset(szOp, 0, OP_SIZE+1);
ret = db_env_create(&env, 0);
ret = env->open(env, "/disk9/tqueue", DB_CREATE | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN |DB_REGISTER |DB_THREAD, 0);
if(ret)
printf("ERROR : opening enviroment %s", db_strerror(ret));
ret = db_create(&dbp, env, 0);
if(ret != 0) {
dbp->err(dbp, ret, "ERROR:");
flags = 0;
ret = dbp->open(dbp, NULL, "mi_bdd.db", NULL, DB_UNKNOWN, flags, 0);
ret = dbp->stat_print(dbp, 0);
if(ret != 0) {
dbp->err(dbp, ret, "Fail Opening");
memset(&clave, 0, sizeof(clave));
memset(&dato, 0, sizeof(dato));
if(argc > 1)
id = atoi(argv[1]);
clave.data = &id;
clave.size = sizeof(id);
dato.data = szOp;
dato.ulen = OP_SIZE;
dato.flags = DB_DBT_USERMEM;
ret = 0;
while(ret == 0) {
ret = dbp->get(dbp, NULL, &clave, &dato, DB_CONSUME_WAIT);
printf("%d: Registro id:%d, dat: %s\n", i, id, szOp);
if(ret) {
switch (ret) {
case DB_NOTFOUND:
dbp->err(dbp, ret, "KEY %d DOES NOT", id);
break;
default:
dbp->err(dbp, ret, "ERROR:");
i++;
dbp->close(dbp, 0);
//env->close(env, 0);
I alredy tried the following flags combination for opening the enviroment.
flags = DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_RECOVER
flags= DB_CREATE | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN
Message edited to add the writer program

Hi Rodrigo,
It looks like you've posted the same program twice.
There are a number of reasons to include transactional support in your applications, and the principal one is recoverability. I don't know if for the writer you are using transactions.
For the reader, you can use DB_RDONLY when opening the db.
How do you run the applications?
A good point to start with, is to run the txn_guide.c example from your Berkeley DB distribution \examples_c\txn_guide.
Also, reading the "Berkeley DB Transactional Data Store Applications" and "The Locking Subsystem" chapters from Berkeley DB Reference Guide, can help you in merging your application with Berkeley DB.
Regards,
Bogdan Coman

Similar Messages

  • Locking problem in VL02N at the time Post Goods issue

    Hi,
    We have implemented 2 BADIs to change qty in delivery and in subsequent documents. Once we receive an IDoc with batches, then we need to change subitems qty according to no of batches.
    Once IDoc has updated, then PGI will do automatically.
    1. LE_SHP_DELIVERY_PROC     - Change qty in delivery (Method SAVE_DOCUMENT_PREPARE)
    2. LE_SHP_GOODSMOVEMENT - Change qty in material document.
    Now, we have a locking problem at the time of posting.
    Please let us know, due to these BADI implementation this problem or any other cause? And provide required to solve this problem.

    hi ,
    do i need to do step 2....?
    i dont think u need step2 ( change qty of MBLNR),bcos ,
    say ur Del.qty is 100, now u want to do del. of 50, then just u will change its qty & do PGI ? so whats the need of changing MBLNR.
    while doing PGI , program will take changed qty of del. only ?
    let me know if i'm wrong.
    regards
    Prabhu

  • Forms 6i : Ole Container : Locking problem

    We have a form in which user can attach all sorts of documents that are then saved in the database.
    Once in a while we have a locking problem; when 2 users try to open the same document, the second one first gets a 'Could not reserve record (2 tries). Keep trying?'. When clicking 'No', the next error message is 'Frm-40501 : unable to reserve record for update or delete', and the form cannot be used anymore. He keeps complaining about the reserved record.
    I've been looking into this problem but cannot seem to find a lot of help.
    Does anyone have an idea how to solve this locking problem?
    I have tried the following things:
    * setting the block to locking mode 'Delayed' => we ended up having duplicate records.
    * Changing properties of the ole-container (In Place Activation, Inside Out support, ...).
    Forms version is 6.0.8.13.0, database 8.0.6.0.0.
    Any help is appreciated.

    that seems to be a normal locking problem. Do you have tried to work with an ON-LOCK trigger ? (e.g. first to see, when locking will occur, second for implementing an own locking-behaviour, maybe with a SELECT for UPDATE)
    Or do you think, that there is something special with your OLE-programming ?
    Gerd

  • Lock Problem while Broadcasting multiple reports using process chains

    Hi All,
    I am trying to broadcast 10 reports using the process chains using the program for RSRD_START and variants created in the Broadcaster..the Program jobs start fine.But I am facing the error that the RSRA_CA_LOG table is getting locked while trying to broadcast the Reports..Can any help me on how to run the jobs without the locking problem..Suggestions please.
    Thanks,
    Mike.

    Hi,
    Thanks for the Inputs and the SAP Notes.
    I am trying to broadcast the Reports from the the Bex Analyer and getting this ock error and not the workbooks.
    I am also trying to Broadcast the Workbooks also, but could not find the options to Broadcast them. we are in SAP -BW3.5 SP 12, Is it possible to broadcast the workbooks in this Patch level..or do we need to upgrade to achieve this.If so...can any one provide me the proceedure to  Broadcast the Workbooks.
    Thanks,
    Mike.

  • Oracle Advanced Queuing - Propagation problem - 11g

    Hi,
    I have a problem when propagation messages between queues. When the message is propagated, it stays on the source queue with READY state.
    I have created two queues on 11g with a propagation rule that any message from queue A are sent to queue B. My problem is that the message from the source queue stays in the source queue even after propagation, which isn't what I was expecting. The problem doesn't occur if the queues are on a different database. This problem only happens if the queues are on the same database.
    the script I use is this:
    For USERB (which has the destination queue)
    create type EVENT_MESSAGE as object (
    eventsource VARCHAR2(30),
    eventname VARCHAR2(255),
    eventid NUMBER(19,0),
    message CLOB
    DECLARE
    an_agent sys.aq$_agent;
    BEGIN
    -- create the publish/subscribe queue table
    dbms_aqadm.create_queue_table(
    queue_table => 'DESTINATION_QUEUE_TABLE',
    queue_payload_type=>'EVENT_MESSAGE',
    sort_list => 'ENQ_TIME',
    message_grouping => DBMS_AQADM.NONE,
    multiple_consumers=>true
    -- create the queue
    dbms_aqadm.create_queue(
    queue_name => 'DESTINATION',
    queue_table => 'DESTINATION_QUEUE_TABLE',
    queue_type => DBMS_AQADM.NORMAL_QUEUE,
    max_retries => 5
    dbms_aqadm.create_aq_agent(agent_name =>'DEQUEUE_AGENT');
    an_agent := sys.aq$_agent('DEQUEUE_AGENT', null, null);
    dbms_aqadm.enable_db_access(
    agent_name => 'DEQUEUE_AGENT',
    db_username => 'USERB'
    dbms_aqadm.add_subscriber(
    queue_name => 'DESTINATION',
    subscriber => an_agent,
    queue_to_queue => FALSE,
    delivery_mode => DBMS_AQADM.PERSISTENT
    -- start the queues
    dbms_aqadm.start_queue('DESTINATION');
    END;
    For USERA
    create type EVENT_MESSAGE as object (
    eventsource VARCHAR2(30),
    eventname VARCHAR2(255),
    eventid NUMBER(19,0),
    message CLOB
    BEGIN
    -- create the publish/subscribe queue table
    dbms_aqadm.create_queue_table(
    queue_table => 'SOURCE_QUEUE_TABLE',
    queue_payload_type=>'EVENT_MESSAGE',
    sort_list => 'ENQ_TIME',
    message_grouping => DBMS_AQADM.NONE,
    multiple_consumers=>true
    -- create the queue
    dbms_aqadm.create_queue(
    queue_name => 'SOURCE',
    queue_table => 'SOURCE_QUEUE_TABLE',
    queue_type => DBMS_AQADM.NORMAL_QUEUE,
    max_retries => 5
    -- start the queues
    dbms_aqadm.start_queue('SOURCE');
    -- create the propagation
    dbms_aqadm.add_subscriber(queue_name => 'SOURCE',
    subscriber => sys.aq$_agent('DEQUEUE_AGENT','USERB.DESTINATION',null),
    queue_to_queue => true);
    dbms_aqadm.schedule_propagation(queue_name => 'SOURCE',
    start_time => sysdate,
    latency => 25,
    destination_queue => 'USERB.DESTINATION');
    END;
    When I enqueue a message to the source on USERA with this:
    declare
    rc binary_integer;
    nq_opt dbms_aq.enqueue_options_t;
    nq_pro dbms_aq.message_properties_t;
    datas EVENT_MESSAGE;
    msgid raw(16);
    begin
    nq_pro.expiration := dbms_aq.never;
    nq_pro.sender_id := sys.aq$_agent('ENQUEUE_AGENT', null, null);
    datas := AGEAS_EVENT_MESSAGE('message','eventname',1,null);
    dbms_aq.enqueue('SOURCE',nq_opt,nq_pro,datas,msgid);
    end;
    The message is propagated to the destination queue, no problem, but the message state on the source queue is kept as ready. I would have expected it to be marked as processed and disappear from the queue table.
    When I look at the AQ$_SOURCE_QUEUE_TABLE_S the I see these records:
         QUEUE_NAME     NAME     ADDRESS     PROTOCOL      SUBSCRIBER TYPE
         SOURCE     (null)     "USERB"."DESTINATION"@AQ$_LOCAL     0     1736
         SOURCE     DEQUEUE_AGENT     "USERB"."DESTINATION"     0     577
    Can anyone help?

    I was talking about following oracle documentations:
    Oracle Database 11g: Advanced Queuing (Technical Whitepaper)
    Streams Advanced Queuing: Best Practices (Technical Whitepaper)
    Oracle Streams Advanced Queuing and Real Application Clusters: Scalability and Performance Guidelines (Technical Whitepaper)
    They are available at.. http://www.oracle.com/technetwork/database/features/data-integration/default-159085.html

  • WSRM queue lock in ERP system

    Hi Guys,
    We are constantly facing wsrm queue locking issue in production and its creates huge impact when the interface is EOIO where if any particular queue gets lock then rest of the messages/units of that particular queue doesnt get execute.
    We have observed this issue after SPS upgrade has been done on the ERP system.
    Can any one help as why the wsrm queues are getting locked so often?
    Thanks.
    Aki

    Hi Guys,
    We are constantly facing wsrm queue locking issue in production and its creates huge impact when the interface is EOIO where if any particular queue gets lock then rest of the messages/units of that particular queue doesnt get execute.
    We have observed this issue after SPS upgrade has been done on the ERP system.
    Can any one help as why the wsrm queues are getting locked so often?
    Thanks.
    Aki

  • Activation lock problem!

    Hello,
    I just got a new iPhone 4s from a friend and I can't get into it because of an activation lock problem. I've already tried to restore it in recovery mode but than I still have to log in to his account. Now i've logged in to his iCloud account and deleted the iPhone using the following instructions:
    Sign in to their iCloud account at www.icloud.com/find.
    Click All Devices to open a list of devices linked to their account, then select the device to be removed. It should show a gray dot or the word “Offline” next to the device name.
    Click "Remove from Account" to remove the device from their account.
    But it seems that I have should done the following instructions, because the iPhone wasn't completely erased yet:
    Sign in to their iCloud account at www.icloud.com/find.
    Click All Devices to open a list of devices linked to their account, then select the device to be removed.
    Click the Erase button to erase all content and settings from the device. When prompted, don't enter a phone number or message. Click Next until the device is erased.
    When the erase is complete, click "Remove from Account" to remove the device from the account.
    The problem is that it's too late for that now, because I already deleted the iPhone from his iCloud... Please help me out here, what can I do to still erase it from iCloud?!
    Greets

    Were you, by chance, running a beta version of iOS 7 on your phone?
    If so, this will be the problem. You will need to log Into the private developers forum athttps://developer.apple.com/support/ios/
    If you are not a developer, you will need to seek help by way of your favourite search site.

  • JavaScript error and CATW record locking problem

    Hello,
    We're having two problems with ESS (CATW and Personal Information (PZM3)) in EP 6. We have an ITS-R/3 landscape.
    The JavaScript problem appears intermittently within Personal Data services (Address, Emergency Contact, ...). The actual error reads "object required" and originates from ITS. A user may be able to click through all the ESS services once fine, but on a second click receive the error. Sometimes they can't use the services at all.
    The record locking problem happens in Time Sheet (CATW). Even though a user Saves and Releases the Time Sheet, it remains locked and cannot be approved. Alternatively, some users are experiencing locked records when they try to complete their own time sheets.
    I'm not sure if these are related.
    Has anyone here seen these problems? Any suggestions are most welcome!
    Cheers,
    Colleen

    The best way to nail down the javascript error would be to use the firefox JavaScript debugger extension plugin and put the breakpoints where the problem occurs.
    This will exactly tell you which object it is looking for which is not found. Moreover you might be able to find that when it is working fine as you said. So give that a try and I am sure you will be able to figure out the problem.
    To me this mostly looks like at time some .js file is not coming through to the browser... but this is just a wild guess based on the symptoms.

  • Pessimistic lock problem with Sybase

    I am having a problem with performing pessimistic lock
    using Toplink and Sybase/HSQLDB.
    Code example:
    Object o = uow.readObject(...
    uow.refreshAndLock(o);
    //Change o
    uow.commitAndResume();
    ==========================
    I receive an Exception:
    Local Exception Stack:
    Exception [TOPLINK-4002] (OracleAS TopLink - 10g (9.0.4.2) (Build 040311)): oracle.toplink.exceptions.DatabaseException
    Exception Description: java.sql.SQLException: Unexpected token: FOR in statement [SELECT t0.CLASSIDENTIFIER, t0.DB_VERSION, t0.OBJECTID, t1.OBJECTID, t1.NAME, t1.DESCRIPTION, t1.TYPE, t2.OBJECTID, t2.MULTIPLE_SERVERS_POLICY, t2.OUTAGE_POLICY, t2.INCOMING_SCRIPT, t2.OUTGOING_SCRIPT, t2.OUTAGE_SCRIPT FROM ROOT t0, LDAPSERVICE t2, SERVICE t1 WHERE ((t0.OBJECTID = 252) AND (((t2.OBJECTID = t0.OBJECTID) AND (t1.OBJECTID = t0.OBJECTID)) AND (t0.CLASSIDENTIFIER = 'ORM.LdapService'))) [b]FOR UPDATE OF * NOWAIT]
    =================
    As you can see Toplink is trying to execute illegal statement : "....FOR UPDATE OF * NOWAIT"
    Do you have any idea what I'm doing wrong?

    Duplicate posting Pessimistic lock problem with Sybase

  • Dead lock problem occur in Ms-Sql Server

    Hi friends,
    I am using the 1,Tomcat server
    2, jdbc-odbc-bridge driver
    In my applicaiton .mutli user access time its throw -deadlock
    exception . How to solve the dead lock problem.. please help it.
    Can i modify the Db connection?
    please help me .... How solve the dead lock problem..
    please ............ its urgent

    I am using this stored procedure to occur dead lock condtion. Orderly insert table values ..
    Imm_tblGameTransactions- Primary Tables
    Imm_tblGameDetailsBJ - Secondary tables
    Please check it.....
    Please explain breifly..... ....
    please.........
    CREATE     procedure IMM_BJDeal 
         @plid int,
         @gameid int,
         @betamt money,
         @bal    money,
         @winamt money,
         @usercards nvarchar(500),
         @dealercards nvarchar(500),
         @useracecnt     int,
         @dealeracecnt   int,
         @dealerbj int,
         @userbj      int,
         @insurance   int,
         @split       int,
         @push        int,
         @sessionid   int, 
         @ltransid    int out
    as
        begin
         declare
                @transdate datetime,
                @linitbal  money,
                @lfinalbal money,
                @errormesg  varchar(50)
           select @linitbal=balance from Imm_players.dbo.Imm_tblPlayerbalance where playerid=@plid
           select @transdate=getdate()
              --set @ldealcards ='['+@dealercard1+','+@dealercard2+']'
              --print  @ldealcards
       if(@userbj=1)
           begin
                  select @lfinalbal= @bal
              begin transaction
                    insert into Imm_tblGameTransactions
                              (playerid,gameid,Initialbalance,transactiondate,betamount,winamount,currencycode,finalbalance,sessionid)
                                      values(@plid,@gameid,@linitbal,@transdate,@betamt,@winamt,'USD',@lfinalbal,@sessionid)
                             IF @@ERROR <> 0
                                  Begin
                                    -- There's an error b/c @ERROR is not 0, rollback
                                         ROLLBACK
                                       return
                                  End
                    select @ltransid=@@identity from Imm_tblGameTransactions
                   insert into Imm_tblGameDetailsBJ(transid,playercard,dealercard,typeid,result,statusid,split,insurance,playercardcount,dealercardcount,winvalue,betvalue)
                                         values(@ltransid,@usercards,@dealercards ,1,1,'PB',@split,@insurance,@useracecnt,@dealeracecnt,@winamt,@betamt)
                    IF @@ERROR <> 0
                   begin
                     -- There's an error b/c @ERROR is not 0, rollback
                          ROLLBACK
                        return
                   end
                   update Imm_players.dbo.Imm_tblPlayerbalance set balance=@lfinalbal where playerid=@plid
              IF @@ERROR <> 0
                   begin
                     -- There's an error b/c @ERROR is not 0, rollback
                          ROLLBACK
                        return     
                   end
                 commit transaction       
              return
           end
       else
           begin
              begin transaction
             insert into Imm_tblGameTransactions(playerid,gameid,Initialbalance,transactiondate,betamount,winamount,currencycode,finalbalance,sessionid)
                                        values(@plid,@gameid,@linitbal,@transdate,@betamt,@winamt,'USD',@bal,@sessionid)
         IF @@ERROR <> 0
              Begin
                -- There's an error b/c @ERROR is not 0, rollback
                     ROLLBACK
                   return
              End
              /*ELSE
                     COMMIT   -- Success!  Commit the transaction*/
             select @ltransid=@@identity from Imm_tblGameTransactions
             insert into Imm_tblGameDetailsBJ(transid,playercard,dealercard,typeid,result,split,insurance,playercardcount,dealercardcount,winvalue,betvalue,statusid)
                                        values(@ltransid,@usercards,@dealercards,1,3,@split,@insurance,@useracecnt,@dealeracecnt,@winamt,@betamt,'G')
         IF @@ERROR <> 0
              Begin
                -- There's an error b/c @ERROR is not 0, rollback
                     ROLLBACK
                   return
              End
              /*ELSE
                     COMMIT   -- Success!  Commit the transaction*/
              commit transaction 
              return           
             end
    end
    GO

  • Locking problem in BPS solution not getting solved  using RSPLSE. SEM_BPS_S

    Can anyone tell me exactly what "rsplse" offers to solve locking in BPS?
    We have made correct selection of characteristics (in our case "costcentre" infoobject) in tab "Lock characteristics" , but still when two people are trying to access (write) data in the same transactional cube against the different cost centres, the system is throwing an error message Cube “zIC_ccp” is locked by username.  (Or if a single person is using the two packages simultaneously using  two web sessions , he is getting the same error. )
    Our assessment is that he should not be facing this locking problem because cost centres here are acting as a “key” to different selection as configured in “rsplse”. 
    Can anyone tell me how to use parameter SEM_BPS_SAVE_UNLOCK. I want to know t. code and other t . code and other details to execute SEM_BPS_SAVE_UNLOCK.

    Hi,
    Please check the OSS note 635244.
      From the OSS note :
    <b> Notes on SET/GET parameters SEM_BPS_NO_LOCK, SEM_BPS_SAVE_UNLOCK :</b>
    These two parameters have nothing to do with the problem described above. They are only designed to facilitate the Customizing process, if users carry out Customizing in t ransaction BPS0 within a project.
    <b>SEM_BPS_NO_LOCK:</b> This parameter has the effect that transaction data is not locked at all. Never use this parameter in a production system. As of Support Package 14 for Release 3.1B, parameter SEM_BPS_NO_LOCK is released by an additional switch in table upc_dark2: For this purpose you have to maintain a record with param = ENABLE_NO_LOCK and value = X in table upc_dark2. Only then the system includes parameter SEM_BPS_NO_LOCK. The parameter can then be useful if you want to test functions or the manual planning with 'test data' in Customizing.
    <b>SEM_BPS_SAVE_UNLOCK</b>: This parameter only works in transaction BPS0; it has the effect that the system unlocks data (if possible) after it has been saved. Therefore, the system only simulates an exit and reentry in transaction BPS0 with the last active detail application. Therefore, the above parameter can be helpful if many people work on Customizing in transaction BPS0, because objects can be unlocked earlier.
    Regards,
    Siva.

  • Article says K8N Neo has SATA frequency locking problem

    This article says that the K8N Neo has SATA frequency locking problems when overclocking:
    http://www.nforcershq.com/modules.php?name=News&file=article&sid=1801
    First of all, is this true?
    And if it is true, do we have a BIOS that fixed this problem.
    My drives are PATA right now so I currently don't have any problems but I plan to get SATA drives/adapters soon.
    I'm running 240 HTT (1:1) so not having the SATA frequency locked could be an issue.

    Well, I´m running HTT 230 now, and I´m always using my Raptor as OS disk. Haven´t had any problems yet (with my disk). It´s connected to s-ata_1. Haven´t tried the other ones.
    But sometimes when I boot (200 or 230HTT, doesn´t matter) I get artifacts on the boot screen and in Windows, so I have to restart.
    Could it be a partially working AGP-lock? It seems as at works most of the time, but sometimes not... Strange... AGP is set to 66-67MHz

  • Locking problems... Help me...

    I am a novice...
    But I have a locking problem..
    First, OneRecord A is locked,
    Second, OneRecord A is also locked...
    Third, OneRecord A is also locked..
    But if OneRecord A is unlocked, then First, Second, Third All 3 OneRecord A is awaken...(because of same object....)
    so Security exception happen...(because one.getCookie() is different from cookie )
    I want to make a program in order...
    First, OneRecord A is unlock....
    Second, OneRecord A is unlock...
    Third, OneRecord A is unlock..
    What shoud i do?
    Help is appreciated...
    I am not a native speakek in English..
    Plz...
    public long lockRecord(long recNo) throws RecordNotFoundException
              int a = (int)recNo;
              if( a >= vecrecord.size() || a < 0) throw new RecordNotFoundException();
              OneRecord one = ((OneRecord)(vecrecord.elementAt(a)));
              if( one == null) throw new RecordNotFoundException();
              long cookie = 0L;
              synchronized(one)
                   if(one.isLocked())
                        try
                             one.wait();                         
                        catch(Exception e)
                   cookie = Thread.currentThread().hashCode();
                   one.setCookie(cookie);               
              return cookie;          
    public void unlock(long recNo, long cookie) throws SecurityException, RecordNotFoundException
              int a = (int)recNo;     
              if( a >= vecrecord.size()) throw new RecordNotFoundException();
              OneRecord one = ((OneRecord)(vecrecord.elementAt(a)));
              if( one == null) throw new RecordNotFoundException();
              synchronized(one)
                   if(one.isLocked())
                        if(one.getCookie() != cookie) throw new SecurityException();
                        one.setCookie(0L);     
                        one.notify();
         }     Edited by: KIMJINHO on Sep 8, 2008 1:56 PM

    I did not really understand but you should call wait inside of a loop.
    As the api for Object.wait says:
    * As in the one argument version, interrupts and spurious wakeups are
    * possible, and this method should always be used in a loopI hope this helps
    Additionally you should not catch an Exception without doing anything. At least log it or write it to the console.
    Edited by: Domi27 on Sep 8, 2008 4:18 PM

  • Num lock problem - Keeps flashing

    I've got a num lock problem on my new Macbook at the moment. It keeps on flashing randomly, even when I don't use it. And when I press it when the led isn't on, it doesn't do anythin. Any ideas what might be wrong?

    I don't think it is serious enough to return it. I have problems with my num lock and caps lock keys also, but I think it is a problem with the PMU firmware. Quite a few people are having an issue, so I don't think it is a hardware problem.
    There are also people having other problems related to the PMU, such as the coloured lines at startup. I suspect we will see a firmware update at some point that can hopefully fix it.
    My advice would be try resetting your PRAM with command-option-p-r at startup (until you hear the second chime). Or resetting the PMU by turning off the 'book. disconnecting power and taking battery out, then pressing power button for 5 seconds. Then turn it all back on again and it should be ok.
    Stay away from 10.4.7 too, it's just trouble.

  • Serious lock problem - transaction has active cursors

    Hi,
    i use BDB C via the Java-API (4.6.21, developing with WindowsXP). Currently i am having serious problems with LOCK_NOT_GRANTED_EXCEPTIONS.
    My application is a queue implementation. One push objects into the database, another one reads them and a third one deletes entries with an outdated TTL (time-to-live). All of these processes are done by multiple dedicated threads what leads to highly concurrent situations.
    The TTL cleaning uses a tx-cursor which deletes entries that are too old. The inserter simply uses put(). The reader uses a cursor too, which starts with a pointer (via getSearchKey) or at the beginning of the database (if no start could be found, the pointer is then outdated as it was deleted by TTL cleaning run).
    The isolation level is at READ_COMMITTED. Sometimes i use RMW locks for reading and updating status information.
    So i implemented a lock detection which retries at least the inserts if a lock fails. The reads can fail and report their exceptions to the outside world. This seems to work fine. Sometimes i get some LOCK_NOT_GRANTED_EXCEPTIONS and the recovery should work. But it works only sometimes.
    BDB-C complains with "transaction has active cursors" (see txn.c - line 1186). All subsequent calls to rollback or commit or any other method of BDB-C handles fails then with a RunRecoveryException. I am absolutely sure, i have no open cursors, as i close them implicitly before tx.commit() or tx.abort(). I wrote a reference counter to ensure that and it shows always a count of 0 open cursors as expected.
    The whole process is of course quite heavy stress for the DB - i am actually read, write, delete and checkpoint the db at the same position at the same time.
    I am tending to introduce MVCC to avoid those locking issues. As i understood concurrent updates of the same db page with multiversion transactions may also cause DeadLockExceptions. Can i use RMW locks to avoid concurrent updates on the same pages with MVCC?
    Some hints?
    TIA
    Dirk

    Hi,
    I have created a patch for Berkeley DB 4.6.21, which outputs information about all cursor open and close operations. This should help you see which cursor is not being closed.
    If you apply the patch below to your Berkeley DB tree, and rebuild.
    Then add setVerbose(VerboseConfig.CURSOR, true), to your EnvironmentConfig initialization.
    It will send log messages to the output stream configured via EnvironmentConfig.setMessageStream(). The default is System.out.
    There will likely be a lot of output.
    Please let me know if this helps you resolve the problem. Otherwise, ask more questions ;)
    Regards,
    Alex Gorrod
    diff -rc db-4.6.21.orig/build_windows/db.h db-4.6.21/build_windows/db.h
    *** db-4.6.21.orig/build_windows/db.h     Fri Sep 28 01:32:08 2007
    --- db-4.6.21/build_windows/db.h     Mon May 12 17:29:52 2008
    *** 60,66 ****
      #define     DB_VERSION_MAJOR     4
      #define     DB_VERSION_MINOR     6
      #define     DB_VERSION_PATCH     21
    ! #define     DB_VERSION_STRING     "Berkeley DB 4.6.21: (September 27, 2007)"
    --- 60,66 ----
      #define     DB_VERSION_MAJOR     4
      #define     DB_VERSION_MINOR     6
      #define     DB_VERSION_PATCH     21
    ! #define     DB_VERSION_STRING     "Berkeley DB 4.6.21: (May 12, 2008)"
    *** 2133,2138 ****
    --- 2133,2139 ----
      #define     DB_VERB_REGISTER     0x0010     /* Dump waits-for table. */
      #define     DB_VERB_REPLICATION     0x0020     /* Replication information. */
      #define     DB_VERB_WAITSFOR     0x0040     /* Dump waits-for table. */
    + #define     DB_VERB_CURSOR          0x0080     /* Cursor open/close information. */
           u_int32_t      verbose;     /* Verbose output. */
           void          app_private;     / Application-private handle. */
    diff -rc db-4.6.21.orig/db/db_am.c db-4.6.21/db/db_am.c
    *** db-4.6.21.orig/db/db_am.c     Thu Jun 14 04:21:30 2007
    --- db-4.6.21/db/db_am.c     Mon May 12 17:32:08 2008
    *** 283,288 ****
    --- 283,291 ----
           TAILQ_INSERT_TAIL(&dbp->active_queue, dbc, links);
           F_SET(dbc, DBC_ACTIVE);
           MUTEX_UNLOCK(dbenv, dbp->mutex);
    +      if (FLD_ISSET(dbenv->verbose, DB_VERB_CURSOR))
    +           __db_msg(dbenv,
    +               "Cursor (%p) opened, associated txn: %p", dbc, dbc->txn);
           *dbcp = dbc;
           return (0);
    diff -rc db-4.6.21.orig/db/db_cam.c db-4.6.21/db/db_cam.c
    *** db-4.6.21.orig/db/db_cam.c     Tue Jun  5 21:46:24 2007
    --- db-4.6.21/db/db_cam.c     Mon May 12 17:32:25 2008
    *** 71,76 ****
    --- 71,79 ----
           opd = cp->opd;
           ret = 0;
    +      if (FLD_ISSET(dbenv->verbose, DB_VERB_CURSOR))
    +           __db_msg(dbenv,
    +               "Cursor (%p) closed, associated txn: %p", dbc, dbc->txn);
            * Remove the cursor(s) from the active queue.  We may be closing two
            * cursors at once here, a top-level one and a lower-level, off-page
    diff -rc db-4.6.21.orig/dbinc/db.in db-4.6.21/dbinc/db.in
    *** db-4.6.21.orig/dbinc/db.in     Fri Jun 29 00:23:35 2007
    --- db-4.6.21/dbinc/db.in     Mon May 12 17:23:20 2008
    *** 2106,2111 ****
    --- 2106,2112 ----
      #define     DB_VERB_REGISTER     0x0010     /* Dump waits-for table. */
      #define     DB_VERB_REPLICATION     0x0020     /* Replication information. */
      #define     DB_VERB_WAITSFOR     0x0040     /* Dump waits-for table. */
    + #define     DB_VERB_CURSOR          0x0080     /* Cursor open/close information. */
           u_int32_t      verbose;     /* Verbose output. */
           void          app_private;     / Application-private handle. */
    diff -rc db-4.6.21.orig/dist/pubdef.in db-4.6.21/dist/pubdef.in
    *** db-4.6.21.orig/dist/pubdef.in     Fri Jul  6 10:22:52 2007
    --- db-4.6.21/dist/pubdef.in     Mon May 12 17:21:48 2008
    *** 432,437 ****
    --- 432,438 ----
      DB_USERCOPY_SETDATA          * I N
      DB_USE_ENVIRON               D I J
      DB_USE_ENVIRON_ROOT          D I J
    + DB_VERB_CURSOR               D I J
      DB_VERB_DEADLOCK          D I J
      DB_VERB_FILEOPS               D I J
      DB_VERB_FILEOPS_ALL          D I J
    diff -rc db-4.6.21.orig/env/env_method.c db-4.6.21/env/env_method.c
    *** db-4.6.21.orig/env/env_method.c     Fri May 18 01:15:11 2007
    --- db-4.6.21/env/env_method.c     Mon May 12 17:28:57 2008
    *** 1070,1075 ****
    --- 1070,1076 ----
           int *onoffp;
           switch (which) {
    +      case DB_VERB_CURSOR:
           case DB_VERB_DEADLOCK:
           case DB_VERB_FILEOPS:
           case DB_VERB_FILEOPS_ALL:
    *** 1098,1103 ****
    --- 1099,1105 ----
           int on;
           switch (which) {
    +      case DB_VERB_CURSOR:
           case DB_VERB_DEADLOCK:
           case DB_VERB_FILEOPS:
           case DB_VERB_FILEOPS_ALL:
    diff -rc db-4.6.21.orig/java/src/com/sleepycat/db/EnvironmentConfig.java db-4.6.21/java/src/com/sleepycat/db/EnvironmentConfig.java
    *** db-4.6.21.orig/java/src/com/sleepycat/db/EnvironmentConfig.java     Fri Jul  6 10:22:54 2007
    --- db-4.6.21/java/src/com/sleepycat/db/EnvironmentConfig.java     Mon May 12 17:25:22 2008
    *** 114,119 ****
    --- 114,120 ----
          private boolean yieldCPU = false;
          /* Verbose Flags */
    +     private boolean verboseCursor = false;
          private boolean verboseDeadlock = false;
          private boolean verboseFileops = false;
          private boolean verboseFileopsAll = false;
    *** 846,851 ****
    --- 847,855 ----
          public void setVerbose(final VerboseConfig flag, boolean enable) {
              int iflag = flag.getInternalFlag();
              switch (iflag) {
    +         case DbConstants.DB_VERB_CURSOR:
    +             verboseCursor = enable;
    +             break;
              case DbConstants.DB_VERB_DEADLOCK:
                  verboseDeadlock = enable;
                  break;
    *** 876,881 ****
    --- 880,887 ----
          public boolean getVerbose(final VerboseConfig flag) {
              int iflag = flag.getInternalFlag();
              switch (iflag) {
    +         case DbConstants.DB_VERB_CURSOR:
    +             return verboseCursor;
              case DbConstants.DB_VERB_DEADLOCK:
                  return verboseDeadlock;
              case DbConstants.DB_VERB_FILEOPS:
    *** 1151,1156 ****
    --- 1157,1167 ----
                  dbenv.set_flags(offFlags, false);
              /* Verbose flags */
    +         if (verboseCursor && !oldConfig.verboseCursor)
    +             dbenv.set_verbose(DbConstants.DB_VERB_CURSOR, true);
    +         if (!verboseCursor && oldConfig.verboseCursor)
    +             dbenv.set_verbose(DbConstants.DB_VERB_CURSOR, false);
    +
              if (verboseDeadlock && !oldConfig.verboseDeadlock)
                  dbenv.set_verbose(DbConstants.DB_VERB_DEADLOCK, true);
              if (!verboseDeadlock && oldConfig.verboseDeadlock)
    *** 1342,1347 ****
    --- 1353,1359 ----
              yieldCPU = ((envFlags & DbConstants.DB_YIELDCPU) != 0);
              /* Verbose flags */
    +         verboseCursor = dbenv.get_verbose(DbConstants.DB_VERB_CURSOR);
              verboseDeadlock = dbenv.get_verbose(DbConstants.DB_VERB_DEADLOCK);
              verboseFileops = dbenv.get_verbose(DbConstants.DB_VERB_FILEOPS);
              verboseFileopsAll = dbenv.get_verbose(DbConstants.DB_VERB_FILEOPS_ALL);
    diff -rc db-4.6.21.orig/java/src/com/sleepycat/db/VerboseConfig.java db-4.6.21/java/src/com/sleepycat/db/VerboseConfig.java
    *** db-4.6.21.orig/java/src/com/sleepycat/db/VerboseConfig.java     Fri Jul  6 10:22:54 2007
    --- db-4.6.21/java/src/com/sleepycat/db/VerboseConfig.java     Mon May 12 17:28:07 2008
    *** 12,17 ****
    --- 12,19 ----
      import com.sleepycat.db.internal.DbEnv;
      public final class VerboseConfig {
    +     public static final VerboseConfig CURSOR =
    +         new VerboseConfig("CURSOR", DbConstants.DB_VERB_CURSOR);
          public static final VerboseConfig DEADLOCK =
              new VerboseConfig("DEADLOCK", DbConstants.DB_VERB_DEADLOCK);
          public static final VerboseConfig FILEOPS =
    diff -rc db-4.6.21.orig/java/src/com/sleepycat/db/internal/DbConstants.java db-4.6.21/java/src/com/sleepycat/db/internal/DbConstants.java
    *** db-4.6.21.orig/java/src/com/sleepycat/db/internal/DbConstants.java     Fri Sep 28 01:32:07 2007
    --- db-4.6.21/java/src/com/sleepycat/db/internal/DbConstants.java     Mon May 12 17:29:17 2008
    *** 194,199 ****
    --- 194,200 ----
          int DB_UPGRADE = 0x0000001;
          int DB_USE_ENVIRON = 0x0004000;
          int DB_USE_ENVIRON_ROOT = 0x0008000;
    +     int DB_VERB_CURSOR = 0x0080;
          int DB_VERB_DEADLOCK = 0x0001;
          int DB_VERB_FILEOPS = 0x0002;
          int DB_VERB_FILEOPS_ALL = 0x0004;

Maybe you are looking for

  • Installing 10.1.1 itunes on 64 bit vista

    I have previously had itunes on my home computer but since going to college i have yet to put it on my lap top. When i go to download itunes i receive the following errors. (vista 64 bit) 1)HRESULT:0x80070424 An error occurred during the istallation

  • In Explorer drop dowl list is not visible for Entities, Hierarchies, Collection

    I am using SQL Server 2012 MDS on Windows 8.1 Pro. The drop down list of entities, Hierarchies, and collections is not visible on explorer screen. When I hover over the Entity menu the drop down seems to appear but hiding behind the rest of the scree

  • Repeating Error Message

    I keep getting this message- "An error occurred while trying to save your photo library." "Some recent changes may be lost. Make sure your hard disk has enough space and that iPhoto is able to access the iPhoto Library." It will not stop coming up ev

  • Adobe Reader 'Basic' and LE 2.5

    Hi I updated to Symbian Anna and looks like some effort has gone into the Adobe Reader, it's noticeably faster for a file that is 20 mb in size. And it reformats quicky and I can use the multi-touch to zoom. Still no full-screen though which sucks ma

  • Can't get rid of empty blank space at top of website

    I'm sure this is quite simple, but I'm stuck! I can't get rid of the empty space between the Header "Upcoming Events" and the text way way below. Any advice or suggestions would be greatly appreciated. http://www.uvanyc.org/community/event_upcoming.h