-
Notifications
You must be signed in to change notification settings - Fork 742
Closed
Labels
Description
Bug Report
What did you do?
- Write a script that continuously create keyspaces
#!/bin/bash
# Set the number of keyspaces you want to create
n=800
for ((i=1; i<=n; i++))
do
curl -X POST http://localhost:2379/pd/api/v2/keyspaces \
-H 'Content-Type: application/json' \
-d '{"name":"test-'$i'", "config": {}}'
done
- Use pdClient.WatchKeyspace
func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
pdCli, err := pd.NewClient([]string{PDAddress}, pd.SecurityOption{})
if err != nil {
log.Fatal("failed to create pd client", zap.Error(err))
}
keyspacesChan, err := pdCli.WatchKeyspaces(ctx)
if err != nil {
log.Fatal("failed to watch keyspace", zap.Error(err))
}
packIndex := 0
totalKeyspaceCount := 0
for {
select {
case <-ctx.Done():
return
case keyspaces := <-keyspacesChan:
log.Info("keyspaces received",
zap.Int("pack-index", packIndex),
zap.Int("keyspace-count", len(keyspaces)),
zap.Int("total-keyspace-count", totalKeyspaceCount),
)
for _, keyspace := range keyspaces {
log.Info("keyspace meta",
zap.Uint32("keyspace-id", keyspace.GetId()),
zap.String("keyspace-name", keyspace.GetName()),
zap.String("keyspace-state", keyspace.GetState().String()),
)
}
packIndex++
totalKeyspaceCount += len(keyspaces)
}
}
}
What did you expect to see?
- The first load from channel should contain all current keyspaces.
- each subsequent load from channel should contain subsequent update to keyspaces.
What did you see instead?
- The first load from channel only contains the first 400 keyspaces.
- subsequent load start from the current keyspace (600+), causing keyspace meta in the middle to be lost
What version of PD are you using (pd-server -V
)?
nightly (7.2.0)