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

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

Open
rl5c opened this issue Mar 31, 2018 · 0 comments
Open

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

rl5c opened this issue Mar 31, 2018 · 0 comments

Comments

@rl5c
Copy link

rl5c commented Mar 31, 2018

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
}
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

1 participant