can not get zookeeper path data, node cannot be discovery.

Open
#199 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
go

Research direction

Start at store/zookeeper/zookeeper.go around line 68 and read the Zookeeper Get implementation and its callers. Reproduce the repeated online/offline case against ZooKeeper 3.4.6, then verify that an existing node with empty data can be discovered and that the relevant behavior is covered by tests if the repository provides them.

Written by the indexing model from the issue text.

Description

zookeeper version: 3.4.6
this problem description: If you use the zk store lib, you will find that when the same node repeatedly goes online and offline, the node can no longer be discovery. After the investigation, it is found that the node path exists in zk, but the data cannot be obtained and the data is empty.

Previous code:store/zookeeper/zookeeper.go line 68.

func (s *Zookeeper) Get(key string) (pair *store.KVPair, err error) {
	resp, meta, err := s.client.Get(s.normalize(key))

	if err != nil {
		if err == zk.ErrNoNode {
			return nil, store.ErrKeyNotFound
		}
		return nil, err
	}

	// FIXME handle very rare cases where Get returns the
	// SOH control character instead of the actual value
	if string(resp) == SOH {
		return s.Get(store.Normalize(key))
	}

	pair = &store.KVPair{
		Key:       key,
		Value:     resp,
		LastIndex: uint64(meta.Version),
	}

	return pair, nil
}

Modified code, the problem disappears, hope to adopt.

func (s *Zookeeper) Get(key string) (pair *store.KVPair, err error) {
	resp, meta, err := s.client.Get(s.normalize(key))

	if err != nil {
		if err == zk.ErrNoNode {
			return nil, store.ErrKeyNotFound
		}
		return nil, err
	}
	
	// FIXME handle very rare cases where Get returns the
	// SOH control character instead of the actual value
	if string(resp) == SOH || string(resp) == "" {  //If the data is empty, you can get it again.
		return s.Get(key)  //get by original key
	}

	pair = &store.KVPair{
		Key:       key,
		Value:     resp,
		LastIndex: uint64(meta.Version),
	}

	return pair, nil
}
Dominant language
Go
Stars
847
Forks
204
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from docker/libkv

All issues in docker/libkv

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.