854783 wrote:That is correct when your two databases reside in separate physical files.
My first understanding though is that a page will have only data that is relevant to a single database table, therefore if i have 2 database tables they will never land on the same page.Correct?
If it is correct, then is the following statement correct(put aside any HA for this question).At this point, it is important to distinguish the concept of a deadlock (T1 holds resource A and needs resource B. T2 holds resource B and needs resource A.) from the DB_LOCK_DEADLOCK return value. There is a large degree of overlap, but the return value encompasses other things (including, but not limited to HA).
- Since the locking is at page level and 2 databases are on different pages, a deadlock can never happen due to simultaneous writes to different table but can happen only due to simultaneous writes to the same table. Is that a valid statement?
- Following the same thinking with some more details, trying to do a dp->put() or txn_begin() from different tables should cause no problem. Is that correct?The phrase "cause no problem" is not correct. Beginning a txn is not affiliated with any database table. It is its own handle and then database operations occur within that txn. Users may choose to do a single operation in a txn, multiple operations to a single database, or multiple operations to many databases, all within a txn. Trying to do a db->put to different database tables should not cause an actual page resource deadlock, but could result in an error return indicating a variety of problems.
Now when it comes to HA, i would like to validate my understanding, basically when a site changes role (either from master to client or vice versa from client to master) there is a lockout which means that doing a db->put or txn_begin from any database table in that case will block or return rep_lockout if we are using conf_nowait? Is that correct?Actually db->put (and similar operations) are handled differently than txn/cursor resources. A db->put operation is a short-term "in the library" operation while a txn/cursor is a long-lived handle. Those are very distinct and different. The db->put operation will never wait for lockout to be released. It will always return right away (with either an error value or success). The txn/cursor usage will block waiting for BDB to release the lockout, unless you set the NOWAIT configuration flag.