[pybsddb] bdb replica node problem

Jesus Cea jcea at argo.es
Thu May 29 11:44:48 CEST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yingbo Qiu wrote:
| I just want a Master-Slave mode to balance read performance.
| so I set replica node's priority to 0 and open db with DB_RDONLY flag.
| But if I directly open db after repmgr_start, it may report DeadLock
| status, or open db without any error but follow read operation will raise
| RUNRECOVERY error.
[...]
| Why?

The problem is that you are trying to open a replicated environment
before it is created, since client is still trying to synchronize with
server.

This is an issue only when you launch client first time. When the
environment already exists, even if it is outdated, you wouldn't have
this problem (unless you are trying to open a newly created DB in the
master, still not replicated to the client).

The easy thing to do is to have a "bootstrap client" code, only used in
newly created clients. This code would join the replicated environment
until it gets a DB_EVENT_REP_STARTUPDONE and then die.

After that, you can call the regular client.

| Now I put the db open operation in DB_EVENT_REP_STARTUPDONE
| event callback function, and it seem ok. But bdb manual say
| that isn't reliable.
|
http://www.oracle.com/technology/documentation/berkeley-db/db/api_c/env_event_notify.html
|
| How do you think about my problem??

You *MUST NOT* call Berkeley DB methods from a callback. This can crash
your program, or worse. You must "signal" the event to the main code via
a flag, a threading.Event or something like that. See replication testcode.

The problem with DB_EVENT_REP_STARTUPDONE is that if you can't connect
to master, you can hang forever (unless you held elections an a new
master gets elected). In the test code, I control both the callback and
a timeout.

- --
Jesus Cea Avion                         _/_/      _/_/_/        _/_/_/
jcea at jcea.es - http://www.jcea.es/     _/_/    _/_/  _/_/    _/_/  _/_/
jabber / xmpp:jcea at jabber.org         _/_/    _/_/          _/_/_/_/_/
~                               _/_/  _/_/    _/_/          _/_/  _/_/
"Things are not so easy"      _/_/  _/_/    _/_/  _/_/    _/_/  _/_/
"My name is Dump, Core Dump"   _/_/_/        _/_/_/      _/_/  _/_/
"El amor es poner tu felicidad en la felicidad de otro" - Leibniz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQCVAwUBSD57Cplgi5GaxT1NAQJPZgP8CiND6F2QqmRo2kiQgW/vx8rHIZCWcoLC
c/xoNpAn+JTPR7Vvif2XsGabonMSJPAQynB9HXy2/MnJ0Fq0Np0dZ11xh0iWPFyG
oasxsu0VrD6sFvikjzC0BmekNWgrzi8h2ImA1sba4dwE6cPLSEvoBkbK8Fq3iGVB
XfNWVcKSxy4=
=ehQq
-----END PGP SIGNATURE-----



More information about the pybsddb mailing list