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

[etcdapi] [Bug]: Repeated revision #848

Closed
1 task done
liangyuanpeng opened this issue Jun 11, 2024 · 2 comments
Closed
1 task done

[etcdapi] [Bug]: Repeated revision #848

liangyuanpeng opened this issue Jun 11, 2024 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@liangyuanpeng
Copy link
Contributor

liangyuanpeng commented Jun 11, 2024

Description about the bug

I'm testing xline with kubernetes conformance. There's a high probability i will get an error: the object has been modified; please apply your changes to the latest version and try again, In general this is a specific design of the k8s, not a fault, but it is a real problem when it becomes a blocker to conformance testing.

the reason is xline retrun the repeate revision.

try to reproduce:

package main

import (
	"context"
	"fmt"
	"log"
	"sync"
	"time"

	clientv3 "go.etcd.io/etcd/client/v3"
)

func main() {
	config := clientv3.Config{
		Endpoints: []string{"192.168.66.2:12379"},
		DialTimeout: 5 * time.Second,
	}
	client, err := clientv3.New(config)
	if err != nil {
		log.Fatal("init client error:", err)
	}

	fmt.Println(client.Cluster.MemberList(context.TODO()))
	c := make(chan *kvresp, 100)
	revmap := make(map[int64]string)
	var mu sync.RWMutex
	putdata(client, 6, c)
	for {
		x := <-c
		mu.RLock()
		if _, ok := revmap[x.reversion]; ok {
			log.Fatalf("exist reversion:%d when working for key:%s !! \n", x.reversion, x.key)
		}
		revmap[x.reversion] = x.key
		log.Printf("finished for key:%s and reversion:%d \n", x.key, x.reversion)
		mu.RUnlock()
	}

}

type kvresp struct {
	key       string
	reversion int64
}

func putdata(client *clientv3.Client, channelcount int, cc chan *kvresp) {

	sts := []string{"/kindtest/configmaps/namespace/cm2", "/kindtest/configmaps/namespace/cm1", "/kindtest/configmaps/namespace/cm3", "/kindtest/configmaps/namespace/cm4", "/kindtest/configmaps/namespace/cm5", "/kindtest/configmaps/namespace/cm6"}

	for i := 0; i < channelcount; i++ {
		go func() {
			for {
				k := sts[i]
				resp, err := client.KV.Put(context.TODO(), k, "world1111111111111111kkkkkkkkkkkkkkkkkkkkkkkkkkkkxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxpppppppppppppppppppppppppwwwwwwwwwwwwwwwwwwwwwwwwwwqqqqqqqqqqqqqqqqqqqqqqqq")
				if err != nil {
					log.Fatal("put data failed!", err)
				}
				cc <- &kvresp{
					reversion: resp.Header.Revision,
					key:       k,
				}
				// time.Sleep(200)
			}

		}()
	}
}

cc @Phoenix500526 @bsbds

Version

xline version: master (ghcr.io/xline-kv/xline:latest)
go version: 1.22

Relevant log output

$ go run main.go 
&{cluster_id:18175749204089910324 member_id:16162903154130446168 revision:10233  [ID:16162903154130446168 name:"xline" peerURLs:"0.0.0.0:12379" clientURLs:"http://0.0.0.0:12379" ] {} [] 0} <nil>
2024/06/11 07:44:18 finished for key:/kindtest/configmaps/namespace/cm6 and reversion:10237 
2024/06/11 07:44:18 finished for key:/kindtest/configmaps/namespace/cm2 and reversion:10234 
2024/06/11 07:44:18 exist reversion:10237 when working for key:/kindtest/configmaps/namespace/cm3 !! 
exit status 1

Code of Conduct

  • I agree to follow this project's Code of Conduct
@liangyuanpeng liangyuanpeng added the bug Something isn't working label Jun 11, 2024
@liangyuanpeng liangyuanpeng changed the title [Bug]: Repeated reversion [etcdapi] [Bug]: Repeated reversion Jun 11, 2024
Copy link

👋 Thanks for opening this issue!

Reply with the following command on its own line to get help or engage:

  • /contributing-agreement : to print Contributing Agreements.
  • /assignme : to assign this issue to you.

@liangyuanpeng liangyuanpeng changed the title [etcdapi] [Bug]: Repeated reversion [etcdapi] [Bug]: Repeated revision Jun 11, 2024
@bsbds
Copy link
Collaborator

bsbds commented Jun 14, 2024

This is a known issue in Xline, it will be fixed in 0.7.0

@bsbds bsbds added this to the v0.7.0 milestone Jun 14, 2024
@bsbds bsbds closed this as completed Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants