Giter VIP home page Giter VIP logo

phxpaxos's Introduction

简体中文README

PhxPaxos is a state-synchronization lib based on Paxos protocol, it is totally designed by Wechat independently. It can help your services in synchronizing the state from a single node to the other nodes to form a multi-copy cluster and handling fail-over automatically by calling functions in our lib.

This lib has been used in Wechat production environment, we have also tested it in a large number of harsh environments to guarantee a stable consistency.

Authors: Haochuan Cui, Ming Chen, Junchao Chen and Duokai Huang

Contact us: [email protected]

Principle details(Chinese)

PhxPaxos Build Status

Features

  • Purely based on Paxos Made Simple by Lamport.
  • Transfering message in a async mechanism architecture.
  • Using fsync to guarantee the correctness in every IO write operations.
  • Latency of a successful Propose is one RTT and one IO write.
  • Using P2P stream protocol to learn paxos log.
  • Cleaning Checkpoint and PaxosLog automatically.
  • Pulling Checkpoint across nodes automatically.
  • Supporting more than one state-machines in a single PhxPaxos Instance.
  • Supporting recover checkpoint by snapshot+paxoslog automatically.
  • Implementing Master election as a state-machine embedded in PhxPaxos
  • Implementing reconfiguration as a state-machine embedded in PhxPaxos
  • Using signature algorithm embedded in PhxPaxos to recognise invalid hosts.
  • Using checksum to verifying the data consistency of increment data in realtime.
  • Implementing Network, Stroage, Monitor, Logging module as a plugin, they can be implemented customly
  • Supporting overload protection in a self-adaption way.

Limitations

  • Only a single process (possibly multi-threaded) can run a PhxPaxos instance at a time.
  • There is no client-server support builtin to the library. An application that needs such support will have to wrap their own server around the library.
  • PhxPaxos was only tested on Linux 64bit platform so far.

Performance

Setup

CPU: 24 x Intel(R) Xeon(R) CPU E5-2420 0 @ 1.90GHz
Memory: 2 GB
Disk: ssd raid5
Network: Gigabit Ethernet
Cluster Nodes: 3
Ping: 0.05ms
Parallel client: 100 Threads

Performance Test Result(QPS)

Request latency small than 10ms.

Data set with small size(100B)
1 Group: 1171
20 Groups: 11931
50 Groups: 13424
100 Groups: 13962
Data set with larse size(100KB)
1 Group: 280
20 Groups: 984
50 Groups: 1054
100 Groups: 1067
BatchPropose(2KB)
100 Groups: 150000

Code Directory Introduction

include: This directory includes all head files while using PhxPaxos. You may make some mistakes if you don't understand all the functions in this directory completely.

NOTE: The public interface is in include/*.h. Callers should not include or rely on the details of any other header files in this package. Those internal APIs may be changed without warning.

src: This directory includes all implementation of Phapaxos, You can figure out the working principle of PhxPaoxs by reading this directorys. No neccessary to read it if you are only using PhxPaxos.

third_party: This directory is designed to place all third party libs for compiling and running PhxPaxos. You can get a detail in the following compilation section. We have only two libs requirement: Protobuf and LevelDB.

plugin: This directory provides the plugin of Logging module. Loggins is an important way to debug a program. But different organazations always implement it in a totally different way. So PhxPaxos does not provide a specific implementation of Logging, instead, it provides the mechanism of Logging so everyone can implement it customly. We also implement a specific Logging by using GLOG for you. If you are using GLOG this may help you in saving your development time.

sample: This directory provides 3 samples based on PhxPaoxs, They representive different depth of using PhxPaxos, from easy to hard.

  • PhxElection: This is a very simple program. It implements a Master Election Program by a Master Election state-machine which is embedded in PhxPaxos.
  • PhxEcho: This shows how to program a status-machine and combine it with PhxPaxos.
  • PhxKV: This is a more complete system. which implements a KV state-machine. It shows how to implement a distributed KV storage system by PhxPaxos and how to delete PaxosLog by implementing the Checkpoint API. It also shows how to combine this code into a RPC(etc: GRPC) framework to get a complete distributed KV storage system.

Guide to Header Files:

  • include/node.h The beginning of PhxPaxos. We strongly suggest you to begin here.
  • include/options.h Some configurations and options needed while running PhxPaxos.
  • include/sm.h A base class of state-machine.
  • include/def.h Sets of return code.
  • include/network.h Abstract function of Network Module. You can use your own network protocol by overloading these functions.
  • include/storage.h Abstract function of Storage Module.
  • include/log.h Abstract function of Logging Module.
  • include/breakpoint.h Abstract function of breaking points, add your ownMonitor Module here to monitor these break points.

How to Compile

Third party libs preparation

Following is a dependency relationship tablet of all directories.

Directories compilation target inner dependency third party dependency
root libphxpaxos.a None protobuf,leveldb
plugin libphxpaxos_plugin.a libphxpaxos.a glog
sample/phxelection Executable program libphxpaxos.a,libphxpaxos_plugin.a None
sample/phxecho Executable program libphxpaxos.a,libphxpaxos_plugin.a None
sample/phxkv Executable program libphxpaxos.a,libphxpaxos_plugin.a grpc
src/ut Unit tests None gtest,gmock

We only need 2 third party libs: Protobuf and Leveldb while compiling PhxPaxos library(target is libphxpaoxs.a).But we need GLOG and GRPC while compiling other directories. All these third party libs should be prepared and palced in our third_party directory before PhxPaxos compilation. You can git clone them by adding --recurse-submodules on just download and link them.

Compilation Enviroment

  • Linux
  • GCC-4.8 or above

Compilation and Installation

How to Complie libphxpaxos.a.

Execute following shell commands in root directory of PhxPaxos

./autoinstall.sh
make
make install
How to Complie libphxpaxos_plugin.a.

Execute following shell commands in plugin directory.

make
make install

How to Wrap Your Own Code Around PhxPaxos.

First choose a single node service.

We will show you this by a PhxEcho service in our sample directory, Echo is a common test functions while writing an RPC service. We will wrap this service's code around PhxPaxos to make Echo into a multi-node service.

First, Assume following is the definition fo PhxEchoServer

class PhxEchoServer
{
public:
    PhxEchoServer();
    ~PhxEchoServer();

    int Echo(const std::string & sEchoReqValue, std::string & sEchoRespValue);
};

Let's wrap this code around PhxPaxos.

Second, implement a state-machine

We now define a PhxEchoSM state-machine which inherit from class StateMachine as the following

class PhxEchoSM : public phxpaxos::StateMachine
{
public:
    PhxEchoSM();

    bool Execute(const int iGroupIdx, const uint64_t llInstanceID, 
            const std::string & sPaxosValue, phxpaxos::SMCtx * poSMCtx);

    const int SMID() const { return 1; }
};

SMID() functions should return an unique identifier since PhxPaxos support more than 1 state-machines at the same time.

Execute() is a state transition function of this state-machine. PhxPaxos guarantees all nodes will execute sPaxosValue in the same order to achieve strong consistency (sPaxosValue is one of input arguments of Execute()). Following is the implementation of this functions:

bool PhxEchoSM :: Execute(const int iGroupIdx, const uint64_t llInstanceID, 
        const std::string & sPaxosValue, SMCtx * poSMCtx)
{
    printf("[SM Execute] ok, smid %d instanceid %lu value %s\n", 
            SMID(), llInstanceID, sPaxosValue.c_str());

    //only commiter node have SMCtx.
    if (poSMCtx != nullptr && poSMCtx->m_pCtx != nullptr)
    {   
        PhxEchoSMCtx * poPhxEchoSMCtx = (PhxEchoSMCtx *)poSMCtx->m_pCtx;
        poPhxEchoSMCtx->iExecuteRet = 0;
        poPhxEchoSMCtx->sEchoRespValue = sPaxosValue;
    }   

    return true;
}

We only print it on the screen as a prove of broadcasting this Echo message.

Here we got a strange class SMCtx, following is the definition.

class SMCtx
{
public:
    SMCtx();
    SMCtx(const int iSMID, void * pCtx);

    int m_iSMID;
    void * m_pCtx;
};

SMCtx is a context argument which is provide by proposer(we will offer more details in the following introduction), transmitted to Execute() function by PhxPaxos and finally callback to proposer.

m_iSMID is related to SMID() function mentioned above.PhxPaxos will transmit this to a specific state-machine which owns the same id.

m_pCtx is a customly context point address provided by proposer.

The context arguments of Execute() functions is a nullptr in all nodes except the one which propose it. Developer should judge if it is NULL while implementing, otherwise it will cause a segment fault.

Following shows the context definition of Echo:

class PhxEchoSMCtx
{
public:
    int iExecuteRet;
    std::string sEchoRespValue;

    PhxEchoSMCtx()
    {   
        iExecuteRet = -1; 
    }   
};

iExecuteRet represents the return code of Execute() execution.

sEchoRespValue represents the sEchoReqValue transmit by Execute().

We finally construct a state-machine and a state transmittion function by classes above.

HINT: What you should do to make a service into a replicated service is to abstract the logic of it. And then implement it in a Execute() fuction. That's all:)

Running PhxPaxos

After the implementation, We will try to run PhxPaxos with PhxEchoSM loaded.

We will do some modifications for EchoServer class first:

class PhxEchoServer
{
public:
    PhxEchoServer(const phxpaxos::NodeInfo & oMyNode, const phxpaxos::NodeInfoList & vecNodeList);
    ~PhxEchoServer();

    int RunPaxos();
    int Echo(const std::string & sEchoReqValue, std::string & sEchoRespValue);

    phxpaxos::NodeInfo m_oMyNode;
    phxpaxos::NodeInfoList m_vecNodeList;

    phxpaxos::Node * m_poPaxosNode;
    PhxEchoSM m_oEchoSM;
};

We add some arguments in construction function, oMyNode represents the information(IP, Port, etc...) of this node. vecNodeList represents informations of all nodes in this cluster. These 2 arguments is pre-defined by PhxPaxos.

Except m_oMyNode and m_vecNodeList, m_oEchoSM is a state-machine we just finished, m_poPaxosNode represents the instance pointer of PhxPaxos running this time.

PhxPaxos instance is actived by executing RunPaxos() function, following is the implementation of this function:

int PhxEchoServer :: RunPaxos()
{
    Options oOptions;

    int ret = MakeLogStoragePath(oOptions.sLogStoragePath);
    if (ret != 0)
    {   
        return ret;
    }   

    //this groupcount means run paxos group count.
    //every paxos group is independent, there are no any communicate between any 2 paxos group.
    oOptions.iGroupCount = 1;

    oOptions.oMyNode = m_oMyNode;
    oOptions.vecNodeInfoList = m_vecNodeList;

    GroupSMInfo oSMInfo;
    oSMInfo.iGroupIdx = 0;
    //one paxos group can have multi state machine.
    oSMInfo.vecSMList.push_back(&m_oEchoSM);
    oOptions.vecGroupSMInfoList.push_back(oSMInfo);

    //use logger_google to print log
    LogFunc pLogFunc;
    ret = LoggerGoogle :: GetLogger("phxecho", "./log", 3, pLogFunc);
    if (ret != 0)
    {   
        printf("get logger_google fail, ret %d\n", ret);
        return ret;
    }   

    //set logger
    oOptions.pLogFunc = pLogFunc;

    ret = Node::RunNode(oOptions, m_poPaxosNode);
    if (ret != 0)
    {   
        printf("run paxos fail, ret %d\n", ret);
        return ret;
    }   

    printf("run paxos ok\n");
    return 0;
}

All arguments and options have been included in Option variable while running PhxPaxos instance.

MakeLogStoragePath() function genereate the path where to storage paxos data and it will be set to oOptions.sLogStoragePath. oOptions.iGroupCount represents how many groups running at the same time. They are identified by GroupIdx (the range is [0, oOptions.iGroupCount) ). Different groups run in a independent space and have no connection with the others groups. Why we put them into a single instance is to make them share the IP/Port.

After configuring all IP/Port informations we will configure the state-machine we just finished.

oOptions.vecGroupSMInfoList is a array of GroupSMInfo class, it represents a list of status-machines corresponding to every specific group.

GroupSMInfo is a class which is used to describe a state-machine info for a specific group. GroupSMInfo.iGroupIdx is the identifier of this group. It will set to be 0 since we have only 1 group.

vecSMList is an array of state-machine class. It represents a list of state-machines which we want to load into PhxPaxos.

Config the Logging functions next, we used GLOG here.

At last, Execute Node::RunNode(oOptions, m_poPaxosNode) to run PhxPaxos. Return code 0 means we have active it successfully and m_poPaxosNode point to this PhxPaxos instance.

Proposing Requests

The following codes shows how to reform Echo() in EchoServer to propose a value in PhxPaxos:

int PhxEchoServer :: Echo(const std::string & sEchoReqValue, std::string & sEchoRespValue)
{
    SMCtx oCtx;
    PhxEchoSMCtx oEchoSMCtx;
    //smid must same to PhxEchoSM.SMID().
    oCtx.m_iSMID = 1;
    oCtx.m_pCtx = (void *)&oEchoSMCtx;

    uint64_t llInstanceID = 0;
    int ret = m_poPaxosNode->Propose(0, sEchoReqValue, llInstanceID, &oCtx);
    if (ret != 0)
    {   
        printf("paxos propose fail, ret %d\n", ret);
        return ret;
    }   

    if (oEchoSMCtx.iExecuteRet != 0)
    {   
        printf("echo sm excute fail, excuteret %d\n", oEchoSMCtx.iExecuteRet);
        return oEchoSMCtx.iExecuteRet;
    }   

    sEchoRespValue = oEchoSMCtx.sEchoRespValue.c_str();

    return 0;
}

First we define a context variable oEchoSMCtx and assigned to oCtx.m_pCtx.

oCtx.m_iSMID set to 1 which corresponding to SMID() above, indicate this request will be executed in the state-machine which SMID is 1.

Then call m_poPaxosNode->Propose with following arguments:

GroupIdx: it indicates which group we will propose this request. The value is 0 here. sEchoReqValue: indicates what we want to propose. llInsanceID: A return arugments we got after proposed successfully, it is global incremented. oCtx: The context variable which will be transmitted to Execute() function.

The propose will return 0 if it was proposed successfully, You can get sEchoRespValue in the context variable.

After all the steps above, we enhanced a Echo service from a single node into a cluster:)

The Running Perfomance

The output of Echo cluster is shown in the following. You can implement it by yourself or just compile sample/phxeco directory to get this program.

We have 3 nodes in this cluster. Following output came from The node which proposed the value:

run paxos ok
echo server start, ip 127.0.0.1 port 11112

please input: <echo req value>
hello phxpaxos:)
[SM Execute] ok, smid 1 instanceid 0 value hello phxpaxos:)
echo resp value hello phxpaxos:)

We listened on 127.0.0.1:11112. Add we sent "hello phxpaxos" as an input. Then Execute() funtion printed [SM Execute] ok... as the code we write above, we also got the same EchoRespValue at the context variable at the same time.

Let's see what happend in the other nodes:

run paxos ok
echo server start, ip 127.0.0.1 port 11113

please input: <echo req value>
[SM Execute] ok, smid 1 instanceid 0 value hello phxpaxos:)

This one listend on 127.0.0.1:11113, The Execute() function also printed "hello phxpaxos".

Got a election feature for your service by using Master Election in PhxPaxos.

Here we want to explain the exact meaning of Master: Master is a special role in a cluster.At any given moment, there is only one node that considers itself as master at most (remember no master exists is legal.).

This is a very pratical. Assume there is a cluster of multi machines and we wish only one machines to serve at any given moment. The common way to achive this is to build up a Zookeeper cluster and implement a distributed lock service. But now dozens of lines of code will help you to implement this feature by using our Master Election feature. You don't any extra big modules now.

Following will show you how to embed Master Election into your own service.

First we construct a election class PhxElection for existing modules.

class PhxElection
{
public:
    PhxElection(const phxpaxos::NodeInfo & oMyNode, const phxpaxos::NodeInfoList & vecNodeList);
    ~PhxElection();

    int RunPaxos();
    const phxpaxos::NodeInfo GetMaster();
    const bool IsIMMaster();

private:
    phxpaxos::NodeInfo m_oMyNode;
    phxpaxos::NodeInfoList m_vecNodeList;
    phxpaxos::Node * m_poPaxosNode;
};

It has two APIs: GetMaster to get current master of this cluster and IsIMMaster indicate whether I(the node) am master now.

Then implement RunPaxos() function:

int PhxElection :: RunPaxos()
{
    Options oOptions;

    int ret = MakeLogStoragePath(oOptions.sLogStoragePath);
    if (ret != 0)
    {   
        return ret;
    }   

    oOptions.iGroupCount = 1;

    oOptions.oMyNode = m_oMyNode;
    oOptions.vecNodeInfoList = m_vecNodeList;

    //open inside master state machine
    GroupSMInfo oSMInfo;
    oSMInfo.iGroupIdx = 0;
    oSMInfo.bIsUseMaster = true;

    oOptions.vecGroupSMInfoList.push_back(oSMInfo);

    ret = Node::RunNode(oOptions, m_poPaxosNode);
    if (ret != 0)
    {   
        printf("run paxos fail, ret %d\n", ret);
        return ret;
    }   

    //you can change master lease in real-time.
    m_poPaxosNode->SetMasterLease(0, 3000);

    printf("run paxos ok\n");
    return 0;
}

The difference between MasterElection and Echo is there is no neccessary to implement your own state-machine this time, instead, you can set oSMInfo.bIsUseMaster to true to enable our embedded MasterElection state-machine.

Then, run Node::RunNode() to get the pointer of PhxPaxos instance. You can set the lease length of Master by using SetMasterLease API at any moment.

Finally, We can get master information from this pointer like following shows:

const phxpaxos::NodeInfo PhxElection :: GetMaster()
{
    //only one group, so groupidx is 0.
    return m_poPaxosNode->GetMaster(0);
}

const bool PhxElection :: IsIMMaster()
{
    return m_poPaxosNode->IsIMMaster(0);
}

Now, every node in the cluster can get master information now by the codes above.

Welcome to have a try and give us your suggestion :)

phxpaxos's People

Contributors

boolking avatar chenneal avatar gangwang2 avatar lynncui00 avatar mapx avatar mariohuang avatar mingchengbh avatar taohexxx avatar taozhijiang avatar tencent-wechat avatar unixliang avatar wuranbo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

phxpaxos's Issues

测试phxecho时出现Could not create logging file: No such file or directory错误

您好!我在编译安装完成phxpaxos之后尝试运行提供的phxecho示例,节点会弹出COULD NOT CREATE A LOGGINGFILE 20161019-015741.4175!Could not create logging file: No such file or directory错误,请问如何解决。
还有一个问题是输入的消息存放在log文件夹的哪个位置当中?

谢谢!

PS:第一个错误我们已经自行解决了(添加了一个log目录),但是仍然找不到相关的持久化存储文件。

请问learner的实现原理是什么?

看了关于phxpaxos的介绍文章和paxos协议的原理介绍,有几点疑惑:
1.一个paxos实例中的计算机节点是怎么确定一个值已经被选定的?proposer收到了过半的acceptor的accepted消息后确定的吗?
2.一个值已经在其他节点被确定的结果是通过learner获得(广播)的吗?比如说一个proposer收到过半acceptor的accepted消息后,形成确定性取值,实例编号加一,之后其他节点发现该节点已经进入下一实例,再用leaner获取该值,是这样吗?

放到生产环境,部分节点无法加入

问题描述:安装编译phxpaxos以后,编译sample/phxecho例子,单节点下使用run_echo.sh的方式可以正常使用。但是,放入到生产环境,依然运行run_echo.sh
./phxecho 192.168.102.157:11111 192.168.102.157:11111,192.168.102.158:11112,192.168.102.159:11113 ./phxecho 192.168.102.158:11112 192.168.102.157:11111,192.168.102.158:11112,192.168.102.159:11113 ./phxecho 192.168.102.159:11113 192.168.102.157:11111,192.168.102.158:11112,192.168.102.159:11113
其中158和159可以输出内容,但是157,仅显示下
run paxos ok echo server start, ip 192.168.102.157 port 11111 please input: <echo req value> ,157节点不输出内容,说明没有连接成功,已经安装了免密码ssh.
请问如何解决问题,或者查看某一部分的日志或代码?是不是自己配置protobuf/gmock的问题

ExecuteForCheckpoint没有被执行

看到phxkv里面并没有使用镜像模式来生成snapshot,而是直接return了true,也没有使用checkpoint传输的功能。
当我自己尝试使用镜像模式生成snapshot时,将bUseCheckpointReplayer设为true,在log中可以看到Checkpoint.Replayer [START],然而看起来StateMachine中的ExecuteForCheckpoint并没有被调用,wiki中也没有找到相关文档。
请问:
如何使用镜像checkpoint功能?

您好,我在编译的时候遇到了一些问题,下面是我的步骤,请问您知道哪一步有问题吗?

正克隆到 'phxpaxos'...
remote: Counting objects: 591, done.
remote: Total 591 (delta 0), reused 0 (delta 0), pack-reused 591
接收对象中: 100% (591/591), 439.80 KiB | 105.00 KiB/s, done.
处理 delta 中: 100% (338/338), done.
检查连接... 完成。
子模组 'third_party/glog' (https://github.com/google/glog) 未对路径 'third_party/glog' 注册
子模组 'third_party/gmock' (https://github.com/google/googlemock) 未对路径 'third_party/gmock' 注册
子模组 'third_party/leveldb' (https://github.com/google/leveldb) 未对路径 'third_party/leveldb' 注册
子模组 'third_party/protobuf' (https://github.com/google/protobuf) 未对路径 'third_party/protobuf' 注册
正克隆到 'third_party/glog'...
remote: Counting objects: 1420, done.
remote: Total 1420 (delta 0), reused 0 (delta 0), pack-reused 1420
接收对象中: 100% (1420/1420), 1.39 MiB | 221.00 KiB/s, done.
处理 delta 中: 100% (1013/1013), done.
检查连接... 完成。
子模组路径 'third_party/glog':检出 'de6149ef8e67b064a433a8b88924fa9f606ad5d5'
检查连接... 完成。
子模组路径 'third_party/protobuf':检出 'd4d13a4349e4e59d67f311185ddcc1890d956d7a'
  • 2
    然后继续./autoinstall.sh
    这步每执行一次就提示一个目录不存在,
```/phxpaxos/third_party/protobuf/include/ not found
please make sure PROTOBUF has been placed on third party directory
还有protobuf/lib
glob/lib等大概四五个目录不存在

我手动创建了这些目录
再执行./autoinstall.sh就可以了

  • 3
    make,报错找不到paxos_msg.pb.h

我就去了phxpaxos/src/comm目录下面执行了下面这句话
protoc --cpp_out=./ paxos_msg.proto
生成了一些文件,包括paxos_msg.pb.h

  • 4
    再去根目录下make出现以下报错信息
phxpaxos/src/comm/./paxos_msg.pb.h:9:42: fatal error: google/protobuf/stubs/common.h: 没有那个文件或目录
 #include <google/protobuf/stubs/common.h>

请问哪一步的哪个命令有问题呢? 请您指导一下,谢谢。

请问proposer提交一个新值时可以忽略prepare流程直接accept的原因

在函数Proposer :: NewValue中,当满足m_bCanSkipPrepare && !m_bWasRejectBySomeone这两个条件的情况下,可以直接跳过prepare阶段直接到accept,从代码中看到,m_bCanSkipPrepare只要在这一轮prepare有半数通过就会置为true,m_bWasRejectBySomeone就更简单明了,就是这一轮提交中没有被其他参与者拒绝过。

我想问下,这个优化的理论依据是什么?有什么资料可以给来看看吗?

encounter problem when compile project

I make sure that protobuf is under the third_part directory. the error message is following:

/home/ariesdevil/phxpaxos/third_party/protobuf/include/ not found
please make sure PROTOBUF has been placed on third party directory

libphxpaxos.a编译失败,但在phxpaxos/.lib/目录下已生成libphxpaxos.a(修改makefile已解决)

所有依赖protobuf和leveldb均已经编译并安装OK,版本如下:
commit 1b964f7
Author: lynncui00 [email protected]
Date: Fri Jan 6 17:15:08 2017 +0800

编译错误如下所示,其中依赖的头文件均存在
g++ -std=c++11 -O2 -I/zwork/git/phxpaxos -I/zwork/git/phxpaxos/third_party/protobuf/include/ -I/zwork/git/phxpaxos/third_party/leveldb/include/ -I/zwork/git/phxpaxos/third_party/glog/src/ -Wall -fPIC -m64 -Wno-unused-local-typedefs -I/zwork/git/phxpaxos/src/utils -Wall -Werror -I/zwork/git/phxpaxos/src/utils -Wall -Werror -c -o wait_lock.o wait_lock.cpp
In file included from /zwork/git/phxpaxos/src/logstorage/db.h:29:0,
from /zwork/git/phxpaxos/src/node/pnode.h:27,
from /zwork/git/phxpaxos/src/node/pnode.cpp:22:
/zwork/git/phxpaxos/src/comm/comm_include.h:24:28: fatal error: ./paxos_msg.pb.h: No such file or directory
#include "./paxos_msg.pb.h"
^
compilation terminated.
In file included from /zwork/git/phxpaxos/src/logstorage/db.h:29:0,
from /zwork/git/phxpaxos/src/node/pnode.h:27,
from /zwork/git/phxpaxos/src/node/node.cpp:23:
/zwork/git/phxpaxos/src/comm/comm_include.h:24:28: fatal error: ./paxos_msg.pb.h: No such file or directory
#include "./paxos_msg.pb.h"
^
compilation terminated.
ori_make: *** [/zwork/git/phxpaxos/src/node/node.o] Error 1
ori_make: *** Waiting for unfinished jobs....
ori_make: *** [/zwork/git/phxpaxos/src/node/pnode.o] Error 1
In file included from /zwork/git/phxpaxos/src/communicate/tcp/message_event.h:28:0,
from /zwork/git/phxpaxos/src/communicate/tcp/tcp_acceptor.h:26,
from /zwork/git/phxpaxos/src/communicate/tcp/tcp.h:25,
from /zwork/git/phxpaxos/src/communicate/dfnetwork.h:26,
from /zwork/git/phxpaxos/src/communicate/udp.cpp:31:
/zwork/git/phxpaxos/src/comm/comm_include.h:24:28: fatal error: ./paxos_msg.pb.h: No such file or directory
#include "./paxos_msg.pb.h"
^
In file included from /zwork/git/phxpaxos/src/communicate/tcp/message_event.h:28:0,
from /zwork/git/phxpaxos/src/communicate/tcp/tcp_acceptor.h:26,
from /zwork/git/phxpaxos/src/communicate/tcp/tcp.h:25,
from /zwork/git/phxpaxos/src/communicate/dfnetwork.h:26,
from /zwork/git/phxpaxos/src/communicate/dfnetwork.cpp:22:
/zwork/git/phxpaxos/src/comm/comm_include.h:24:28: fatal error: ./paxos_msg.pb.h: No such file or directory
#include "./paxos_msg.pb.h"

感觉makefile的依赖不对,尤其对于$(SRC_BASE_PATH)/.lib/libphxpaxos.a $(SRC_BASE_PATH)/.lib/extlib/libphxpaxos.a这两个库有什么区别不明白。其中 $(SRC_BASE_PATH)/.lib/libphxpaxos.a的依赖$(PHXPAXOS_SRC)为空,我的makefile通过./autoinstall.sh生成,生成的makefile如下:
_lib_phxpaxos: phxpaxos_dir $(SRC_BASE_PATH)/.lib/libphxpaxos.a $(SRC_BASE_PATH)/.lib/extlib/libphxpaxos.a

phxpaxos_dir:$(PHXPAXOS_FULL_LIB_PATH)
@for dir in $^;
do
current_dir=readlink $$dir -m;
pwd_dir=pwd;
pwd_dir=readlink $$pwd_dir -m;
if ([ "$$current_dir" != "$$pwd_dir" ]); then
make -C $$dir;
fi;
done

$(SRC_BASE_PATH)/.lib/libphxpaxos.a: $(PHXPAXOS_SRC)
ar -cvq $@ $(PHXPAXOS_SRC)

PHXPAXOS_LIB_OBJ=$(patsubst %, $(SRC_BASE_PATH)/%, src/node/group.o src/node/pnode.o src/node/node.o src/node/propose_batch.o src/communicate/dfnetwork.o src/communicate/udp.o src/communicate/network.o src/communicate/communicate.o src/communicate/tcp/event_base.o src/communicate/tcp/message_event.o src/communicate/tcp/event_loop.o src/communicate/tcp/tcp_client.o src/communicate/tcp/tcp_acceptor.o src/communicate/tcp/notify.o src/communicate/tcp/tcp.o src/algorithm/base.o src/algorithm/proposer.o src/algorithm/acceptor.o src/algorithm/learner.o src/algorithm/learner_sender.o src/algorithm/instance.o src/algorithm/ioloop.o src/algorithm/commitctx.o src/algorithm/committer.o src/algorithm/checkpoint_sender.o src/algorithm/checkpoint_receiver.o src/algorithm/msg_counter.o src/checkpoint/cp_mgr.o src/checkpoint/replayer.o src/checkpoint/cleaner.o src/master/master_sm.pb.o src/master/master_sm.o src/master/master_mgr.o src/master/master_variables_store.o src/config/config.o src/config/system_v_sm.o src/sm-base/sm_base.o src/sm-base/sm.o src/logstorage/db.o src/logstorage/paxos_log.o src/logstorage/log_store.o src/logstorage/system_variables_store.o src/comm/paxos_msg.pb.o src/comm/breakpoint.o src/comm/options.o src/comm/inside_options.o src/comm/logger.o src/utils/concurrent.o src/utils/socket.o src/utils/util.o src/utils/crc32.o src/utils/timer.o src/utils/bytes_buffer.o src/utils/serial_lock.o src/utils/wait_lock.o src/utils/notifier_pool.o)
$(SRC_BASE_PATH)/.lib/extlib/libphxpaxos.a: $(PHXPAXOS_LIB_OBJ)
ar -cvq $@ $(PHXPAXOS_LIB_OBJ)_

选举功能编译问题

你好,想请教个问题,如果想使用选举功能,编译时候应该指定哪些参数?谢谢。
比如像下面这样编译自带phxelection例子,就报错。
g++ -std=c++11 election.cpp election_main.cpp -I../include -L../lib/libphxpaxos.a

/tmp/ccvQw9HF.o:在函数‘phxelection::PhxElection::MakeLogStoragePath(std::string&)’中:
election.cpp:(.text+0x112):对‘phxpaxos::NodeInfo::GetPort() const’未定义的引用
election.cpp:(.text+0x123):对‘phxpaxos::NodeInfo::GetIP() const’未定义的引用
/tmp/ccvQw9HF.o:在函数‘phxelection::PhxElection::RunPaxos()’中:
election.cpp:(.text+0x2a4):对‘phxpaxos::Options::Options()’未定义的引用
election.cpp:(.text+0x332):对‘phxpaxos::GroupSMInfo::GroupSMInfo()’未定义的引用
election.cpp:(.text+0x37d):对‘phxpaxos::Node::RunNode(phxpaxos::Options const&, phxpaxos::Node_&)’未定义的引用
/tmp/cc2h5vra.o:在函数‘parse_ipport(char const_, phxpaxos::NodeInfo&)’中:
election_main.cpp:(.text+0xac):对‘phxpaxos::NodeInfo::SetIPPort(std::string const&, int)’未定义的引用
/tmp/cc2h5vra.o:在函数‘parse_ipport_list(char const*, std::vector<phxpaxos::NodeInfo, std::allocatorphxpaxos::NodeInfo >&)’中:
election_main.cpp:(.text+0x1ba):对‘phxpaxos::NodeInfo::NodeInfo()’未定义的引用
/tmp/cc2h5vra.o:在函数‘main’中:
election_main.cpp:(.text+0x2fb):对‘phxpaxos::NodeInfo::NodeInfo()’未定义的引用
election_main.cpp:(.text+0x3f8):对‘phxpaxos::NodeInfo::GetPort() const’未定义的引用
election_main.cpp:(.text+0x407):对‘phxpaxos::NodeInfo::GetIP() const’未定义的引用
election_main.cpp:(.text+0x41e):对‘phxpaxos::NodeInfo::GetNodeID() const’未定义的引用
collect2: error: ld returned 1 exit status

PhxPaxos是否强制了Master/Follower机制

我在阅读代码时候发现,如果当前Group对应的Instance为Follower,则会skip对应proposed的value,详细见代码:

``void Instance :: CheckNewValue()
{
if (m_poConfig->IsIMFollower())
{
PLGErr("I'm follower, skip this new value");
m_oCommitCtx.SetResultOnlyRet(PaxosTryCommitRet_Follower_Cannot_Commit);
return ;
}
}`

我的疑问是PhPaxos是否可以取消这个限制,或者改为配置,比如我们的应用是希望支持多点写入的,只是说,我们的client会去基于一个简单的机制去选择一个非严格意义上的master(优先写入节点,减少冲突),但是其它的节点也是可以写入的(在出现membership change的时候)。

请教一下checkpoint的minchoseninstanceid的本意是什么?

代码里面看,会延迟100个instance版本来设置 minchoseninstaneid.
但是这样导致启动的时候从存储的minchoseinstanceid里面重建checkpointmgr的时候无法找到对应的数据而导致失败。本意应该是 向前100个版本来存储minchoseninstanceid?

重启时状态机恢复问题

如果一个节点在重启时,Instance初始化时,相关代码
uint64_t llCPInstanceID = m_oCheckpointMgr.GetCheckpointInstanceID() + 1;

uint64_t llNowInstanceID = llCPInstanceID;
if (llNowInstanceID < m_oAcceptor.GetInstanceID())
{
    ret = PlayLog(llNowInstanceID, m_oAcceptor.GetInstanceID());  
    if (ret != 0)
    {
        return ret;
    }

    PLGImp("PlayLog OK, begin instanceid %lu end instanceid %lu", llNowInstanceID, m_oAcceptor.GetInstanceID());

    llNowInstanceID = m_oAcceptor.GetInstanceID();
}
else
{
    if (llNowInstanceID > m_oAcceptor.GetInstanceID())
    {
        ret = ProtectionLogic_IsCheckpointInstanceIDCorrect(llNowInstanceID, m_oAcceptor.GetInstanceID());
        if (ret != 0)
        {
            return ret;
        }
        m_oAcceptor.InitForNewPaxosInstance();
    }
    
    m_oAcceptor.SetInstanceID(llNowInstanceID);
}

在if分支中会将llNowInstanceID到m_oAcceptor.GetInstanceID()的日志对状态机进行重放,从而恢复状态机。我的理解是,这里恢复应该是首先加载llNowInstanceID-1,即此CheckpointInstanceID时落盘的数据,然后重放llNowInstanceID到m_oAcceptor.GetInstanceID()的日志才能恢复所有的数据。

集群的同步的问题

现象为:3台机器有两台选是好的,另外一台一直没有能加入到集群,没加入到集群的机器用GetMaster接口有时候获得的地址是自己的ip和port,IsIMMaster返回的是true,从日志看op version一直比 master version大。最后大概10个小时后集群同步了,我们业务里面集群没有同步好的时候会调用propose数据,不知道是否有影响。
phxpaxos版本为master 2个月前版本。

master上一直有错误日志:
2016-11-10 03:27:04.11s ERR(0): PN8phxpaxos18MasterStateMachineE::LearnMaster version conflit, op version 252514 now master version 252543
2016-11-10 03:27:04.11s ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14
2016-11-10 03:27:09.11s ERR(0): PN8phxpaxos18MasterStateMachineE::LearnMaster version conflit, op version 252544 now master version 252566
2016-11-10 03:27:09.11s ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14
2016-11-10 03:27:11.11s ERR(0): PN8phxpaxos18MasterStateMachineE::LearnMaster version conflit, op version 252570 now master version 252577
2016-11-10 03:27:11.11s ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14
2016-11-10 03:27:12.11s ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14
2016-11-10 03:27:12.11s ERR(0): PN8phxpaxos8ProposerE::OnPrepareReply Not preparing, skip this msg
加入到集群的slave也一直有错误日志:
2016-11-10 11:27:33.11s ERR(0): PN8phxpaxos18MasterStateMachineE::LearnMaster version conflit, op version 252689 now master version 252687
2016-11-10 11:27:35.11s ERR(0): PN8phxpaxos18MasterStateMachineE::LearnMaster version conflit, op version 252693 now master version 252702
没能加入到集群的错误日志:
2016-11-10 11:30:43.11s ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14
2016-11-10 11:30:44.11s ERR(0): PN8phxpaxos18MasterStateMachineE::LearnMaster version conflit, op version 253605 now master version 253606
2016-11-10 11:30:45.11s ERR(0): PN8phxpaxos18MasterStateMachineE::LearnMaster version conflit, op version 253608 now master version 253606
2016-11-10 11:30:45.11s ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14
2016-11-10 11:30:45.11s ERR(0): PN8phxpaxos18MasterStateMachineE::LearnMaster version conflit, op version 253614 now master version 253606
2016-11-10 11:30:45.11s ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14

关于 定时器 和 消息队列 的 映射问题

@lynncui00
最近阅读源码读到了 定时器 和 消息队列 两个结构。

其中定时器存在 Timer 实例的 m_vecTimerHeap 结构中,这是一个小顶堆的 vector 。
消息队列放在 IOLoop 实例的 m_oMessageQueue 结构中,是一个 string 的 Queue 。

每次 IOLoop() 的时候先处理已经超时的事件,这个我明白;但是在处理完超时时间后,每次 OneLoop() 都会弹出一个 m_vecTimerHeap 中最小的超时定时器,然而对应的 message 居然是 oMessageQueue 队首的那个消息节点,然而两者并不存在对应关系

假设一个场景,我设定一个恒定增长的物理时间轴,在物理时间 100s 的时候我做了动作 A 并设定 timeout 为 300s,在物理时间 200s 的时候我做了动作 B 并设定超时为 100s 。某个时候假设两者在都收到了 reply 消息加入了 oMessageQueue 队列, 只是 A 的 reply 先到,loop 的时候两者也都没有超时,我先拿出的是 B 动作的超时时间(因为 m_llAbsTime 更小),但是处理的却是 A 的消息。

详情见 IOLoop.cpp 的 void IOLoop :: OneLoop(const int iTimeoutMs) 函数。

我认为定时器向量 vecTimerHeap 和消息队列 m_oMessageQueue 应该维护一个映射关系。 否则 timeout 的大小会影响消息事件的处理。

请问 每个paxos group 目录下的 vfile这个目录是用来做什么的?

如:
root@localhost vfile]# pwd
/root/phx-test/logpath_172.17.111.54_9527/g0/vfile
[root@localhost vfile]# ll
total 12
-rw-------. 1 root root 104857600 Mar 1 02:25 0.f
-rw-------. 1 root root 158 Feb 28 22:05 LOG
-rw-------. 1 root root 0 Feb 28 02:18 meta
[root@localhost vfile]#

这些文件的作用是什么

能否再给出一些实现原理介绍文档,这个项目感觉原理介绍的文档比较少,除了工程实现那篇文章

protobuf 没有include目录

./autoinstall.sh 提示protobuf下没有include目录。

protobuf的代码是在phxpaxos根目录下用git submodule update --init --recursive获取的。下载的代码确实没有include目录。以前也没用过protobuf,是否新版本移除了include目录?

sample编译错误,对‘vtable for phxpaxos::StateMachine’未定义的引用

cd phxpaxos/sample/phxecho;
make

g++ -std=c++11 -I/data/tmp/phxpaxos -I/data/tmp/phxpaxos/third_party/protobuf/include/ -I/data/tmp/phxpaxos/third_party/leveldb/include/ -I/data/tmp/phxpaxos/third_party/glog/src/ -Wall -g -fPIC -m64 -Wno-unused-local-typedefs -I/data/tmp/phxpaxos/include -I/data/tmp/phxpaxos/plugin/include -I/data/tmp/phxpaxos/sample/phxecho -I/data/tmp/phxpaxos/third_party/leveldb/include/ -I/data/tmp/phxpaxos/third_party/protobuf/include/ -Wall -Werror -c -o echo_sm.o echo_sm.cpp g++ -std=c++11 -I/data/tmp/phxpaxos -I/data/tmp/phxpaxos/third_party/protobuf/include/ -I/data/tmp/phxpaxos/third_party/leveldb/include/ -I/data/tmp/phxpaxos/third_party/glog/src/ -Wall -g -fPIC -m64 -Wno-unused-local-typedefs -I/data/tmp/phxpaxos/include -I/data/tmp/phxpaxos/plugin/include -I/data/tmp/phxpaxos/sample/phxecho -I/data/tmp/phxpaxos/third_party/leveldb/include/ -I/data/tmp/phxpaxos/third_party/protobuf/include/ -Wall -Werror -c -o echo_server.o echo_server.cpp g++ -std=c++11 -I/data/tmp/phxpaxos -I/data/tmp/phxpaxos/third_party/protobuf/include/ -I/data/tmp/phxpaxos/third_party/leveldb/include/ -I/data/tmp/phxpaxos/third_party/glog/src/ -Wall -g -fPIC -m64 -Wno-unused-local-typedefs -I/data/tmp/phxpaxos/include -I/data/tmp/phxpaxos/plugin/include -I/data/tmp/phxpaxos/sample/phxecho -I/data/tmp/phxpaxos/third_party/leveldb/include/ -I/data/tmp/phxpaxos/third_party/protobuf/include/ -Wall -Werror -c -o main.o main.cpp g++ echo_sm.o echo_server.o main.o -o phxecho -L/data/tmp/phxpaxos/.lib -L/data/tmp/phxpaxos/third_party/protobuf/lib -L/data/tmp/phxpaxos/third_party/leveldb/lib/ -L/data/tmp/phxpaxos/third_party/glog/lib -L/data/tmp/phxpaxos/third_party/grpc/lib -L/data/tmp/phxpaxos/third_party/openssl/lib -g /data/tmp/phxpaxos/lib/libphxpaxos_plugin.a /data/tmp/phxpaxos/lib/libphxpaxos.a /data/tmp/phxpaxos/third_party/leveldb/lib//libleveldb.a /data/tmp/phxpaxos/third_party/protobuf/lib/libprotobuf.a /data/tmp/phxpaxos/third_party/glog/lib/libglog.a /data/tmp/phxpaxos/third_party/glog/lib/libglog.a -lpthread echo_sm.o:在函数‘phxpaxos::StateMachine::~StateMachine()’中: /data/tmp/phxpaxos/include/phxpaxos/sm.h:61:对‘vtable for phxpaxos::StateMachine’未定义的引用 echo_sm.o:在函数‘phxpaxos::StateMachine::StateMachine()’中: /data/tmp/phxpaxos/include/phxpaxos/sm.h:58:对‘vtable for phxpaxos::StateMachine’未定义的引用 echo_sm.o:(.data.rel.ro._ZTVN7phxecho9PhxEchoSME[_ZTVN7phxecho9PhxEchoSME]+0x30):对‘phxpaxos::StateMachine::ExecuteForCheckpoint(int, unsigned long, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)’未定义的引用 echo_sm.o:(.data.rel.ro._ZTVN7phxecho9PhxEchoSME[_ZTVN7phxecho9PhxEchoSME]+0x38):对‘phxpaxos::StateMachine::GetCheckpointInstanceID(int) const’未定义的引用 echo_sm.o:(.data.rel.ro._ZTVN7phxecho9PhxEchoSME[_ZTVN7phxecho9PhxEchoSME]+0x40):对‘phxpaxos::StateMachine::LockCheckpointState()’未定义的引用 echo_sm.o:(.data.rel.ro._ZTVN7phxecho9PhxEchoSME[_ZTVN7phxecho9PhxEchoSME]+0x48):对‘phxpaxos::StateMachine::GetCheckpointState(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)’未定义的引用 echo_sm.o:(.data.rel.ro._ZTVN7phxecho9PhxEchoSME[_ZTVN7phxecho9PhxEchoSME]+0x50):对‘phxpaxos::StateMachine::UnLockCheckpointState()’未定义的引用 echo_sm.o:(.data.rel.ro._ZTVN7phxecho9PhxEchoSME[_ZTVN7phxecho9PhxEchoSME]+0x58):对‘phxpaxos::StateMachine::LoadCheckpointState(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, unsigned long)’未定义的引用 echo_sm.o:(.data.rel.ro._ZTIN7phxecho9PhxEchoSME[_ZTIN7phxecho9PhxEchoSME]+0x10):对‘typeinfo for phxpaxos::StateMachine’未定义的引用 echo_server.o:在函数‘phxecho::PhxEchoServer::MakeLogStoragePath(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)’中: /data/tmp/phxpaxos/sample/phxecho/echo_server.cpp:49:对‘phxpaxos::NodeInfo::GetPort() const’未定义的引用 /data/tmp/phxpaxos/sample/phxecho/echo_server.cpp:49:对‘phxpaxos::NodeInfo::GetIP[abi:cxx11]() const’未定义的引用 echo_server.o:在函数‘phxecho::PhxEchoServer::RunPaxos()’中: /data/tmp/phxpaxos/sample/phxecho/echo_server.cpp:67:对‘phxpaxos::Options::Options()’未定义的引用 /data/tmp/phxpaxos/sample/phxecho/echo_server.cpp:82:对‘phxpaxos::GroupSMInfo::GroupSMInfo()’未定义的引用 /data/tmp/phxpaxos/sample/phxecho/echo_server.cpp:90:对‘phxpaxos::LoggerGoogle::GetLogger(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int, void (*&)(int, char const*, __va_list_tag*))’未定义的引用 /data/tmp/phxpaxos/sample/phxecho/echo_server.cpp:100:对‘phxpaxos::Node::RunNode(phxpaxos::Options const&, phxpaxos::Node*&)’未定义的引用 echo_server.o:在函数‘phxecho::PhxEchoServer::Echo(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)’中: /data/tmp/phxpaxos/sample/phxecho/echo_server.cpp:113:对‘phxpaxos::SMCtx::SMCtx()’未定义的引用 main.o:在函数‘parse_ipport(char const*, phxpaxos::NodeInfo&)’中: /data/tmp/phxpaxos/sample/phxecho/main.cpp:45:对‘phxpaxos::NodeInfo::SetIPPort(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)’未定义的引用 main.o:在函数‘parse_ipport_list(char const*, std::vector<phxpaxos::NodeInfo, std::allocator<phxpaxos::NodeInfo> >&)’中: /data/tmp/phxpaxos/sample/phxecho/main.cpp:64:对‘phxpaxos::NodeInfo::NodeInfo()’未定义的引用 main.o:在函数‘main’中: /data/tmp/phxpaxos/sample/phxecho/main.cpp:92:对‘phxpaxos::NodeInfo::NodeInfo()’未定义的引用 /data/tmp/phxpaxos/sample/phxecho/main.cpp:113:对‘phxpaxos::NodeInfo::GetPort() const’未定义的引用 /data/tmp/phxpaxos/sample/phxecho/main.cpp:113:对‘phxpaxos::NodeInfo::GetIP[abi:cxx11]() const’未定义的引用 collect2: error: ld returned 1 exit status Makefile:36: recipe for target 'phxecho' failed make: *** [phxecho] Error 1

DropMaster的问题

master调用DropMaster后返回0,但仍然是master,master上没错误日志,在另外一台机器上有错误日志,
2016-11-10 15:49:55.11s ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14
2016-11-10 15:49:56.11s ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14
2016-11-10 15:50:30.11s ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14
2016-11-10 15:50:31.11s ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14
2016-11-10 15:50:32.11s ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14

fork之后不能clone到本地

总是会在“openssl”那里出现remote: fatal: early EOF + index-pack failed的错误,请问是什么情况?谢谢!

Urgent...

This is really the wrong place - but all other means of trying to reach support have not been answered back.

Trying to sign up for a developer account to make a bot, but the image verification on the setup profile is busted. I either get no response message or a verification failure - which I think is related to your server handling of "time/Date".

Please help! This is for client work!

screenshot from 2016-07-05 13-24-24

可以在 readme 里补充下 wiki 链接

坦率地说,没有第一时间意识到应该看 wiki,读了一遍 readme,就准备 quick start 了,照着来就不行了。

wiki 的文档很详细,建议 readme 加个链接提醒大家看下。

Multi-Paxos提交的问题

Cui,你好

看到你们在知乎专栏的教程,十分感谢。在此我想问一个问题:

我想问下,对于执行失败的command会留下gap,这些gap会用no-op操作进行填充,那么原先这些失败的命令怎么办?客户端请求返回错误然后让客户端重试么?
另外,我看好像Multi-Paxos对提交的顺序是没有保证的,Multi-Paxos对预取的r个命令可以任意的顺序Chosen Value,而且Leader失败后新的Leader对未决的命令也是任意顺序执行的,就是其假定r个命令之间Chosen Value是没有因果或者依赖关系的,是不是这样?如果这样会不会对某些业务有影响?还是强制序列化操作?

Learner运行的时候直接exit了。我看了一下代码,请教一下exit了下一步怎么办呢?重启么?

int Learner :: OnSendCheckpoint_End(const CheckpointMsg & oCheckpointMsg)
{
//.......
BP->GetCheckpointBP()->ReceiveCheckpointAndLoadSucc();
PLGImp("All sm load state ok, start to exit process");
exit(-1);
return 0;
}

这个地方直接exit 进程了。成功之后难道不是应该恢复sm么?为什么直接退出进程而非线程。
我发现重启可以恢复,但是为什么一定要重启呢?是不是有更优雅的办法?

这么多错误,确定能编译过?

g++ -std=c++11 -I/root/lvpy/lib/tencent/phxpaxos -I/usr/local/include/google/protobuf -I/usr/include/leveldb -I/usr/local/include/glog -Wall -g -fPIC -m64 -Wno-unused-local-typedefs -I/root/lvpy/lib/tencent/phxpaxos/include -I/root/lvpy/lib/tencent/phxpaxos/src/comm -I/root/lvpy/lib/tencent/phxpaxos/src/config -I/root/lvpy/lib/tencent/phxpaxos/src/logstorage -I/root/lvpy/lib/tencent/phxpaxos/src/master -I/root/lvpy/lib/tencent/phxpaxos/src/sm-base -I/root/lvpy/lib/tencent/phxpaxos/src/utils -I/usr/include/leveldb -I/usr/local/include/google/protobuf -Wall -Werror -c -o master_variables_store.o master_variables_store.cpp
master_variables_store.cpp: In member function 'int phxpaxos::MasterVariablesStore::Write(const phxpaxos::WriteOptions&, int, const phxpaxos::MasterVariables&)':
master_variables_store.cpp:40:5: error: 'string' was not declared in this scope
string sBuffer;
^
master_variables_store.cpp:40:5: note: suggested alternatives:
In file included from /usr/include/c++/4.8.2/string:39:0,
from master_variables_store.h:24,
from master_variables_store.cpp:22:
/usr/include/c++/4.8.2/bits/stringfwd.h:62:33: note: 'std::string'
typedef basic_string string;
^
/usr/include/c++/4.8.2/bits/stringfwd.h:62:33: note: 'std::string'
master_variables_store.cpp:40:12: error: expected ';' before 'sBuffer'
string sBuffer;
^
master_variables_store.cpp:41:48: error: 'sBuffer' was not declared in this scope
bool sSucc = oVariables.SerializeToString(&sBuffer);
^
master_variables_store.cpp:44:43: error: 'PLG1Err' was not declared in this scope
PLG1Err("Variables.Serialize fail");
^
master_variables_store.cpp:52:47: error: 'PLG1Err' was not declared in this scope
iGroupIdx, sBuffer.size(), ret);
^
master_variables_store.cpp:38:15: error: unused variable 'm_iMyGroupIdx' [-Werror=unused-variable]
const int m_iMyGroupIdx = iGroupIdx;
^
master_variables_store.cpp: In member function 'int phxpaxos::MasterVariablesStore::Read(int, phxpaxos::MasterVariables&)':
master_variables_store.cpp:63:5: error: 'string' was not declared in this scope
string sBuffer;
^
master_variables_store.cpp:63:5: note: suggested alternatives:
In file included from /usr/include/c++/4.8.2/string:39:0,
from master_variables_store.h:24,
from master_variables_store.cpp:22:
/usr/include/c++/4.8.2/bits/stringfwd.h:62:33: note: 'std::string'
typedef basic_string string;
^
/usr/include/c++/4.8.2/bits/stringfwd.h:62:33: note: 'std::string'
master_variables_store.cpp:63:12: error: expected ';' before 'sBuffer'
string sBuffer;
^
master_variables_store.cpp:64:61: error: 'sBuffer' was not declared in this scope
int ret = m_poLogStorage->GetMasterVariables(iGroupIdx, sBuffer);
^
master_variables_store.cpp:67:66: error: 'PLG1Err' was not declared in this scope
PLG1Err("DB.Get fail, groupidx %d ret %d", iGroupIdx, ret);
^
master_variables_store.cpp:72:59: error: 'PLG1Imp' was not declared in this scope
PLG1Imp("DB.Get not found, groupidx %d", iGroupIdx);
^
master_variables_store.cpp:79:79: error: 'PLG1Err' was not declared in this scope
PLG1Err("Variables.ParseFromArray fail, bufferlen %zu", sBuffer.size());
^
master_variables_store.cpp:61:15: error: unused variable 'm_iMyGroupIdx' [-Werror=unused-variable]
const int m_iMyGroupIdx = iGroupIdx;
^
cc1plus: all warnings being treated as errors
make[1]: *** [master_variables_store.o] Error 1
make[1]: Leaving directory /root/lvpy/lib/tencent/phxpaxos/src/master' make[1]: Entering directory/root/lvpy/lib/tencent/phxpaxos/src/node'
g++ -std=c++11 -I/root/lvpy/lib/tencent/phxpaxos -I/usr/local/include/google/protobuf -I/usr/include/leveldb -I/usr/local/include/glog -Wall -g -fPIC -m64 -Wno-unused-local-typedefs -I/root/lvpy/lib/tencent/phxpaxos/include -I/root/lvpy/lib/tencent/phxpaxos/src/algorithm -I/root/lvpy/lib/tencent/phxpaxos/src/checkpoint -I/root/lvpy/lib/tencent/phxpaxos/src/comm -I/root/lvpy/lib/tencent/phxpaxos/src/communicate -I/root/lvpy/lib/tencent/phxpaxos/src/communicate/tcp -I/root/lvpy/lib/tencent/phxpaxos/src/config -I/root/lvpy/lib/tencent/phxpaxos/src/logstorage -I/root/lvpy/lib/tencent/phxpaxos/src/master -I/root/lvpy/lib/tencent/phxpaxos/src/node -I/root/lvpy/lib/tencent/phxpaxos/src/sm-base -I/root/lvpy/lib/tencent/phxpaxos/src/utils -I/usr/include/leveldb -I/usr/local/include/google/protobuf -Wall -Werror -c -o pnode.o pnode.cpp
In file included from pnode.cpp:22:0:
pnode.h:127:5: error: 'MultiDatabase' does not name a type
MultiDatabase m_oDefaultLogStorage;
^
pnode.cpp: In member function 'int phxpaxos::PNode::InitLogStorage(const phxpaxos::Options&, phxpaxos::LogStorage_&)':
pnode.cpp:71:15: error: 'm_oDefaultLogStorage' was not declared in this scope
int ret = m_oDefaultLogStorage.Init(oOptions.sLogStoragePath, oOptions.iGroupCount);
^
make[1]: ** [pnode.o] Error 1
make[1]: Leaving directory `/root/lvpy/lib/tencent/phxpaxos/src/node'
g++ -std=c++11 -I/root/lvpy/lib/tencent/phxpaxos -I/usr/local/include/google/protobuf -I/usr/include/leveldb -I/usr/local/include/glog -Wall -g -fPIC -m64 -Wno-unused-local-typedefs -I/root/lvpy/lib/tencent/phxpaxos/ -I/root/lvpy/lib/tencent/phxpaxos/include -I/root/lvpy/lib/tencent/phxpaxos/src/algorithm -I/root/lvpy/lib/tencent/phxpaxos/src/checkpoint -I/root/lvpy/lib/tencent/phxpaxos/src/comm -I/root/lvpy/lib/tencent/phxpaxos/src/communicate -I/root/lvpy/lib/tencent/phxpaxos/src/communicate/tcp -I/root/lvpy/lib/tencent/phxpaxos/src/config -I/root/lvpy/lib/tencent/phxpaxos/src/logstorage -I/root/lvpy/lib/tencent/phxpaxos/src/master -I/root/lvpy/lib/tencent/phxpaxos/src/node -I/root/lvpy/lib/tencent/phxpaxos/src/sm-base -I/root/lvpy/lib/tencent/phxpaxos/src/utils -I/usr/include/leveldb -I/usr/local/include/google/protobuf -Wall -Werror -c -o /root/lvpy/lib/tencent/phxpaxos/src/node/pnode.o /root/lvpy/lib/tencent/phxpaxos/src/node/pnode.cpp
In file included from /root/lvpy/lib/tencent/phxpaxos/src/node/pnode.cpp:22:0:
/root/lvpy/lib/tencent/phxpaxos/src/node/pnode.h:127:5: error: 'MultiDatabase' does not name a type
MultiDatabase m_oDefaultLogStorage;
^
/root/lvpy/lib/tencent/phxpaxos/src/node/pnode.cpp: In member function 'int phxpaxos::PNode::InitLogStorage(const phxpaxos::Options&, phxpaxos::LogStorage
&)':
/root/lvpy/lib/tencent/phxpaxos/src/node/pnode.cpp:71:15: error: 'm_oDefaultLogStorage' was not declared in this scope
int ret = m_oDefaultLogStorage.Init(oOptions.sLogStoragePath, oOptions.iGroupCount);
^
make: *_* [/root/lvpy/lib/tencent/phxpaxos/src/node/pnode.o] Error 1

checkpoint id 和 instanceid 不一致导致的问题

一台机器上的checkpoint id比 instanceid更大(目前原因不是很清楚,使用paxos_tools获得的这台机器的最大instanceid 为6986455,理论上应该也会存在这种情况,因为checkpoint id和instanceid是独立写入的)

016-11-24 17:06:43.11s CheckpointInstanceID 7030709
2016-11-24 17:06:43.11s ^[[41;37m ERR(0): PN8phxpaxos8DatabaseE::GetMinChosenInstanceID no min chosen instanceid ^[[0m
2016-11-24 17:06:43.11s ^[[41;37m ERR(0): PN8phxpaxos8InstanceE::InitLastCheckSum las checksum not exist, now instanceid 7030710 ^[[0m

另外的一台机器加入集群,但是他的instanceid < 7030710,所以会请求同步数据,但是实际上6986455到7030709是没有数据的,这样会导致同步失败,主master会有日志
RR(0): PN8phxpaxos13LearnerSenderE::SendLearnedValue SendOne fail, SendInstanceID 6986456 SendToNodeID 9402119685132001185 ret 1)
这台机器一直加入不了集群,而且这时候 GetMaster的返回的值是不确定的,有时候是正确的master ip和port,有时候是0.0.0.0和 0

请问下,此项目是否支持A/B网冗余,另外改造的难度有多大

传统行业有些需要两个独立的A/B网络来增加通信的可靠性,A网络断开B网路可以继续通信,请问贵项目是否支持A/B网冗余? 例如A网路断开B网路可用时,并不进行选主策略,只有主机双网都断开时才进行选主。
另外若不支持A/B网冗余,那么能否改造,改造的难度有多大,相比起zookeeper改造呢?

征集文档以及使用经验

题主精力有限,在不断回答各位的问题当中感觉文档还是有不少需要补充,与此同时,各位在使用的过程或阅读代码的过程中必然会得到一些经验以及理解,如果大家能通过文字固化下来造福下一个闯入者,岂不是一件很好的事情。

大家有文章都可以在这里回复外链,我会在WIKI开设一个第三方文档专区,收集这些我认为对开发者有帮助的文章,如果写得很好的文章,还可能会得到一个大QQ公仔的奖励。

文章不限篇幅,不限以下主题:

  • 使用经验,遇到的问题答疑。
  • 源码分析吐槽或者你的疑问(我会找时间解答)。
  • 如何通过PhxPaxos构建自己的分布式服务。
  • 你用PhxPaxos做了什么。
  • 性能测试。

编译找不到这个paxos_msg.pb.h,请问如何解决

compilation terminated.
make: *** [/data/phxsql-master/third_party/phxpaxos/phxpaxos-3341807442ad2e220bef3600f7424467a49be55c/src/communicate/communicate.o] Error 1
In file included from /data/phxsql-master/third_party/phxpaxos/phxpaxos-3341807442ad2e220bef3600f7424467a49be55c/src/algorithm/base.h:25:0,
from /data/phxsql-master/third_party/phxpaxos/phxpaxos-3341807442ad2e220bef3600f7424467a49be55c/src/algorithm/acceptor.h:24,
from /data/phxsql-master/third_party/phxpaxos/phxpaxos-3341807442ad2e220bef3600f7424467a49be55c/src/algorithm/acceptor.cpp:22:
/data/phxsql-master/third_party/phxpaxos/phxpaxos-3341807442ad2e220bef3600f7424467a49be55c/src/comm/comm_include.h:24:28: fatal error: ./paxos_msg.pb.h: No such file or directory
#include "./paxos_msg.pb.h"

phxpaxos 启动不了

一台服务器paxos服务一次重启后突然就启动不了,后台有日志:

2016-11-22 08:08:03.11s CheckpointInstanceID 6497752
2016-11-22 08:08:03.11s ERR(0): PN8phxpaxos8DatabaseE::GetMinChosenInstanceID no min chosen instanceid
2016-11-22 08:08:03.11s ERR(0): PN8phxpaxos8InstanceE::PlayLog log read fail, instanceid 6497754 ret 1
这个有可能是什么原因?

版本为master

第三方库问题

为什么不直接将使用到的第三方库直接放到third_party目录下,而需要去下载,这样可能会因为第三方库的版本更新导致编译问题,而且管理起来也不太方便

Prepare和Accept阶段持久化问题

Acceptor中OnPrepare和OnAccept中都调用Persist来持久化AcceptorState,存储是通过键llInstanceID从leveldb中拿到sFileID从而定位到值在文件中的偏移量。
由于leveldb中两次键都是一样,leveldb中会保存OnAccept中的sFileID,所以读的时候能够读到选定的值。在日志文件中,使用的是追加写,OnPrepare和OnAccept在文件中写了两条关于llInstanceID的日志,如果上面解读的正确,那么请问OnPrepare保存的日志是什么作用?

关于错误日志的问题

3台机器上频繁的错误日志,特别是master都快刷屏了,不知道对系统有没影响:
master:
2016-10-20 11:04:20.10s ERR(0): PN8phxpaxos8InstanceE::ReceiveMsgForProposer InstanceID not same, skip msg
2016-10-20 11:04:20.10s ERR(0): PN8phxpaxos8InstanceE::ReceiveMsgForProposer InstanceID not same, skip msg
2016-10-20 11:04:20.10s ERR(0): PN8phxpaxos8InstanceE::ReceiveMsgForProposer InstanceID not same, skip msg

一台slave
2016-10-20 11:06:37.10s ERR(0): PN8phxpaxos7LearnerE::OnSendNowInstanceID Lag msg, skip
2016-10-20 11:06:45.10s ERR(0): PN8phxpaxos7LearnerE::OnSendNowInstanceID Lag msg, skip

另一台slave
2016-10-20 11:06:28.10s ERR(0): PN8phxpaxos7LearnerE::OnSendNowInstanceID Lag msg, skip
2016-10-20 11:06:28.10s ERR(0): PN8phxpaxos7LearnerE::OnAskforLearn LearnerSender working for others.
2016-10-20 11:06:44.10s ERR(0): PN8phxpaxos7LearnerE::OnAskforLearn LearnerSender working for others.

3台机器都在同一个局域网

checkpoint_sender.cpp中的SendCheckpoint函数有重复代码

void CheckpointSender :: SendCheckpoint()
{
int ret = m_poLearner->SendCheckpointBegin(
m_iSendNodeID, m_llUUID, m_llSequence,
m_poSMFac->GetCheckpointInstanceID(m_poConfig->GetMyGroupIdx()));
if (ret != 0)
{
PLGErr("SendCheckpointBegin fail, ret %d", ret);
return;
}

ret = m_poLearner->SendCheckpointBegin(
        m_iSendNodeID, m_llUUID, m_llSequence,
        m_poSMFac->GetCheckpointInstanceID(m_poConfig->GetMyGroupIdx()));
if (ret != 0)
{
    PLGErr("SendCheckpointBegin fail, ret %d", ret);
    return;
}

这两段代码有重复吧?做的都是同一个事情。

主master内存问题

主master测试过程中内存会增长,是否是缓存原因?缓存最大会到多大?

master切换的问题

master在运行过程中突然从master变成slave了,另外一台slave变成master了,可能会是什么原因导致的呢?3台机器在局域网中
master上的日志:
2016-10-26 11:27:04.10s �[41;37m ERR(0): PN8phxpaxos9CommitterE::NewValueGetIDNoRetry Get lock ok, but lockusetime 868ms too long, lefttimeout 132ms �[0m
2016-10-26 11:31:07.10s �[41;37m ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 404 �[0m
2016-10-26 11:31:07.10s �[41;37m ERR(0): PN8phxpaxos8ProposerE::OnAcceptReply Not proposing, skip this msg �[0m
2016-10-26 11:31:07.10s �[41;37m ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14 �[0m
2016-10-26 11:31:07.10s �[41;37m ERR(0): PN8phxpaxos9CommitterE::NewValueGetIDNoRetry Get lock ok, but lockusetime 946ms too long, lefttimeout 54ms �[0m
2016-10-26 11:31:07.10s �[41;37m ERR(0): PN8phxpaxos9CommitterE::NewValueGetIDNoRetry Get lock ok, but lockusetime 1392ms too long, lefttimeout 0ms �[0m
2016-10-26 11:31:54.10s �[41;37m ERR(0): PN8phxpaxos9CommitterE::NewValueGetIDNoRetry Try get lock, but timeout, lockusetime 3642ms �[0m
2016-10-26 11:31:54.10s �[41;37m ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 404 �[0m
2016-10-26 11:31:55.10s �[41;37m ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14 �[0m
2016-10-26 11:31:55.10s �[41;37m ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14 �[0m
2016-10-26 11:31:56.10s �[41;37m ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 404 �[0m
2016-10-26 11:31:57.10s �[41;37m ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 404 �[0m
2016-10-26 11:31:59.10s �[41;37m ERR(0): PN8phxpaxos9CommitterE::NewValueGetIDNoRetry Try get lock, but timeout, lockusetime 1000ms �[0m
2016-10-26 11:32:00.10s �[41;37m ERR(0): PN8phxpaxos9CommitterE::NewValueGetIDNoRetry Try get lock, but timeout, lockusetime 1000ms �[0m
2016-10-26 11:32:01.10s �[41;37m ERR(0): PN8phxpaxos9CommitterE::NewValueGetIDNoRetry Try get lock, but timeout, lockusetime 1000ms �[0m
2016-10-26 11:32:02.10s �[41;37m ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14 �[0m
2016-10-26 11:32:03.10s �[41;37m ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 404 �[0m
2016-10-26 11:32:06.10s �[41;37m ERR(0): PN8phxpaxos9CommitterE::NewValueGetIDNoRetry Try get lock, but timeout, lockusetime 1000ms �[0m
2016-10-26 11:32:07.10s �[41;37m ERR(0): PN8phxpaxos9CommitterE::NewValueGetIDNoRetry Try get lock, but timeout, lockusetime 1000ms �[0m
2016-10-26 11:32:08.10s �[41;37m ERR(0): PN8phxpaxos9CommitterE::NewValueGetIDNoRetry Try get lock, but timeout, lockusetime 1000ms �[0m
2016-10-26 11:32:09.10s �[41;37m ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14 �[0m
2016-10-26 11:32:10.10s �[41;37m ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 404 �[0m
2016-10-26 11:32:12.10s �[41;37m ERR(0): PN8phxpaxos18MasterStateMachineE::LearnMaster version conflit, op version 1784849 now master version 1784894 �[0m
2016-10-26 11:32:12.10s �[41;37m ERR(0): PN8phxpaxos18MasterStateMachineE::LearnMaster version conflit, op version 1784852 now master version 1784894 �[0m
2016-10-26 11:32:12.10s �[41;37m ERR(0): PN8phxpaxos18MasterStateMachineE::LearnMaster version conflit, op version 1784863 now master version 1784894 �[0m
2016-10-26 11:32:12.10s �[41;37m ERR(0): PN8phxpaxos18MasterStateMachineE::LearnMaster version conflit, op version 1784878 now master version 1784894 �[0m
2016-10-26 11:32:47.10s �[41;37m ERR(0): PN8phxpaxos9CommitCtxE::GetResult commit fail, ret 14 �[0m

文件句柄泄漏的问题

在使用kv后偶尔会出现文件句柄泄漏的问题,kv是在phxkv基础上改的,使用的是SSDB的数据引擎,从代码看SSDB引擎是对leveldb的简单包装。现象为kv数据库的某个leveldb的ldb文件被打开了1万多个句柄,导致应用crash了,正常情况下某个ldb文件只是被打开一次的。另外propose中有不少的404的错误(应该是超时吧?),这个一般是什么原因呢?
操作系统为ubuntu14.04,普通的sata硬盘,我们是单进程多线程模型,某个时刻只有一个线程会操作phxpaxos引擎。
下面为用lsof统计的进程句柄情况,只贴了部分泄漏句柄:
mcu 13810 server1 7176r REG 8,1 1984229 2001190 /home/box/storage/kvdb/001125.ldb
mcu 13810 server1 7177r REG 8,1 1984229 2001190 /home/box/storage/kvdb/001125.ldb
mcu 13810 server1 7178r REG 8,1 1984229 2001190 /home/box/storage/kvdb/001125.ldb
mcu 13810 server1 7179r REG 8,1 1984229 2001190 /home/box/storage/kvdb/001125.ldb
mcu 13810 server1 7180r REG 8,1 1984229 2001190 /home/box/storage/kvdb/001125.ldb
mcu 13810 server1 7181r REG 8,1 1984229 2001190 /home/box/storage/kvdb/001125.ldb
mcu 13810 server1 7182r REG 8,1 1984229 2001190 /home/box/storage/kvdb/001125.ldb

内置选举功能一个疑问

你好,请教个问题:
如果节点的加入是通过类服务发现而逐渐加入,即任节点启动时并不知道其他节点的任何信息,直到通过服务发现才陆续知道其他节点的信息,而不是像你们给的例子是事先知道所有的节点ip,这个应该怎么实现呢?能否提供个大致思路呢?谢谢。

LogStorage的路径一定要是绝对路径吗

在接收checkpoint的时候遇到错误,发现原因是 CheckpointReceiver::InitFilePath 中会无条件在路径前加"/",原本的相对路径变成了绝对路径,没有权限mkdir失败。

编译protobuf时,无法执行./autogen.sh(已解决)

cd third_party
cp -r gmock ./protobuf/
./autogen.sh
然后继续按照文章编译即可…

补充一点点小问题并已解决:
执行./phxecho 127.0.0.1:11111 127.0.0.1:11111,127.0.0.1:11112,127.0.0.1:11113
会发现无法创建日志,Haochuan Cui :“在运行目录mkdir log就行了” ,OK, 3Q!

OK,今天上手试试。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.