Slony-I的 RemoteWorker重试调查
客户的问题是:
向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重试调查的更多相关文章
- ElasticSearch 的一次非正常master脱离的调查 (转 和我碰到的情况一模一样)
转自 http://simonlei.iteye.com/blog/1669992 一共有4个节点的cluster,其中es4 是master,某个时间突然es1脱离了整个cluster,调查过程如下 ...
- 由VIP漂移引发的算法异常问题调查和解决
最近工作中的一个问题,耗时一个月之久终于调查完毕且顺利解决,顿时感慨万千.耗时之久和预期解决时间和环境搭建以及日志不合理等等有关,当然这个并非此文的重点.之所以在很久以后的今天又开始写文,主要是这个问 ...
- easyui模板页面 不良调查
<%@page import="com.xy.cc.util.CUtil" %><%@page import="com.xy.cc.bean.UserP ...
- 当master down掉后,pt-heartbeat不断重试会导致内存缓慢增长
最近同事反映,在使用pt-heartbeat监控主从复制延迟的过程中,如果master down掉了,则pt-heartbeat则会连接失败,但会不断重试. 重试本无可厚非,毕竟从使用者的角度来说,希 ...
- O365(世纪互联)SharePoint 之调查列表简单介绍
前言 SharePoint中为了提供了很多开箱即用的应用程序,比如调查列表就是其中之一,同样,在O365版本里(国际版和世纪互联版本均可),也有这样的调查列表可以供我们使用,而使用起来非常方便和快速, ...
- Office 365使用情况调查不完全分析报告
感谢大家参与了9月13日在Office 365技术群(O萌)中发起的一个关于Office 365使用情况的调查,在一天左右的时间内,我们一共收到了67份反馈,其中绝大部分是在3分钟内提交的. 本次调查 ...
- 基于Lease分布式系统重试服务选举
/** * Copyright (c) 2015, www.cubbery.com. All rights reserved. */ package com.cubbery.event.retry; ...
- 【Java EE 学习 73】【数据采集系统第五天】【参与调查】【导航处理】【答案回显】【保存答案】
一.参与调查的流程 单击导航栏上的“参与调查”按钮->EntrySurveyAction做出相应,找到所有的Survey对象并转发到显示所有survey对象的页面上供用户选择->用户单击其 ...
- 【Java EE 学习 72 上】【数据采集系统第四天】【增加调查logo】【文件上传】【动态错误页指定】【上传限制】【国际化】
增加logo的技术点:文件上传,国际化 文件上传的功能在struts2中是使用文件上传拦截器完成的. 1.首先需要在页面上添加一个文件上传的超链接. 点击该超链接能够跳转到文件上传页面.我给该表单页面 ...
随机推荐
- XX.frame.origin.x 赋值问题
can't use that myView.frame.origin.x=25.0; 因为.操作 和 = 一起用的话会调用 set方法.所以上式是行不通的. 可以用下面的方式来实现. that I h ...
- 搭建XMPP协议,实现自主推送消息到手机
关于服务器端向Android客户端的推送,主要有三种方式: 1.客户端定时去服务端取或者保持一个长Socket,从本质讲这个不叫推送,这是去服务端拽数据.但是实现简单,主要缺点:耗电等 2.Googl ...
- 10、NFC技术:读写NFC标签中的文本数据
代码实现过程如下: 读写NFC标签的纯文本数据.java import java.nio.charset.Charset; import java.util.Locale; import androi ...
- IE对toLocaleString小数位处理
在js中对数值的格式化经常会用到四舍五入.保留小数位数.百分制格式化,分别会用到以下方法 <script type="text/javascript"> var n = ...
- 为网页设计师准备的30个使用的HTML5框架
原文地址:http://www.goodfav.com/zh/html5-framework-8189.html 网页设计师在开始使用一些应用程序之前需要考虑几个事实,以确保在应用Web程序框架时,这 ...
- Linux文件系统 (Ubunt)
Linux 文件系统是linux的一个十分基础的知识,同时也是学习linux的必备知识. 本文将站在一个较高的视图来了解linux的文件系统,主要包括了linux磁盘分区和目录.挂载基本原理.文件存储 ...
- c++类使用
一.C++定义类(注意:结束部分的分号不能省略) class 类名 { public: //公共的行为或属性 private: //公共的行为或属性 }; 注意:类的成员变量在定义时不能进行初始化, ...
- iOS开发-你真的会用SDWebImage?(转发)
原文地址: http://www.jianshu.com/p/dabc0c6d083e SDWebImage作为目前最受欢迎的图片下载第三方框架,使用率很高.但是你真的会用吗?本文接下来将通过例子分析 ...
- Oracle创建删除用户,角色,表空间,导入导出数据库命令总结(转载)
无意间看到一篇文章,觉得对于ORACLE的新手很实用,特转载,原文出处这里 说明:在创建数据库时输入的密码,是修改系统默认的密码,以system和sysman等系统默认身份登录时要输入的密码就是修改后 ...
- 第三百三十九天 how can I 坚持
脑子里老是无缘无故浮现出之前学的古文,之前只是傻学了,什么都没搞懂啊. 吾师道也,夫庸知其年之先后生于吾乎?是故无贵无贱,无长无少,道之所存,师之所存也. 是故弟子不必不如师,师不必贤于弟子,闻道有先 ...