mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
avoid data race on doSubscribeToOneFiler/ma.filer.UniqueFilerEpoch (#3566)
https://github.com/seaweedfs/seaweedfs/issues/3565
This commit is contained in:
parent
9c76896e2d
commit
803ca3c958
|
@ -9,6 +9,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
@ -194,13 +195,13 @@ func (ma *MetaAggregator) doSubscribeToOneFiler(f *Filer, self pb.ServerAddress,
|
||||||
err = pb.WithFilerClient(true, peer, ma.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
err = pb.WithFilerClient(true, peer, ma.grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
ma.filer.UniqueFilerEpoch++
|
atomic.AddInt32(&ma.filer.UniqueFilerEpoch, 1)
|
||||||
stream, err := client.SubscribeLocalMetadata(ctx, &filer_pb.SubscribeMetadataRequest{
|
stream, err := client.SubscribeLocalMetadata(ctx, &filer_pb.SubscribeMetadataRequest{
|
||||||
ClientName: "filer:" + string(self),
|
ClientName: "filer:" + string(self),
|
||||||
PathPrefix: "/",
|
PathPrefix: "/",
|
||||||
SinceNs: lastTsNs,
|
SinceNs: lastTsNs,
|
||||||
ClientId: ma.filer.UniqueFilerId,
|
ClientId: ma.filer.UniqueFilerId,
|
||||||
ClientEpoch: ma.filer.UniqueFilerEpoch,
|
ClientEpoch: atomic.LoadInt32(&ma.filer.UniqueFilerEpoch),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("subscribe: %v", err)
|
return fmt.Errorf("subscribe: %v", err)
|
||||||
|
|
Loading…
Reference in a new issue