I have created an application on linux(CentOS 5.6) , the version of BDB is 5.1, The way I used it AS:
1) I used the db enviornments, multithreads, transaction,cursors, secondary database, and, every db file contain only one database(table);
2) set the flags as DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN | DB_INIT_MPOOL | DB_THREAD when call DBEnv->open(), set flag DB_REGION_INIT on use DBEnv->set_flags(), and set DB_LOG_AUTO_REMOVE on by call DBEnv->log_set_config();
3)there mutithreads read the dabases and ONLY one thread write the databases;
4)In my daemon process, I create a single pthread( the main thread was exit when the application have started) to handle the signal SIGINT, and in the signal handler I close all the DB handlers and DBEnv handle;
But the trouble is when I kill -s SIGINT to stop the application, it randomly return -30973 errno on some API calls, likely be Db::pget, dbc::get or db::get. and some time it also lead to a dbexception in transation.
which one can tell me how can this happen?
I have find out the cause myself, It's the db_recover utility tool! For I used a shell to stop the application process, and add a db_recover running after kill -s SIGINT to application process,but forgot to wait application process to stop. So as the app are stopping, the db_recover cause it crash.