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

为什么代码里面的写入Levedb做了两次呢? #1345

Open
taomin597715379 opened this issue May 17, 2020 · 4 comments
Open

为什么代码里面的写入Levedb做了两次呢? #1345

taomin597715379 opened this issue May 17, 2020 · 4 comments

Comments

@taomin597715379
Copy link

binlogs->Put(buf, slice(val));
binlogs->add_log(log_type, BinlogCommand::KSET, buf);
其中 add_log中也存在一次写入Leveldb,只不过他的Key不是buf了,而是tran_seq,这样做的目的是?

@ideawu
Copy link
Owner

ideawu commented May 17, 2020

Hi, ssdb 的写入逻辑是把实际的数据操作(Put, Delete)与对应的 binlog 放到 WriteBatch 里, 作为一个原子操作写入磁盘.

@taomin597715379
Copy link
Author

也就是Binlog跟实际的数据一样,被写入到LevelDb里面,对吧?

@taomin597715379
Copy link
Author

这样的设计是不是不太好呢?主从同步的时候,正常情况是同步Binlog文件,在第一次通过tcp传文件即可,非常快,后面再做增量同步。但如果按照现在的设计,Binlog也在LeveDb的ldb文件里面,在同步的时候,你还得遍历出所有的Binlog数据,然后再一点点同步到从节点。

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

3 participants
@ideawu @taomin597715379 and others