Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src 是副本集的情况下,无法读取Secondary的数据 #1

Open
TOTom opened this issue Dec 11, 2014 · 10 comments
Open

src 是副本集的情况下,无法读取Secondary的数据 #1

TOTom opened this issue Dec 11, 2014 · 10 comments

Comments

@TOTom
Copy link

TOTom commented Dec 11, 2014

1、src 是副本集的情况下,无法读取Secondary的数据,无法从副本集的单个member 中同步数据
2、副本集默认只读权限,出错信息:
OperationFailure: command SON([('count', u'app'), ('fields', None), ('query', {})]) failed: not authorized on track to execute command { count: "app", fields: null, query: {} }

@matrix2011
Copy link
Owner

你好,谢谢反馈。1. src 同步数据是从Primary读取数据的,为什么要读取Secondary的数据呢?2. 这里是需要admin的账号,代码中授权是采用admin db授权的,需要使用管理员账号。

@TOTom
Copy link
Author

TOTom commented Dec 12, 2014

sorry,今天看了源码,确实如此,还有下面的代码有问题,这个变量找不到:self._realTS
def del(self):
global g_msg_queue, g_realTS

    if self._realTS and self._conf.mode in ['incr', 'smart']:
        logging.info('update ts before exit')
        updateOptTime(self._conf.opt_file, self._src_conn.getRepl(), g_realTS)

@matrix2011
Copy link
Owner

谢谢,self._realTS 确实找不到,bug 已经修复。

@TOTom
Copy link
Author

TOTom commented Dec 18, 2014

请问下,全量同步的时候这两句是否应该调一下执行顺序,先写入optime ,再全量同步?
self._ensureDB(db, copy_data=True)
updateOptTime(self._conf.opt_file, self._src_conn.getRepl(), self._getSrcOptime())

@matrix2011
Copy link
Owner

这个特性没有很好地测试,不过放到前面确实是比较安全的做法。

@TOTom
Copy link
Author

TOTom commented Dec 20, 2014

我updateOptTime 提前了,不过还有一个问题,如何解决同步过程中断网的情况?:
if self._conf.mode in ['all', 'smart']:
updateOptTime(self._conf.opt_file, self._src_conn.getRepl(), self._getSrcOptime())

    for db in self._conf.dbs:
        if self._conf.mode in ['all', 'smart']:
            self._ensureDB(db, copy_data=True)
        else:
            self._ensureDB(db, copy_data=False)

@TOTom
Copy link
Author

TOTom commented Dec 20, 2014

find 函数查询的原理是什么?没有while 循环也能一直读取?
cursor = self._src_mc[dbname][collname].find(spec=None, snapshot=True, timeout=False)

@matrix2011
Copy link
Owner

断网是没有问题的,会有自动重连机制,我们异地同步有过多次网络故障,但是目前都正常工作的。find有参数控制读取的策略,具体可以参见文档,包括:tailable,snapshot 等参数。

@TOTom
Copy link
Author

TOTom commented Dec 20, 2014

我的现象是套接字假死,进程挂起了

@matrix2011
Copy link
Owner

是源还是目的地址断了?是什么类型断网?ip没有了还是说ping不通?我来浮现下看看。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants