DB_SECONDARY_BAD problem
871889Jun 28 2011 — edited Jun 28 2011Hello, I have a table and one index associated:
DbEnv env(0);
env.open("db-home", DB_CREATE | DB_INIT_MPOOL | DB_INIT_LOCK | DB_THREAD, 0);
Db table1(&env, 0);
table1.set_pagesize(TABLE_PAGE_SIZE);
table1.open(NULL, TABLE_NAME, NULL, DB_BTREE, DB_CREATE | DB_THREAD, 0);
Db tableIdx(&env, 0);
tableIdx.set_pagesize(ORDER_IDX_PAGE_SIZE);
tableIdx.open(NULL, TABLEIDX_NAME, NULL, DB_BTREE, DB_CREATE | DB_THREAD, 0);
tableDb.associate(NULL, &tableIdx, &getKeys, 0);
and I have a method e.g. save_to_table, where I do:
1. Check for record existence using tableIdx->exists
2. if record not exists, save using table->put, else reject
save_to_table is called from several threads and periodically I get DB_SECONDARY_BAD error.
Sometimes threads are deadlocked. gdb shows, what one thread calls tableIdx->exists and another tries to call table->put.
How to fix it?
P.S. each thread has its own instance of env/table/tableIdx
P.P.S I use 5.1.25 version
Edited by: 868886 on 28.06.2011 5:02