Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataBase Lock Error #30

Open
santosh116 opened this issue Apr 27, 2017 · 2 comments
Open

DataBase Lock Error #30

santosh116 opened this issue Apr 27, 2017 · 2 comments

Comments

@santosh116
Copy link

Hi ,

I'm using hiberlite,
There are two tables in database , two process trying to read separate table from database in loop.
I folllowed the sample.cpp code.
But after few minutes of execution, there is DB LOCK Error.
I don't understand, why while doing READ we are getting DBLOCK error.
Thanks.

@santosh116
Copy link
Author

Function 1: Calling in Loop, Process 2
 hiberlite::Database db("Deviceinfo.db");
 db.registerBeanClass<Device_info>();
 vector<hiberlite::bean_ptr<Device_info>>v=db.getAllBeans<Device_info>()
 dptr->productId =  v[0]->productId            
 dptr->modelNo =  v[0]->modelNo             

Function 2: Calling in loop process 2
 hiberlite::Database db("Deviceinfo.db");
 db.registerBeanClass<PortCfg>();
 vector<hiberlite::bean_ptr<PortCfg>>v=db.getAllBeans<PortCfg>();

 dptr->index      =  v[0]->Pindex;

@MastaChimp
Copy link

I've found I had to add locking mechanisms for this ORM.

  • Put a file-scoped mutex in Database.cpp
  • Add ScopeLock to
    • Database::dbSelectIds
    • Database::allocId
    • Database::dbExecQuery
    • Database::dbUpdate
    • Database::dbLoad

For the most part, this has solved the locking errors. I think there are still 2-3 places where they can happen, but locking out these sections has worked for about 2 weeks so far!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants