Groups
Groups
Sign in
Groups
Groups
skynet-users
Conversations
About
Send feedback
Help
skynet连接外部数据库,闪断后的恢复问题
181 views
Skip to first unread message
cc
unread,
Jan 14, 2017, 12:41:10 AM
1/14/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to skynet-users
最近遇到个问题,可以抽象成这样。单个skynet进程内,有多个业务服务要请求一个数据服务,数据服务简单地读写另外一台主机上的数据库(可以认为是redis或MySQL)。由于网络等各种原因,数据服务跟数据库的连接偶尔会闪断几秒钟,现在希望数据服务能够在断开数据库连接期间缓存业务服务的请求(包括send和call),数据服务重连上数据库后再按顺序处理之前的业务服务的请求。
曾经想到个方案,数据服务发现操作数据库异常时,记录一个session,过一段时间后如果连上了并且session相同,则按正常流程走;没连上或session不同,则过一段时间后再试,如此循环。后面发现那个时间不好把控,主要是因为重连数据库后,缓存的消息不是一个紧接一个处理。
cc
unread,
Jan 16, 2017, 4:48:21 AM
1/16/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to skynet-users
云大,你说报错的时候循环sleep是不是最简单直接。但这个方案CPU可能会不同意
local function sleep(n)
for i=1,n do
end
end
sleep(100000000)
------------------ 原始邮件 ------------------
发件人:
"cc"<
28328...@qq.com
>;
发送时间:
2017年1月14日(星期六) 中午1:41
收件人:
"skynet-users"<
skynet...@googlegroups.com
>;
主题:
[skynet] skynet连接外部数据库,闪断后的恢复问题
最近遇到个问题,可以抽象成这样。单个skynet进程内,有多个业务服务要请求一个数据服务,数据服务简单地读写另外一台主机上的数据库(可以认为是redis或MySQL)。由于网络等各种原因,数据服务跟数据库的连接偶尔会闪断几秒钟,现在希望数据服务能够在断开数据库连接期间缓存业务服务的请求(包括send和call),数据服务重连上数据库后再按顺序处理之前的业务服务的请求。
曾经想到个方案,数据服务发现操作数据库异常时,记录一个session,过一段时间后如果连上了并且session相同,则按正常流程走;没连上或session不同,则过一段时间后再试,如此循环。后面发现那个时间不好把控,主要是因为重连数据库后,缓存的消息不是一个紧接一个处理。
--
您收到此邮件是因为您订阅了Google网上论坛上的“skynet-users”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到
skynet-users...@googlegroups.com
。
要发帖到此群组,请发送电子邮件至
skynet...@googlegroups.com
。
访问此群组:
https://groups.google.com/group/skynet-users
。
要在网络上查看此讨论,请访问
https://groups.google.com/d/msgid/skynet-users/tencent_07D565254BFDE1AB1720486F%40qq.com
。
要查看更多选项,请访问
https://groups.google.com/d/optout
。
Zheng Fangxin
unread,
Jan 19, 2017, 4:02:25 AM
1/19/17
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to skynet-users
要sleep也该用skynet.sleep
在 2017年1月14日星期六 UTC+8下午1:41:10,cc写道:
Reply all
Reply to author
Forward
0 new messages