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

store: copy old value when refresh + cas #5683

Merged
merged 1 commit into from
Jun 15, 2016
Merged

Conversation

xiang90
Copy link
Contributor

@xiang90 xiang90 commented Jun 15, 2016

@@ -298,6 +298,10 @@ func (s *store) CompareAndSwap(nodePath string, prevValue string, prevIndex uint
return nil, err
}

if expireOpts.Refresh {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this return an error if value != "" in case someone expects this to use the given value like a refreshless CAS?

@heyitsanthony
Copy link
Contributor

lgtm

@xiang90 xiang90 merged commit bc69142 into etcd-io:master Jun 15, 2016
@xiang90 xiang90 deleted the fix_refresh branch June 15, 2016 23:11
@LLParse
Copy link

LLParse commented Sep 5, 2016

Hi @xiang90, I see this is labelled for backport. Which versions is this fix targeted for?

@heyitsanthony
Copy link
Contributor

@LLParse this was backported into 2.3.7.

@LLParse
Copy link

LLParse commented Sep 6, 2016

@heyitsanthony Thanks...

For reference, I downloaded https://github.com/coreos/etcd/releases/download/v2.3.7/etcd-v2.3.7-darwin-amd64.zip on Sep 2 17:39 MST and it exhibited this behavior. I will build the tagged release from source for now.

@heyitsanthony
Copy link
Contributor

@LLParse I fetched 2.3.7-darwin-amd64.zip and I'm seeing Git SHA: fd17c91 when I run etcd. Checking out the release-2.3 repo at that commit, I see 9ce0e8b right before it. The fix should be built into the binary. How are you testing this?

@LLParse
Copy link

LLParse commented Sep 6, 2016

My code must be the problem. Sorry. It occurs to me that my initial write could've been erroneous when I ran into this issue and I simply ran into this issue when looking for an answer. Alternatively, I'm using the API incorrectly.

This is the initial registration call.

const (
    nodeLockTTL = 30 * time.Second
)

    n.Id = uuid.NewV4().String()
    n.Info = &NodeInfo{n.Config.Hostname}
    nodeInfoJson, _ := json.Marshal(n.Info)
    n.InfoJson = string(nodeInfoJson)
    log.Printf("Creating node %s\n", n.Id)

    _, err := n.Keys.Set(
        context.Background(),
        fmt.Sprintf("/%s/nodes/%s", n.Config.ClusterName, n.Id),
        n.InfoJson,
        &etcd.SetOptions{TTL: nodeLockTTL})

This is the call that I perceived as setting the value to an empty string.

            _, err := n.Keys.Set(
                context.Background(),
                fmt.Sprintf("/%s/nodes/%s", n.Config.ClusterName, n.Id),
                "",
                &etcd.SetOptions{TTL: nodeLockTTL, Refresh: true})

@LLParse
Copy link

LLParse commented Sep 6, 2016

Whoooops, definitely my mistake. It is functioning properly for me now - I must've messed up the initial set. My apologies, please disregard this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants