bonifaido / rust-zookeeper

Pure Rust library for Apache ZooKeeper built on MIO
MIT License
206 stars 46 forks source link

rust-zookeeper can't create data with zetcd cluster #83

Closed acezen closed 3 years ago

acezen commented 3 years ago

I run an etcd cluster and use zetcd to to dispatch the zookeeper operations on an etcd cluster.

zetcd --zkaddr 0.0.0.0:2181 --endpoints localhost:2379

and then I use rust-zookeeper to connect with zetcd and create data:

    // Connect to the test cluster
    let zk = ZooKeeper::connect("127.0.0.1:2181",
                                Duration::from_secs(5),
                                move |event: WatchedEvent| {
                                    info!("{:?}", event);
                                    if event.keeper_state == KeeperState::Disconnected {
                                        disconnects_watcher.fetch_add(1, Ordering::Relaxed);
                                    }
                                })
                 .unwrap();

    // Do the tests
    let create = zk.create("/test",
                           vec![8, 8],
                           Acl::open_unsafe().clone(),
                           CreateMode::Ephemeral);

it can connect to the zetcd, but when it send a create data request to zetcd, rust-zookeeper got error when parse the response:

2021-08-23T03:07:16Z ERROR zookeeper::zookeeper] error closing zookeeper connection in drop: ConnectionLoss
test zk_test ... FAILED                                                                               

failures:                                                                                             

---- zk_test stdout ----
thread 'io' panicked at 'Failed to parse ConnectResponse Error { kind: UnexpectedEof, message: "failed to fill whole buffer" }', src/io.rs:225:21
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
   1: std::panicking::begin_panic_fmt                                                            
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:457:5
   2: zookeeper::io::ZkIo::handle_chunk        
             at ./src/io.rs:225:21 
   3: zookeeper::io::ZkIo::handle_response
             at ./src/io.rs:164:17
   4: zookeeper::io::ZkIo::ready_zk
             at ./src/io.rs:417:21
   5: zookeeper::io::ZkIo::ready
             at ./src/io.rs:366:19
   6: zookeeper::io::ZkIo::run
             at ./src/io.rs:569:17
   7: zookeeper::zookeeper::ZooKeeper::connect::{{closure}}
             at ./src/zookeeper.rs:78:44
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

and here is zetcd's log:

I0823 10:46:59.490173  461733 server.go:91] accepted remote connection "127.0.0.1:34456"
I0823 10:46:59.490318  461733 authconn.go:50] error reading connection request (EOF)
I0823 10:46:59.490324  461733 server.go:91] accepted remote connection "127.0.0.1:34458"
I0823 10:46:59.490347  461733 authconn.go:53] auth(&{ProtocolVersion:0 LastZxidSeen:0 TimeOut:5000 SessionID:0 Passwd:[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]})
I0823 10:46:59.491225  461733 pool.go:83] authresp=&{ProtocolVersion:0 TimeOut:5000 SessionID:7587856633219205200 Passwd:[49 166 157 159 194 53 181 70 167 83 236 228 211 170 130 6]}
I0823 10:46:59.491280  461733 server.go:64] serving serial session requests on id=694d7b67dd9f4850
I0823 10:46:59.491290  461733 session.go:59] starting the session... id=7587856633219205200
I0823 10:46:59.491305  461733 server.go:73] zkreq={xid:1 req:*zetcd.CreateRequest:&{Path:/test Data:[8 8] Acl:[{Perms:31 Scheme:world ID:anyone}] Flags:1}}
I0823 10:46:59.491327  461733 zklog.go:28] Create(1,{Path:/test Data:[8 8] Acl:[{Perms:31 Scheme:world ID:anyone}] Flags:1})
I0823 10:46:59.492012  461733 zketcd.go:53] Create(1) = (zxid=41); txnresp: {Header:cluster_id:14841639068965178418 member_id:10276657743932975437 revision:41 raft_term:2  Succeeded:true Responses:[response_put:<header:<revision:41 > >  response_put:<header:<revision:41 > >  response_put:<header:<revision:41 > >  response_put:<header:<revision:41 > >  response_put:<header:<revision:41 > >  response_put:<header:<revision:41 > >  response_put:<header:<revision:41 > >  response_put:<header:<revision:41 > >  response_put:<header:<revision:41 > > ]}
I0823 10:46:59.492477  461733 conn.go:139] conn.Send(xid=1, zxid=40, &{Path:/test})
I0823 10:46:59.501334  461733 server.go:73] zkreq={xid:0 err:"read tcp 127.0.0.1:2181->127.0.0.1:34458: read: connection reset by peer"}
I0823 10:46:59.501367  461733 session.go:61] finishing the session... id=7587856633219205200; expect revoke...
acezen commented 3 years ago

I try zookeeper java client too , it can work with zetcd.