客户的问题是:

向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. SQLSERVER 检查字段值域并输出行数和值列表

    select * from ( SELECT 'C_DILEI' as fen,'地类' as fcn, 'NVARCHAR'as ftype, '2'as flen, ( SELECT count( ...

  2. UIScrollView 不能滚动的问题

    uiscrollview是开发sdk自带的控件, 在使用的时候,发现滚动不了, 最常山见的原因是 contentSize 这个属性,比uiscrollview的frame要小...所以无需滚动,自然就 ...

  3. XX.frame.origin.x 赋值问题

    can't use that myView.frame.origin.x=25.0; 因为.操作 和 = 一起用的话会调用 set方法.所以上式是行不通的. 可以用下面的方式来实现. that I h ...

  4. Linux makefile教程之隐含规则九[转]

    隐含规则 ———— 在 我们使用Makefile时,有一些我们会经常使用,而且使用频率非常高的东西,比如,我们编译C/C++的源程序为中间目标文件(Unix下是[.o] 文件,Windows下是[.o ...

  5. cocos2dx+lua中cc.EventListenerMouse:create()的bug

    今天在调试项目的时候用到了鼠标事件的监听 在创建事件监听器的时候出了问题 cc.EventListenerMouse:create() 这句返回值为nil 原来这是cocos2dx引擎的一个bug,t ...

  6. STL六大组件之——分配器(内存分配,好深奥的东西)

    SGI设计了双层级配置器,第一级配置器直接使用malloc()和free(),第二级配置器则视情况采用不同的策略:当配置区块超过128bytes时,视之为“足够大”,便调用第一级配置器:当配置区小于1 ...

  7. 一个有趣的模拟光照的shader(类似法线贴图)

    最近使用unity,碰到到一个很有趣的例子.场景无光线,却模拟出了光照,效果挺好.其思路与法线贴图原理异曲同工. 原作者提供的效果印象深刻. 模型除了使用原来的diffuse贴图外,还用到了一张模拟记 ...

  8. centos6.3 安装配置redis

    1.下载安装 1.1 下载包 注:在http://download.redis.io/releases查询需要下载的版本 wget http://download.redis.io/releases/ ...

  9. gson在java和json串之间的应用

    public class JsonToJavaUtil { /** * 将json转成成javaBean对象 * * @param <T> * 返回类型 * @param json * 字 ...

  10. JAVA逻辑字符串判断真假

    package com.chinahrt.zyn.iteye; import javax.script.Bindings; import javax.script.Compilable; import ...