The Bug about 'DB_SECONDARY_BAD' still exists in BerkeleyDB4.8!

The Bug about 'DB_SECONDARY_BAD' still exists in BerkeleyDB4.8?
I'm sorry for my poor English, But I just cannot find anywhere else for help.
Thanks for your patience first!
I'm using BDB4.8 C++ API on Ubuntu 10.04, Linux Kernel 2.6.32-24-generic
$uname -a
$Linux wonpc 2.6.32-24-generic #43-Ubuntu SMP Thu Sep 16 14:17:33 UTC 2010 i686 GNU/Linux
When I update(overwrite) a record in database, I may get a DB_SECONDARY_BAD exception,
What's worse, This case doesn't always occures, it's random. So I think it probably a bug
of BDB, I have seen many issues about DB_SECONDARY_BAD with BDB4.5,4.6...
To reproduce the issue, I make a simplified test program from my real program.
The data to be stroed into database is a class called 'EntryData', It's defined in db_access.h,
where also defines some HighLevel API functions that hide the BDB calls, such as
store_entry_data(), which use EntryData as its argument. The EntryData have a string-type
member-data 'name' and a vector<string>-type mem-data 'labels', So store_entry_data() will
put the real data of EntryData to a contiguous memory block. The get_entry_data() returns
an EntryData builed up from the contiguous memory block fetched from database.
The comlete test program is post following this line:
/////////db_access.h////////////
#ifndef __DB_ACCESS_H__
#define __DB_ACCESS_H__
#include <string>
#include <vector>
#include <db_cxx.h>
class EntryData;
//extern Path DataDir; // default value, can be changed
extern int database_setup();
extern int database_close();
extern int store_entry_data(const EntryData&, u_int32_t = DB_NOOVERWRITE);
extern int get_entry_data(const std::string&, EntryData*, u_int32_t = 0);
extern int rm_entry_data(const std::string&);
class DBSetup
// 构造时调用database_setup, 超出作用域自动调用database_close .
// 该类没有数据成员.
public:
DBSetup() {
database_setup();
~DBSetup() {
database_close();
class EntryData
public:
typedef std::vector<std::string> LabelContainerType;
EntryData() {}
EntryData(const std::string& s) : name(s) {}
EntryData(const std::string& s, LabelContainerType& v)
: name(s), labels(v) {}
EntryData(const std::string&, const char*[]);
class DataBlock;
// 直接从内存块中构建, mem指针将会从数据库中获取,
// 它就是EntryData转化成的DataBlock中buf_ptr->buf的内容.
EntryData(const void* mem_blk, const int len);
~EntryData() {};
const std::string& get_name () const { return name; }
const LabelContainerType& get_labels() const { return labels; }
void set_name (const std::string& s) { name = s; }
void add_label(const std::string&);
void rem_label(const std::string&);
void show() const;
// get contiguous memory for all:
DataBlock get_block() const { return DataBlock(*this); }
class DataBlock
// contiguous memory for all.
public:
DataBlock(const EntryData& data);
// 引进一块内存作为 buf_ptr->buf 的内容.
// 例如从数据库中获取结果
DataBlock(void* mem, int len);
// 复制构造函数:
DataBlock(const DataBlock& orig) :
data_size(orig.data_size),
capacity(orig.capacity),
buf_ptr(orig.buf_ptr) { ++buf_ptr->use; }
// 赋值操作符:
DataBlock& operator=(const DataBlock& oth)
data_size = oth.data_size;
capacity = oth.capacity;
if(--buf_ptr->use == 0)
delete buf_ptr;
buf_ptr = oth.buf_ptr;
return *this;
~DataBlock() {
if(--buf_ptr->use == 0) { delete buf_ptr; }
// data()函数因 Dbt 构造函数不支持const char*而被迫返回 char*
// data() 返回的指针是应该被修改的.
const char* data() const { return buf_ptr->buf; }
int size() const { return data_size; }
private:
void pack_str(const std::string& s);
static const int init_capacity = 100;
int data_size; // 记录数据块的长度.
int capacity; // 已经分配到 buf 的内存大小.
class SmartPtr; // 前向声明.
SmartPtr* buf_ptr;
class SmartPtr
friend class DataBlock;
char* buf;
int use;
SmartPtr(char* p) : buf(p), use(1) {}
~SmartPtr() { delete [] buf; }
private:
std::string name; // entry name
LabelContainerType labels; // entry labels list
}; // class EntryData
#endif
//////db_access.cc/////////////
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include "directory.h"
#include "db_access.h"
using namespace std;
static Path DataDir("~/mydict_data"); // default value, can be changed
const Path& get_datadir() { return DataDir; }
static DbEnv myEnv(0);
static Db db_bynam(&myEnv, 0); // using name as key
static Db db_bylab(&myEnv, 0); // using label as key
static int generate_keys_for_db_bylab
(Db* sdbp, const Dbt* pkey, const Dbt* pdata, Dbt* skey)
EntryData entry_data(pdata->get_data(), pdata->get_size());
int lab_num = entry_data.get_labels().size();
Dbt* tmpdbt = (Dbt*) malloc( sizeof(Dbt) * lab_num );
memset(tmpdbt, 0, sizeof(Dbt) * lab_num);
EntryData::LabelContainerType::const_iterator
lab_it = entry_data.get_labels().begin(), lab_end = entry_data.get_labels().end();
for(int i = 0; lab_it != lab_end; ++lab_it, ++i) {
tmpdbt[ i ].set_data( (void*)lab_it->c_str() );
tmpdbt[ i ].set_size( lab_it->size() );
skey->set_flags(DB_DBT_MULTIPLE | DB_DBT_APPMALLOC);
skey->set_data(tmpdbt);
skey->set_size(lab_num);
return 0;
//@Return Value: return non-zero at error
extern int database_setup()
const string DBEnvHome (DataDir + "DBEnv");
const string dbfile_bynam("dbfile_bynam");
const string dbfile_bylab("dbfile_bylab");
db_bylab.set_flags(DB_DUPSORT);
const u_int32_t env_flags = DB_CREATE | DB_INIT_MPOOL;
const u_int32_t db_flags = DB_CREATE;
rmkdir(DBEnvHome);
try
myEnv.open(DBEnvHome.c_str(), env_flags, 0);
db_bynam.open(NULL, dbfile_bynam.c_str(), NULL, DB_BTREE, db_flags, 0);
db_bylab.open(NULL, dbfile_bylab.c_str(), NULL, DB_BTREE, db_flags, 0);
db_bynam.associate(NULL, &db_bylab, generate_keys_for_db_bylab, 0);
} catch(DbException &e) {
cerr << "Err when open DBEnv or Db: " << e.what() << endl;
return -1;
} catch(std::exception& e) {
cerr << "Err when open DBEnv or Db: " << e.what() << endl;
return -1;
return 0;
int database_close()
try {
db_bylab.close(0);
db_bynam.close(0);
myEnv.close(0);
} catch(DbException &e) {
cerr << e.what();
return -1;
} catch(std::exception &e) {
cerr << e.what();
return -1;
return 0;
// 返回Dbt::put()的返回值
int store_entry_data(const EntryData& e, u_int32_t flags)
int res = 0;
try {
EntryData::DataBlock blk(e);
// data()返回的buf中存放的第一个字符串便是 e.get_name().
Dbt key ( (void*)blk.data(), strlen(blk.data()) + 1 );
Dbt data( (void*)blk.data(), blk.size() );
res = db_bynam.put(NULL, &key, &data, flags);
} catch (DbException& e) {
cerr << e.what() << endl;
throw; // 重新抛出.
return res;
// 返回 Db::get()的返回值, 调用成功时 EntryData* e的值才有意义
int get_entry_data
(const std::string& entry_name, EntryData* e, u_int32_t flags)
Dbt key( (void*)entry_name.c_str(), entry_name.size() + 1 );
Dbt data;
data.set_flags(DB_DBT_MALLOC);
int res = db_bynam.get(NULL, &key, &data, flags);
if(res == 0)
new (e) EntryData( data.get_data(), data.get_size() );
free( data.get_data() );
return res;
int rm_entry_data(const std::string& name)
Dbt key( (void*)name.c_str(), name.size() + 1 );
cout << "to remove: \'" << name << "\'" << endl;
int res = db_bynam.del(NULL, &key, 0);
return res;
EntryData::EntryData(const std::string& s, const char* labels_arr[]) : name(s)
{   // labels_arr 需要以 NULL 结尾.
for(const char** i = labels_arr; *i != NULL; i++)
labels.push_back(*i);
EntryData::EntryData(const void* mem_blk, const int len)
const char* buf = (const char*)mem_blk;
int consumed = 0; // 已经消耗的mem_blk的大小.
name = buf; // 第一串为 name
consumed += name.size() + 1;
for (string label = buf + consumed;
consumed < len;
consumed += label.size() + 1)
label = buf + consumed;
labels.push_back(label);
void EntryData::add_label(const string& new_label)
if(find(labels.begin(), labels.end(), new_label)
== labels.end())
labels.push_back(new_label);
void EntryData::rem_label(const string& to_rem)
LabelContainerType::iterator iter = find(labels.begin(), labels.end(), to_rem);
if(iter != labels.end())
labels.erase(iter);
void EntryData::show() const {
cout << "name: " << name << "; labels: ";
LabelContainerType::const_iterator it, end = labels.end();
for(it = labels.begin(); it != end; ++it)
cout << *it << " ";
cout << endl;
EntryData::DataBlock::DataBlock(const EntryData& data) :
data_size(0),
capacity(init_capacity),
buf_ptr(new SmartPtr(new char[init_capacity]))
pack_str(data.name);
for(EntryData::LabelContainerType::const_iterator \
i = data.labels.begin();
i != data.labels.end();
++i) { pack_str(*i); }
void EntryData::DataBlock::pack_str(const std::string& s)
int string_size = s.size() + 1; // to put sting in buf separately.
if(capacity >= data_size + string_size) {
memcpy(buf_ptr->buf + data_size, s.c_str(), string_size);
else {
capacity = (data_size + string_size)*2; // 分配尽可能大的空间.
buf_ptr->buf = (char*)realloc(buf_ptr->buf, capacity);
memcpy(buf_ptr->buf + data_size, s.c_str(), string_size);
data_size += string_size;
//////////// test_put.cc ///////////
#include <iostream>
#include <string>
#include <cstdlib>
#include "db_access.h"
using namespace std;
int main(int argc, char** argv)
if(argc < 2) { exit(EXIT_FAILURE); }
DBSetup setupup_mydb;
int res = 0;
EntryData ed(argv[1], (const char**)argv + 2);
res = store_entry_data(ed);
if(res != 0) {
     cerr << db_strerror(res) << endl;
     return res;
return 0;
// To Compile:
// $ g++ -ldb_cxx -lboost_regex -o test_put test_put.cc db_access.cc directory.cc
//////////// test_update.cc ///////////
#include <iostream>
#include <cstdlib>
#include <string>
#include <boost/program_options.hpp>
#include "db_access.h"
using namespace std;
namespace po = boost::program_options;
int main(int argc, char** argv)
if(argc < 2) { exit(EXIT_SUCCESS); }
DBSetup setupup_mydb;
int res = 0;
po::options_description cmdopts("Allowed options");
po::positional_options_description pos_opts;
cmdopts.add_options()
("entry", "Specify the entry that will be edited")
("addlabel,a", po::value< vector<string> >(),
"add a label for specified entry")
("removelabel,r", po::value< vector<string> >(),
"remove the label of specified entry")
pos_opts.add("entry", 1);
po::variables_map vm;
store( po::command_line_parser(argc, argv).
options(cmdopts).positional(pos_opts).run(), vm );
notify(vm);
EntryData entry_data;
if(vm.count("entry")) {
const string& entry_to_edit = vm["entry"].as<string>();
res = get_entry_data( entry_to_edit, &entry_data );
switch (res)
case 0:
break;
case DB_NOTFOUND:
cerr << "No entry named: \'"
<< entry_to_edit << "\'\n";
return res;
break;
default:
cerr << db_strerror(res) << endl;
return res;
} else {
cerr << "No entry specified\n";
exit(EXIT_FAILURE);
EntryData new_entry_data(entry_data);
typedef vector<string>::const_iterator VS_CI;
if(vm.count("addlabel")) {
const vector<string>& to_adds = vm["addlabel"].as< vector<string> >();
VS_CI end = to_adds.end();
for(VS_CI i = to_adds.begin(); i != end; ++i) {
new_entry_data.add_label(*i);
if(vm.count("removelabel")) {
const vector<string>& to_rems = vm["removelabel"].as< vector<string> >();
VS_CI end = to_rems.end();
for(VS_CI i = to_rems.begin(); i != end; ++i) {
new_entry_data.rem_label(*i);
cout << "Old data| ";
entry_data.show();
cout << "New data| ";
new_entry_data.show();
res = store_entry_data(new_entry_data, 0); // set flags to zero permitting Over Write
if(res != 0) {
cerr << db_strerror(res) << endl;
return res;
return 0;
// To Compile:
// $ g++ -ldb_cxx -lboost_regex -lboost_program_options -o test_update test_update.cc db_access.cc directory.cc

////////directory.h//////
#ifndef __DIRECTORY_H__
#define __DIRECTORY_H__
#include <string>
#include <string>
#include <sys/types.h>
using std::string;
class Path
public:
Path() {}
Path(const std::string&);
Path(const char* raw) { new (this) Path(string(raw)); }
Path upper() const;
void operator+= (const std::string&);
// convert to string (char*):
//operator std::string() const {return spath;}
operator const char*() const {return spath.c_str();}
const std::string& str() const {return spath;}
private:
std::string spath; // the real path
inline Path operator+(const Path& L, const string& R)
Path p(L);
p += R;
return p;
int rmkdir(const string& path, const mode_t mode = 0744, const int depth = -1);
#endif
///////directory.cc///////
#ifndef __DIRECTORY_H__
#define __DIRECTORY_H__
#include <string>
#include <string>
#include <sys/types.h>
using std::string;
class Path
public:
Path() {}
Path(const std::string&);
Path(const char* raw) { new (this) Path(string(raw)); }
Path upper() const;
void operator+= (const std::string&);
// convert to string (char*):
//operator std::string() const {return spath;}
operator const char*() const {return spath.c_str();}
const std::string& str() const {return spath;}
private:
std::string spath; // the real path
inline Path operator+(const Path& L, const string& R)
Path p(L);
p += R;
return p;
int rmkdir(const string& path, const mode_t mode = 0744, const int depth = -1);
#endif
//////////////////// All the code is above ////////////////////////////////
Use the under command
$ g++ -ldb_cxx -lboost_regex -o test_put test_put.cc db_access.cc directory.cc
to get a test program that can insert a record to database.
To insert a record, use the under command:
$ ./test_put ubuntu linux os
It will store an EntryData named 'ubuntu' and two labels('linux', 'os') to database.
Use the under command
$ g++ -ldb_cxx -lboost_regex -lboost_program_options -o test_update test_update.cc db_access.cc directory.cc
to get a test program that can update the existing records.
To update the record, use the under command:
$ ./test_update ubuntu -r linux -a canonical
It will update the with the key 'ubuntu', with the label 'linux' removed and a new
label 'canonical'.
Great thanks to you if you've read and understood my code!
I've said that the DB_SECONDARY_BAD exception is random. The same operation may cause
exception in one time and may goes well in another time.
As I've test below:
## Lines not started with '$' is the stdout or stderr.
$ ./test_put linux os linus
$ ./test_update linux -r os
Old data| name: linux; labels: os linus
New data| name: linux; labels: linus
$ ./test_update linux -r linus
Old data| name: linux; labels: linus
New data| name: linux; labels:
dbfile_bynam: DB_SECONDARY_BAD: Secondary index inconsistent with primary
Db::put: DB_SECONDARY_BAD: Secondary index inconsistent with primary
terminate called after throwing an instance of 'DbException'
what(): Db::put: DB_SECONDARY_BAD: Secondary index inconsistent with primary
已放弃
Look! I've received a DB_SECONDARY_BAD exception. But thus exception does not always
happen even under the same operation.
For the exception is random, you may have not the "luck" to get it during your test.
So let's insert a record by:
$ ./test_put t
and then give it a great number of labels:
$ for((i = 0; i != 100; ++i)); do ./test_update t -a "label_$i"; done
and then:
$ for((i = 0; i != 100; ++i)); do ./test_update t -r "label_$i"; done
Thus, the DB_SECONDARY_BAD exception is almost certain to happen.
I've been confused by the problem for times. I would appreciate if someone can solve
my problem.
Many thanks!
Wonder

Similar Messages

  • I cannot updates in my application store because the previous email add still exist even i have already new apple id

    I cannot update in my application store because the previous email add still exist even i have a new apple id

    FAQ apple id http://support.apple.com/kb/he37
    Doesn't matter if you have a new ID, all apps are tied to the apple id that was used to download it.

  • I import photos into lightroom and they appear just fine and then after 'developing' some disappear from the library though they still exist in the previous import window

    I import photos into lightroom and they appear just fine and then after 'developing' some disappear from the library though they still exist in the previous import window

    Running MacOS 10.9.4 16 Gb RAM Lightroom v5.2

  • Does the frequency selection tool still exist in audition?

    Does this tool still exist in audition? I am sure it was available in soundbooth
    Very useful if you are trying to remove a constant buzzing of a certain frequency from an audio file.

    Thanks for your answer!
    Disappointing that it's gone. Will definitely submit a feature request.
    The frequency selection tool was convenient, especially in the spectral view, because you could manually select one frequency across the entire file, while being zoomed in at only one specific time segment. You always risk forgetting/not catching something at the beginning or end of the file, when doing the manual selection tools, like the rectangle selection. Plus you'll have to be zoomed out all the way, so it's a bit harder to exactly select the frequency you need.
    The automated tools are useful, but in early 2015 I still value the human pattern recognition systems and artistic and aesthetic judgement over that of an AI. (We'll see for how much longer,...)

  • Projects/WBS elements with the editing mask A still exist.

    Hi All,
    I am trying to create a New Coding Mask with Project ID "A" in Dev client 100. ( Ex: A.0000.XX)
    But System is giving an error says that"There are still projects or WBS elements with edit mask A in the system. Therefore you cannot change them".
    But there is no WBS or PD's with this coding mask existing in development client 100.What to do?Is there anyone faced this problam earlier?Any refresh activity required for this?
    Thanks in Advance!
    Thanks
    Suresh Kumar.

    Hello,
    You need to check whether there are any projects in the system starting with "A" using CNS41.  If at all there are any project existing in the system which starts with "A" then the system wont allow to create coding mask which starts with "A"
    You can try to delete these project if possible and then try out if the system allows you to create the coding mask.
    Thanks and Regards,
    Anish

  • HT201317 How do i remove photo stream from my windows 7 pc? I have not given permission for it to be enabled, but the icon and text still exists in 'computer'.

    Please how?
    Ps i object to posting this in a forum, i apologise to other forum users. This is what apple support requires me to do.poor job apple

    I had already done that before giving him the phone.  I left iTunes Match on it because in my mind, he would have access to his music and more.  I guess he did not like the clutter form having the entire music to have to browse through.
    In any case, I fixed the problem by doing a factory reset and restore from backup.
    I should not need to do that .. but that got rid of the iTunes Match from the device.

  • Delimiting an  Org Unit when the sub ordinate relationships still exist.

    Hello All,
    I tried to delimit an Orgunit when there are subordinate positions already assigned. I am able to delimit without ending the relationships first. Why SAP is letting do this. Now after the delimit I have Orgunit with end date of 06/22/2207, and the subordinate objects enddate is 12/31/9999. Is there a config where we can control this or is this SAP issue?
    Thanks,
    Chakri.

    Hi Chakri,
    perhaps the switch
    PPOM EXTCK                                                                       
    in table T77S0 is the solution for you.
    PPOM EXTCK :
                                                                                    In the Simple maintenance view, you can use the entry PPOM EXTCK to          
        determine, when delimiting or deleting an organizational unit or a           
        position, whether:                                                                               
    o   the system should generate an error message pointing out that the        
            subordinate objects must first be moved, deleted or delimited                                                                               
    For this option, enter the value 'X'.                                                                               
    o   direct modification of the assignment of subordinate objects should      
            be possible                                                                               
    For this option, enter the value ' '.                                                                               
    This setting affects the following relationships:                                                                               
    o   Organizational unit                                                      
            - Organizational unit                                                    
            - Position                                                               
            - Cost center                                                                               
    o   Position                                                                 
            - Person                                                                 
            - User                                                                   
            - Business partner                                                       
    Regards
    Bernd

  • Since the FF8 update, all bookmarks were lost and none of the recommended methods for restoring lost bookmarks work; I always get "Unable to process to backup file" even though the backup .json files still exist

    Since a FF8 update, all bookmarks were lost and none of the recommended restore methods work, even though I have been able to find the backup ".json" files; I continually get "Unable to process the backup file" for all methods of importing or restoring the bookmarks from the .json files. As others note, I can also no longer add any new bookmarks to my now empty bookmarks tab. My profile has not changed, so that's not the problem. This is really a pain.

    Did you try to delete the file places.sqlite to make Firefox rebuild the places.sqlite database file from a JSON backup?
    *http://kb.mozillazine.org/Unable_to_process_the_backup_file_-_Firefox
    A possible cause is a problem with the file places.sqlite that stores the bookmarks and the history.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    *https://support.mozilla.org/kb/Bookmarks+not+saved#w_places-database-file

  • Does the "Warning! Not Enough Memory" bug still exist in Logic 8?

    Hello everyone,
    I'm wondering if the dreaded "warning, not enough memory" bug still exists in Logic 8. Here is a detailed account of the bug from Logic 7: http://discussions.apple.com/thread.jspa?messageID=767597&#767597
    If this is fixed, I'm seriously considering upgrading mid-project! The film score I'm working on has many doubling parts that I'd like to edit at the same time in the matrix editor. However, editing multiple parts in the matrix editor seems provoke the little bugger, and I've already been bitten a few times in this project already. The only solution I've found is to stay clear of editing multiple parts at once (i.e. edit each parts individually, which obviously takes more time) or save before editing and hope I dont get bit.
    I would LOVE to hear a report that this bug has been exterminated, and perhaps may upgrade mid project if thats the case.
    Thanks in advance for your reply!

    Heya,
    I'm not familiar with the bug you're talking about. But would, as a fellow film composer, strongly urge you against the mid project switch.
    I loaded in LP8 and ofcourse had a look at what it was all about, and it's really really fantastic. It also seems very stable. I fortunately have a side project that I am working on so switched to LP8 for that. Whilst I'm thankful to get my head around a very new approach for logic, I'm also thankful that I have this side project as it has illuminated a multitude of problems that exist with LP8 that would make any scoring process a bit of a headache to say the least. The main one being that if you don't have a very very powerful mac (I'm prepping a really fully loaded 8 core) you are not going to get anywhere near the performance out of Logic as you do with 7. This is a bottom up overhaul and it needs hardware to match. Heck even my 30" cinema display seems cramped and insubstantial on this new version. I would be so bold to say hold off until you have a hearty new mac and at least 8.2 is released IMHO but maybe try and get on it onto a smaller project to familiarize yourself before hand.

  • Bug #18104 still exists

    Hello,
    I am quite disappointed about BDB 5. One of the most nasty bugs (#18104) still
    exists. As soon as you want to use the set_thread_count() feature, BDB will not
    free the thread-control-block. If you connect/disconnect, BDB will stop working
    quite early. You can re-produce this issue with any `db_*` tool.
    The testcase:
    #include <stdlib.h>
    #include <db.h>
    #define DIRECTORY "/tmp/db"
    int main()
        /* open environment */
        DB_ENV *handle;
        int status = db_env_create( &handle, 0 );
        status = handle->set_cachesize( handle, 0, 32*1024*1024, 0 );
        status = handle->set_thread_count( handle, 0x100 );
        status = handle->open( handle, DIRECTORY, DB_CREATE, 0644 );
        if( status != 0 )
            return 1;
        /* raise error "Unable to allocate thread control block" */
        for( ;; )
            system( "db_stat -e -h " DIRECTORY " | grep process/thread | wc" );
        return 0;
    }

    Hi Sandra,
    Hi Greg,
    Our architecture is quite simple: a cron-job runs ENV->failchk() and ENV->txn_checkpoint()
    once a minute (which should be fine, shouldn't it?)
    The problem, neither ENV->close() nor ENV->failchk() removes outdated items from the
    thread-control-block. One would expect, that the PID is added to the block as soon as the
    process connects and removed when the process disconnects. But it is not.
    If the block runs out of memory, BDB requires a recovery (see the down below testcase).
    Usually ENV->failchk() cleans the thread-control-block, as soon as there are more items in
    the block than "thread_count". Today three times it did not even remove them, if there were
    more than "thread_count" items in the block - but this happend sporadic so it was difficult
    to create a testcase.
    Once ENV->failchk() cleans the thread-control-block, BDB works as expected. If a process
    connects, the PID is added to the block, and as soon as the process disconnects, the PID is
    removed from the thread-control-block. You can test this by looping the first loop 1090 times.
    The testcase:
    #include <stdio.h>
    #include <stdlib.h>
    #include <signal.h>
    #include <db.h>
    #include <errno.h>
    #define DIRECTORY "/tmp/db"
    static int bdb_is_alive( DB_ENV *dbenv, pid_t pid, db_threadid_t tid, u_int32_t flags )
        int status;
        status = kill( pid, 0 );
        if( status != -1 )
            return 1;
        if( errno == ESRCH )
            return 0;
        exit( 1 );  /* should never happen */
    int main()
        system( "mkdir -p " DIRECTORY );
        system( "db_recover -h " DIRECTORY );
        system( "rm -rfv " DIRECTORY "/*" );
        /* open environment */
        int status, i;
        DB_ENV *handle;
        status = db_env_create( &handle, 0 );
        status = handle->set_cachesize( handle, 0, 32*1024*1024, 0 );
        status = handle->set_thread_count( handle, 1091 );
        status = handle->set_isalive( handle, bdb_is_alive );
        status = handle->open( handle, DIRECTORY, DB_CREATE, 0644 );
        if( status != 0 )
            return 1;   /* should never happen */
        status = handle->failchk( handle, 0 );
        status = handle->close( handle, 0 );
        /* Now start workers (`db_stat`) + failchks() */
        for( i=0; i < 1089; ++i )       /* thread_count - 2 */
            fprintf(stderr,"Number of items in the thread-control-block: "); fflush(stdout);
            system( "db_stat -e -h " DIRECTORY " | grep process/thread | wc -l" );
            status = db_env_create( &handle, 0 );
            status = handle->set_isalive( handle, bdb_is_alive );
            status = handle->open( handle, DIRECTORY, DB_CREATE, 0644 );
            if( status != 0 )
                return 1;   /* should never happen */
            status = handle->failchk( handle, 0 );      /* strange - does not remove the process-entries created by `db_stat` */
            if( status != 0 )
                return 1;   /* should never happen */
            status = handle->close( handle, 0 );
        /* raise error: "Unable to allocate thread control block" */
        for( i=1; i < 422; ++i )
            fprintf(stderr,"Number of items in the thread-control-block: "); fflush(stdout);
            system( "db_stat -e -h " DIRECTORY " | grep process/thread | wc -l" );
        /* You should see on stderr:
                db_stat: Unable to allocate thread control block
                db_stat: Unable to allocate thread control block
                db_stat: DB_ENV->open: /tmp/db: Cannot allocate memory
        fprintf(stderr,"BDB is dead now. Only `db_recover` helps...\n%s\n",db_version(NULL,NULL,NULL));
        return 0;
    }

  • Index with "or" clause (BUG still exists?)

    The change log for 2.3.10 mentions "Fixed a bug that caused incorrect query plans to be generated for predicates that used the "or" operator in conjunction with indexes [#15328]."
    But looks like the Bug still exists.
    I am listing the steps to-repro. Let me know if i have missed something (or if the bug needs to be fixed)
    DATA
    dbxml> openContainer test.dbxml
    dbxml> getDocuments
    2 documents found
    dbxml> print
    <node><value>a</value></node>
    <node><value>b</value></node>
    INDEX (just one string equality index on node "value")
    dbxml> listIndexes
    Index: unique-node-metadata-equality-string for node {http://www.sleepycat.com/2002/dbxml}:name
    Index: node-element-equality-string for node {}:value
    2 indexes found.
    QUERY
    setVerbose 2 2
    preload test.dbxml
    query 'let $temp := fn:compare("test", "test") = 0
    let $results := for $i in collection("test.dbxml")
    where ($temp or $i/node[value = ("a")])
    return $i
    return <out>{$temp}{$results}</out>'
    When $temp is true i expected the result set to contain both the records, but that was not the case with the index. It works well when there is no index!
    Result WITH INDEX
    dbxml> print
    <out>true<node><value>a</value></node></out>
    Result WITHOUT INDEX
    dbxml> print
    <out>true<node><value>a</value></node><node><value>b</value></node></out>

    Hi Vijay,
    This is a completely different bug, relating to predicate expressions that do not examine nodes. Please try the following patch, to see if it fixes this bug for you:
    --- dbxml-2.3.10-original/dbxml/src/dbxml/optimizer/QueryPlanGenerator.cpp     2007-04-18 10:05:24.000000000 +0100
    +++ dbxml-2.3.10/dbxml/src/dbxml/optimizer/QueryPlanGenerator.cpp     2007-08-08 11:32:10.000000000 +0100
    @@ -1566,11 +1572,12 @@
         else if(name == Or::name) {
              UnionQP *unionOp = new (&memMgr_) UnionQP(&memMgr_);
    +          result.operation = unionOp;
              for(VectorOfASTNodes::iterator i = args.begin(); i != args.end(); ++i) {
                   PathResult ret = generate(*i, ids);
                   unionOp->addArg(ret.operation);
    +               if(ret.operation == 0) result.operation = 0;
    -          result.operation = unionOp;
         // These operators use the presence of the node arguments, not their valueJohn

  • Old kexi bug still exists?

    So I was looking into using something other than phpMyAdmin for editing my databases, so I looked into kexi.  When I used the import "Structure and Data" option, it just populates the tables with empty values.
    After some searching, I found that this use to be an issue a while back: Problem and Resolution.
    Can anyone else confirm this as a still-existing (or reoccurring) bug?
    Or, am I just messing something up along the way?
    Thanks.

    I hope someone can help me... it is very important and i am desperate for answers (BUMP)

  • Hi, I developed a web application using HTML5-Offline Application Cache mechanism. Inspite of deleting the cache as mentioned in the above steps, Firefox still maintains a copy of the page in it's cache. Also, a serious bug is, even though we delete all

    == Issue
    ==
    I have a problem with my bookmarks, cookies, history or settings
    == Description
    ==
    Hi,
    I developed a web application using HTML5-Offline Application Cache mechanism. Inspite of deleting the cache as mentioned in the above steps, Firefox still maintains a copy of the page in it's cache. Also, a serious bug is, even though we delete all temp files used by Firefox, and open the previously cached page, it displays it correctly, but upon refreshing/reloading it again shows the previous version of the page maintained in the cache.
    == Troubleshooting information
    ==
    HTML5: Application Caching
    .style1 {
    font-family: Consolas;
    font-size: small;
    text-align: left;
    margin-left: 80px;
    function onCacheChecking(e)
    printOutput("CHECKINGContents of the manifest are being checked.", 0);
    function onCacheCached(e) {
    printOutput("CACHEDAll the resources mentioned in the manifest have been downloaded", 0);
    function onCacheNoUpdate(e)
    printOutput("NOUPDATEManifest file has not been changed. No updates took place.", 0);
    function onCacheUpdateReady(e)
    printOutput("UPDATEREADYChanges have been made to manifest file, and were downloaded.", 0);
    function onCacheError(e) {
    printOutput("ERRORAn error occured while trying to process manifest file.", 0);
    function onCacheObselete(e)
    printOutput("OBSOLETEEither the manifest file has been deleted or renamed at the source", 0);
    function onCacheDownloading(e) {
    printOutput("DOWNLOADINGDownloading resources into local cache.", 0);
    function onCacheProgress(e) {
    printOutput("PROGRESSDownload in process.", 0);
    function printOutput(statusMessages, howToTell)
    * Outputs information about an event with its description
    * @param statusMessages The message string to be displayed that describes the event
    * @param howToTell Specifies if the output is to be written onto document(0) or alert(1) or both(2)
    try {
    if (howToTell == 2) {
    document.getElementById("stat").innerHTML += statusMessages;
    window.alert(statusMessages);
    else if (howToTell == 0) {
    document.getElementById("stat").innerHTML += statusMessages;
    else if (howToTell == 1) {
    window.alert(statusMessages);
    catch (IOExceptionOutput) {
    window.alert(IOExceptionOutput);
    function initiateCaching()
    var ONLY_DOC = 0;
    var ONLY_ALERT = 1;
    var BOTH_DOC_ALERT = 2;
    try
    if (window.applicationCache)
    var appcache = window.applicationCache;
    printOutput("BROWSER COMPATIBILITYSUCCESS!! AppCache works on this browser.", 0);
    appcache.addEventListener('checking', onCacheChecking, false);
    appcache.addEventListener('cached', onCacheCached, false);
    appcache.addEventListener('noupdate', onCacheNoUpdate, false);
    appcache.addEventListener('downloading', onCacheDownloading, false);
    appcache.addEventListener('progress', onCacheProgress, false);
    appcache.addEventListener('updateready', onCacheUpdateReady, false);
    appcache.addEventListener('error', onCacheError, false);
    appcache.addEventListener('obsolete', onCacheObselete, false);
    else
    document.getElementById("stat").innerHTML = "Failure! I cant work.";
    catch (UnknownError)
    window.alert('Internet Explorer does not support Application Caching yet.\nPlease run me on Safari or Firefox browsers\n\n');
    stat.innerHTML = "Failure! I cant work.";
    == Firefox version
    ==
    3.6.3
    == Operating system
    ==
    Windows XP
    == User Agent
    ==
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729; .NET4.0E)
    == Plugins installed
    ==
    *-Shockwave Flash 10.0 r45
    *Default Plug-in
    *Adobe PDF Plug-In For Firefox and Netscape "9.3.2"
    *NPRuntime Script Plug-in Library for Java(TM) Deploy
    *The QuickTime Plugin allows you to view a wide variety of multimedia content in Web pages. For more information, visit the QuickTime Web site.
    *Google Update
    *4.0.50524.0
    *Office Live Update v1.4
    *NPWLPG
    *Windows Presentation Foundation (WPF) plug-in for Mozilla browsers
    *Next Generation Java Plug-in 1.6.0_20 for Mozilla browsers
    *Npdsplay dll
    *DRM Store Netscape Plugin
    *DRM Netscape Network Object
    Thanks & Regards,
    Kandarpa Chandrasekhar Omkar
    Software Engineer
    Wipro Technologies
    Bangalore.
    [email protected]
    [email protected]

    We have had this issue many, many times before including on the latest 3.6 rev. It appears that when the applicationCache has an update triggered by a new manifest file, the browser may still use only its local network cache to check for updates to the files in the manifest, instead of forcing an HTTP request and revalidating both the browser cache and the applicationCache versions of the cached file (seems there is more than one). I have to assume this is a browser bug, as one should not have to frig with server Cache-Control headers and such to get this to work as expected (and even then it still doesn't sometimes).
    The only thing that seems to fix the problem is setting network.http.use-cache to false (default is true) in about:config . This helps my case because we only ever run offline (applicationCache driven) apps in the affected browser (our managed mobile apps platform), but it will otherwise slow down your browser experience considerably.

  • Help I need help. i get this message'Firefox could not install this item because "install.rdf" (provided by the item) is not well-formed or does not exist. Please contact the author about this problem.' How do i fix this?

    Firefox could not install this item because "install.rdf" (provided by the item) is not well-formed or does not exist. Please contact the author about this problem.
    Well that is the message i get. I can still use firefox(version3.6.8)

    You get that error if an extension is using an old and no longer supported method to install a plugin.
    Which plugin are you trying to install?
    See also http://kb.mozillazine.org/Unable_to_install_themes_or_extensions

  • Every once in a while when I open my mail or a page I get nothing but strange lines of symbols.  Many of the symbols are black triangles with question marks in the center.  I completely reset it like new, but problem still exists

    Every once in a while when I open my mail or open a page I get lines of strange symbols like black triangles with question marks in the center.  I have reset the ipad2 to new condition but the problem still exists.

    A reset does not make tthe iPad "like new."
    First, let's ensure that we agree on just what is a Reset...
    Hold down the on/off switch and the Home button simultaneously until you see the Apple logo.  Ignore the "Slide to power off" text if it appears.  You will not lose any apps, data, music, movies, settings, etc.
    If the Reset doesn't work, try a Restore.  Note that it's nowhere near as quick as a Reset.  Connect via cable to the computer that you use for sync.  From iTunes, select the iPad/iPod and then select the Summary tab.  Follow directions for Restore and be sure to say "yes" to the backup.  You will be warned that all data (apps, music, movies, etc.) will be erased but, as the Restore finishes, you will be asked if you wish the contents of the backup to be copied to the iPad/iPod.  Again, say "yes."
    At the end of the basic Restore, you will be asked if you wish to sync the iPad/iPod.  As before, say "yes."  Note that that sync selection will disappear and the Restore will end if you do not respond within a reasonable time.  If that happens, only the apps that are part of the IOS will appear on your device.  Corrective action is simple -  choose manual "Sync" from the bottom right of iTunes.
    If you're unable to do the Restore, go into Recovery Mode per the instructions here.

Maybe you are looking for