Berkeley DB Replica Mechanism-master-Slave synchronization

Source: Internet
Author: User

REPMGR/REPMGR_NET.C,

__repmgr_send (): Do Send_broadcast, then deal with the db_rep_permanent according to policy

__repmgr_send_broadcast (): On each site, send_connection ().

MASTER Send

Log/log_put.c, Log_put (),

Do not accept Rep_client

__rep_send_message (env, Db_eid_broadcast,-Rep_newfile, Rep_log

Txn/txn_chkpt.c, __txn_checkpoint ()

Rep_client is here only when recover, sync MP quits immediately

Before Master Sync MP, send to client:

__rep_send_message (env, Db_eid_broadcast, Rep_start_sync

Waiting for Chkpt_delay

Write CKP Log Rec

Db_rep_rerequest vs Db_rep_anywhere

* GAP Requests is "new" and can go anywhere, unless
* This is already a re-request.

Repmgr_net.c, __repmgr_send ()

if ((Flags & Db_rep_anywhere | db_rep_rerequest)) ==db_rep_anywhere &&

(site = __repmgr_find_available_peer (env))

after sending, db_rep_permanent, check policy, how many ACK is required to return (for durability).

Http://docs.oracle.com/cd/E17076_03/html/api_reference/C/repmgrset_ack_policy.html

Default Db_repmgr_acks_quorum, Repmgr_net.c, __repmgr_send (), Visible (n-1)/2 + 1

After determined, __repmgr_await_cond (env, got_acks, &perm, Rep->ack_timeout, &db_rep->ack_waiters) ;

= = while (Got_acks (env, &perm)) {pthread_cond_timedwait (&db_rep->ack_waiters,rep->ack_ Timeout)}

Repmgr_net.c, Got_acks ().

Dbinc/rep.h,

struct __db_rep {}

Repmgr_runnable *selector, **messengers, **elect_threads;

WSAEventSelect

Client Receive

REPMGR_METHOD.C, __repmgr_start_int ()-Elect/msg/select threads
REPMGR_METHOD.C, __repmgr_start_selector ()
REPMGR_SEL.C, __repmgr_select_thread ()
REPMGR_WINDOWS.C, __repmgr_select_loop ()
REPMGR_WINDOWS.C, Handle_completion ()-
REPMGR_SEL.C, __repmgr_read_from_site ()
REPMGR_SEL.C, Dispatch_msgin ()-

Put Db_rep->input_queue, __repmgr_signal (&db_rep->msg_avail)

Rep.h, struct __db_rep- cond_var_t check_election, Gmdb_idle, msg_avail;


REPMGR_METHOD.C, __repmgr_start_int ()
REPMGR_METHOD.C, __repmgr_start_msg_threads ()
REPMGR_MSG.C, __repmgr_msg_thread ()
Message_loop ()

while (ret = __repmgr_queue_get () ...

__repmgr_queue_get-while (M = available_work (env)) = = NULL), wait on Msg_avail
Process_message ()
REPMGR_RECORD.C, __rep_process_message_int ()

For Rep_log messages, call

REP_LOG.C, __rep_log ()

REP_RECORD.C, __rep_apply ():

Log.h, struct Log {}-Waiting_lsn, Max_wait_lsn, __db.rep.db, READY_LSN

Waiting_lsn:it is the first LSN that we are holding without putting in the log, because we received one or more log rec Ords out of order.

Ready_lsn:it is the next LSN of we expect to receive. It s normally equal to "LSN", except at the beginning of a log file, at which point it's set to the lsn of th E first record of the new file

If it is the next log rec that we need, call __rep_process_rec (), __rep_remfirst/__rep_getnext then processes the log in TMP db; __rep _loggap_req ().

If it is behind the log rec we need, enter TMP db, update WAITING_LSN, send __rep_loggap_req ().

If you are in front of the log rec we need, we will receive duplicate log rec.

REP_RECORD.C, __rep_process_rec (), NewFile Special handling exit. In addition to CKP, the other writes directly to the log file first

-Db___txn_prepare: Flush log directly

-Db___txn_regop: __rep_process_txn (), get the required write lock, get the TXN corresponding to all the log rec, sort, read out, Db_dispatch (db_txn_apply

-DB___TXN_CKP: First write a rec in rep_db (bookkeeping DB), nooverwrite, if there is already, then other threads are doing CKP, exiting. Sync MP; Write DB_LOG_CHKPNT log rec, flush log

Berkeley DB Replica Mechanism-master-Slave synchronization

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.