This discussion is archived
6 Replies Latest reply: Nov 7, 2013 6:59 PM by 4246bac3-3a09-4031-8891-51bb8a451ffc RSS

Log files can't be removed automatically in HA environment

4246bac3-3a09-4031-8891-51bb8a451ffc Newbie
Currently Being Moderated

Hi BDB experts,

 

 

I am writing db HA application based on bdb version 4.6.21. Two daemons run on two machines, one as master which will read/write db, one as client/backup will only read db. There is one thread in master daemon that run checkpoint every 1 second: dbenv->txn_checkpoint(dbenv, 1, 1, 0), and dbenv->log_archive(dbenv, NULL, DB_ARCH_REMOVE) will be called after runnng checkpoint each time. The env was open with flag: DB_CREATE | DB_INIT_TXN |  DB_INIT_LOCK | DB_INIT_LOG | DB_REGISTER | DB_RECOVER | DB_INIT_MPOOL | DB_THREAD  | DB_INIT_REP;   Autoremove flag was set by: envp->set_flags(uid_dbs.envp, DB_LOG_AUTOREMOVE, 1) before open env.

 

I found this thread https://forums.oracle.com/message/10945602#10945602 which discussed about non-ha environment, and I tested my code in a non-ha env without DB_INIT_REP, it worked. However in HA env those log files were never removed. Could you help on this issue? Does the client need to run checkpoint? May there be a bdb bug?

 

Thanks,

Min

  • 1. Re: Log files can't be removed automatically in HA environment
    Paula B Explorer
    Currently Being Moderated

    There is one thread in master daemon that run checkpoint every 1 second: dbenv->txn_checkpoint(dbenv, 1, 1, 0), and dbenv->log_archive(dbenv, NULL, DB_ARCH_REMOVE) will be called after runnng checkpoint each time. The env was open with flag: DB_CREATE | DB_INIT_TXN |  DB_INIT_LOCK | DB_INIT_LOG | DB_REGISTER | DB_RECOVER | DB_INIT_MPOOL | DB_THREAD  | DB_INIT_REP;   Autoremove flag was set by: envp->set_flags(uid_dbs.envp, DB_LOG_AUTOREMOVE, 1) before open env.

     

    I am not saying that this is causing a problem, but doing the DB_ENV->log_archive(DB_ARCH_REMOVE) in your thread and setting DB_ENV->set_flags(DB_LOG_AUTOREMOVE) is redundant. In your thread, you control the timing. The DB_ENV->set_flags(DB_LOG_AUTOREMOVE) option checks for and removes unneeded log files when we create a new log file.

     

    Did you see in the documentation for DB_ENV->set_flags(DB_LOG_AUTOREMOVE) that we don't recommend doing automatic log file removal with replication? Although this warning is not repeated in DB_ENV->log_archive(DB_ARCH_REMOVE), it also applies to this option. You should reconsider using this option, particularly if it is possible that your client could go down for a long time.

     

    But this is only a warning and automatic log removal should work. My first thought here is to ask whether your client has recently gone through a sync? Internally, we block archiving on the master during some parts of a client sync to improve the chances that we will keep around all logs needed by the syncing client. We block archiving for up to 30 seconds after the client sync.

     

    I found this thread https://forums.oracle.com/message/10945602#10945602 which discussed about non-ha environment, and I tested my code in a non-ha env without DB_INIT_REP, it worked. However in HA env those log files were never removed.

     

    This thread is discussing a different issue. The reason for our warning in BDB 4.6 against using automatic log removal with replication is that it doesn't take into account all the sites in your replication group, so we could remove a log from the master that a client still needs.

     

    We added replication group-aware automatic log removal in BDB 5.3 Replication Manager, and this discussion is about a change of behavior from this addition. With this addition, we no longer need to recommend against using automatic log removal with replication in BDB 5.3 and later releases.

     

    Could you help on this issue? Does the client need to run checkpoint? May there be a bdb bug?

     

    I'm not sure the client needs to run its own checkpoints because it performs checkpoints when it receives checkpoint log records from the master.

     

    But none of the log removal options on the master does anything to remove logs on the client. You will need to perform steps to archive logs separately on the client and the master.

     

    Paula Bingham

    Oracle

  • 2. Re: Log files can't be removed automatically in HA environment
    userBDBDMS Guru Moderator
    Currently Being Moderated

    Min,

     

      I would strongly encourage you to upgrade your BDB version to at least 5.3.    Since 4.6, we have had 7 new releases that have come out.   We will continue to do our best to answer questions on the older releases but it always best to be current in what you are using.    In 4.6 we have a utility db_archive utility.  You can use this utility to write the log files to some form of backup media, and then after that you can use OS commands to delete the files.     Prior to deleting the files you need to be sure that BDB is no longer using them.    Prior to removing any from the master, you need to be sure that the contents of that log file has been pushed to each of your clients.   


    thanks

    mike

     

  • 3. Re: Log files can't be removed automatically in HA environment
    4246bac3-3a09-4031-8891-51bb8a451ffc Newbie
    Currently Being Moderated

    Thanks Paula, you are right. In the test, master added new records continuously. I tested again in another way, db_archive worked.

  • 4. Re: Log files can't be removed automatically in HA environment
    4246bac3-3a09-4031-8891-51bb8a451ffc Newbie
    Currently Being Moderated

    Thanks Mike for the help. I would like to upgrade but it is not determined by me, I am only developing a very small feature for one of the company's product. Many features already used this old release for many years, I don't know if the upgrade would induce new issues and I don't have strong reasons that can persuade high level guys of the company to upgrade.

  • 5. Re: Log files can't be removed automatically in HA environment
    userBDBDMS Guru Moderator
    Currently Being Moderated

    Can you provide some details on what the use case is, how is BDB HA being used.  Some information about the customer as well.    Is the application for an internal or external product.

     

     

    thanks

    mike

  • 6. Re: Log files can't be removed automatically in HA environment
    4246bac3-3a09-4031-8891-51bb8a451ffc Newbie
    Currently Being Moderated

    Thanks Mike. The problem is solved according to Paula's answer.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points