客户的问题是:

向Slony-I运行环境中,增加新的slaveDB节点的时候发生错误。

log中反复出现错误,然后再重新开始(重新开始部分的log省略):

CONFIG remoteWorkerThread_1: connected to provider DB
CONFIG remoteWorkerThread_1: prepare to copy table "tst"."a_tbl"
CONFIG remoteWorkerThread_1: prepare to copy table "tst"."b_tbl"
CONFIG remoteWorkerThread_1: prepare to copy table "tst"."c_tbl"
CONFIG remoteWorkerThread_1: all tables for set found on subscriber
CONFIG remoteWorkerThread_1: copy sequence "tst"."a_no_seq"
CONFIG remoteWorkerThread_1: copy sequence "tst"."b_no_seq"
CONFIG remoteWorkerThread_1: copy sequence "tst"."c_no_seq" CONFIG remoteWorkerThread_1: copy table "tst"."a_tbl"
CONFIG remoteWorkerThread_1: Begin COPY of table "tst"."a_tbl"
NOTICE: truncate of "tst"."a_tbl" succeeded
CONFIG remoteWorkerThread_1: bytes copied for table "tst"."a_tbl"
CONFIG remoteWorkerThread_1: 27.97 seconds to copy table "tst"."a_tbl" CONFIG remoteWorkerThread_1: copy table "tst"."b_tbl"
CONFIG remoteWorkerThread_1: Begin COPY of table "tst"."b_tbl"
ERROR remoteWorkerThread_1: "select "_mycluster".copyFields(2);" WARN remoteWorkerThread_1: data copy for set failed times - sleep seconds
NOTICE: Slony-I: Logswitch to sl_log_2 initiated
CONTEXT: SQL statement "SELECT "_mycluster".logswitch_start()"

经过查阅资料,并且和客户沟通,发现是他们的网络环境有问题:原有节点所在网段和新增节点不在一个网段。而他们又使用了网络工具来监控网络,在某些特定情况下,网络工具会切点网络连接。

正式此原因,导致出错。然后我进行了代码分析,发现remoteworker是很勤劳的,如果发生了通讯错误,它会反复重试的:

remoteWorkerThread_main函数的while循环,就会完成这个工作。

/* ----------
* slon_remoteWorkerThread
*
* Listen for events on the local database connection. This means, events
* generated by the local node only.
* ----------
*/
void *
remoteWorkerThread_main(void *cdata)
{

/*
* Work until shutdown or node destruction
*/
while (true)
{

/*
* Event type specific processing
*/
if (strcmp(event->ev_type, "SYNC") == )
{

}
else /* not SYNC */
{

/*
* Simple configuration events. Call the corresponding runtime
* config function, add the query to call the configuration event
* specific stored procedure.
*/
if (strcmp(event->ev_type, "STORE_NODE") == )
{

}

else if (strcmp(event->ev_type, "ENABLE_SUBSCRIPTION") == )
{

int copy_set_retries = ;
… if (sub_receiver == rtcfg_nodeid &&
event->ev_origin == node->no_id)
{
ScheduleStatus sched_rc;
int sleeptime = ;

while (true)
{

/*
* If the copy succeeds, exit the loop and let the
* transaction commit.
*/

if (copy_set(node, local_conn, sub_set, event) == )
{

copy_set_retries = ;
break;
}
copy_set_retries++; /*
* Data copy for new enabled set has failed. Rollback
* the transaction, sleep and try again.
*/
slon_log(SLON_WARN, "remoteWorkerThread_%d: "
"data copy for set %d failed %d times - "
"sleep %d seconds\n",
node->
no_id, sub_set, copy_set_retries,
sleeptime);

}
}
else
{

}

}

else
{

} /*
* All simple configuration events fall through here. Commit the
* transaction.
*/

}

}

} /* ----------
* copy_set
* ----------
*/
static int
copy_set(SlonNode *node, SlonConn *local_conn, int set_id,
SlonWorkMsg_event *event)
{

/*
* Connect to the provider DB
*/

slon_log(SLON_CONFIG, "remoteWorkerThread_%d: "
"connected to provider DB\n",
node->no_id);

/*
* For each table in the set
*/
for (tupno1 = ; tupno1 < ntuples1; tupno1++)
{
char *tab_fqname = PQgetvalue(res1, tupno1, ); gettimeofday(&tv_start2, NULL);
slon_log(SLON_CONFIG, "remoteWorkerThread_%d: "
"prepare to copy table %s\n",
node->no_id, tab_fqname); (void) slon_mkquery(&query3, "select * from %s limit 0;",
tab_fqname);
res2 = PQexec(loc_dbconn, dstring_data(&query3));

}

slon_log(SLON_CONFIG, "remoteWorkerThread_%d: "
"all tables for set %d found on subscriber\n",
node->no_id, set_id);

for (tupno1 = ; tupno1 < ntuples1; tupno1++)
{

slon_log(SLON_CONFIG, "remoteWorkerThread_%d: "
"copy sequence %s\n",
node->no_id, seq_fqname);

}
… /*
* For each table in the set
*/
for (tupno1 = ; tupno1 < ntuples1; tupno1++)
{

slon_log(SLON_CONFIG, "remoteWorkerThread_%d: "
"copy table %s\n",
node->no_id, tab_fqname);

if (omit_copy) {

} else {
slon_log(SLON_CONFIG, "remoteWorkerThread_%d: "
"Begin COPY of table %s\n",
node->no_id, tab_fqname); (void) slon_mkquery(&query2, "select %s.copyFields(%d);",
rtcfg_namespace, tab_id); res3 = PQexec(pro_dbconn, dstring_data(&query2)); if (PQresultStatus(res3) != PGRES_TUPLES_OK)
{
slon_log(SLON_ERROR, "remoteWorkerThread_%d: \"%s\" %s\n",
node->no_id, dstring_data(&query2),
PQresultErrorMessage(res3));

return -;
} …
slon_log(SLON_CONFIG, "remoteWorkerThread_%d: "
INT64_FORMAT " bytes copied for table %s\n",
node->no_id, copysize, tab_fqname);

slon_log(SLON_CONFIG, "remoteWorkerThread_%d: "
"%.3f seconds to copy table %s\n",
node->no_id,
TIMEVAL_DIFF(&tv_start2, &tv_now), tab_fqname);
}

return ;
}

Slony-I的 RemoteWorker重试调查的更多相关文章

  1. ElasticSearch 的一次非正常master脱离的调查 (转 和我碰到的情况一模一样)

    转自 http://simonlei.iteye.com/blog/1669992 一共有4个节点的cluster,其中es4 是master,某个时间突然es1脱离了整个cluster,调查过程如下 ...

  2. 由VIP漂移引发的算法异常问题调查和解决

    最近工作中的一个问题,耗时一个月之久终于调查完毕且顺利解决,顿时感慨万千.耗时之久和预期解决时间和环境搭建以及日志不合理等等有关,当然这个并非此文的重点.之所以在很久以后的今天又开始写文,主要是这个问 ...

  3. easyui模板页面 不良调查

    <%@page import="com.xy.cc.util.CUtil" %><%@page import="com.xy.cc.bean.UserP ...

  4. 当master down掉后,pt-heartbeat不断重试会导致内存缓慢增长

    最近同事反映,在使用pt-heartbeat监控主从复制延迟的过程中,如果master down掉了,则pt-heartbeat则会连接失败,但会不断重试. 重试本无可厚非,毕竟从使用者的角度来说,希 ...

  5. O365(世纪互联)SharePoint 之调查列表简单介绍

    前言 SharePoint中为了提供了很多开箱即用的应用程序,比如调查列表就是其中之一,同样,在O365版本里(国际版和世纪互联版本均可),也有这样的调查列表可以供我们使用,而使用起来非常方便和快速, ...

  6. Office 365使用情况调查不完全分析报告

    感谢大家参与了9月13日在Office 365技术群(O萌)中发起的一个关于Office 365使用情况的调查,在一天左右的时间内,我们一共收到了67份反馈,其中绝大部分是在3分钟内提交的. 本次调查 ...

  7. 基于Lease分布式系统重试服务选举

    /** * Copyright (c) 2015, www.cubbery.com. All rights reserved. */ package com.cubbery.event.retry; ...

  8. 【Java EE 学习 73】【数据采集系统第五天】【参与调查】【导航处理】【答案回显】【保存答案】

    一.参与调查的流程 单击导航栏上的“参与调查”按钮->EntrySurveyAction做出相应,找到所有的Survey对象并转发到显示所有survey对象的页面上供用户选择->用户单击其 ...

  9. 【Java EE 学习 72 上】【数据采集系统第四天】【增加调查logo】【文件上传】【动态错误页指定】【上传限制】【国际化】

    增加logo的技术点:文件上传,国际化 文件上传的功能在struts2中是使用文件上传拦截器完成的. 1.首先需要在页面上添加一个文件上传的超链接. 点击该超链接能够跳转到文件上传页面.我给该表单页面 ...

随机推荐

  1. struts2 action 返回图片流

    数据库为mssql zp字段为image类型 java代码 OutputStream out = null; try { String contenttype = "image/jpeg&q ...

  2. HDU 5137 How Many Maos Does the Guanxi Worth

    How Many Maos Does the Guanxi Worth Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 512000/5120 ...

  3. 使用 Google Fonts 为网页添加美观字体

    前言 文字是网页中很重要的组成部分.为文字选择一个合适的字体,能够更好的展现一个网站的个性,表达所要传递的信息,同时吸引用户来产生兴趣. 说到字体,我们首先会想到 CSS 里面的 font,例如: & ...

  4. loadrunner11录制不成功解决方法

    问题一:loadrunner11录制时events为0的解决办法  刚安装好的11.0,系统环境是:WIN7+IE11+LR11 1.ie去掉工具—internet选项中->高级—>去掉“ ...

  5. 单机版搭建Hadoop环境图文教程详解

    安装过程: 一.安装Linux操作系统二.在Ubuntu下创建hadoop用户组和用户三.在Ubuntu下安装JDK四.修改机器名五.安装ssh服务六.建立ssh无密码登录本机七.安装hadoop八. ...

  6. layout相关

    大致看了看布局大致有5种(approximately) 1. LinearLayout 2. RelativeLayout 3. FrameLayout 4. TableLayout 5. GridL ...

  7. nginx指令

    Directives(指令) Syntax(语法): aio on | off | threads[=pool]; Default: aio off; Context: http, server, l ...

  8. python中的多线程【转】

    转载自: http://c4fun.cn/blog/2014/05/06/python-threading/ python中关于多线程的操作可以使用thread和threading模块来实现,其中th ...

  9. AutoCompleteTextView使用 监听

    AutoCompleteTextView使用 An editable text view that shows completion suggestions automatically while t ...

  10. Hadoop2.2.0 手动切换HA环境搭建

    ssh-copy-id -i hadoop5含义: 节点hadoop4上执行ssh-copy-id -i hadoop5的含义是把hadoop4上的公钥id_rsa.pub的内容追加到hadoop5的 ...