fix datarace
Some checks failed
test / test (pull_request) Failing after 18m15s
lint / lint (pull_request) Failing after 18m27s
coverage / build (pull_request) Failing after 18m33s

This commit is contained in:
Evstigneev Denis
2025-12-10 16:51:51 +03:00
parent f98811b93e
commit 813999e969
2 changed files with 6 additions and 0 deletions

View File

@@ -239,6 +239,8 @@ func TestKillConsumers_E2E_Rebalance(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
bLogger := broker.Logger(logger.DefaultLogger.Clone(logger.WithLevel(logger.DebugLevel)))
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel() defer cancel()
@@ -246,6 +248,7 @@ func TestKillConsumers_E2E_Rebalance(t *testing.T) {
broker.ContentType("application/octet-stream"), broker.ContentType("application/octet-stream"),
broker.Codec("application/octet-stream", codec.NewCodec()), broker.Codec("application/octet-stream", codec.NewCodec()),
broker.Addrs(cluster.ListenAddrs()...), broker.Addrs(cluster.ListenAddrs()...),
bLogger,
kgo.CommitInterval(500*time.Millisecond), kgo.CommitInterval(500*time.Millisecond),
kgo.Options( kgo.Options(
kg.ClientID("test-1"), kg.ClientID("test-1"),
@@ -266,6 +269,7 @@ func TestKillConsumers_E2E_Rebalance(t *testing.T) {
broker.ContentType("application/octet-stream"), broker.ContentType("application/octet-stream"),
broker.Codec("application/octet-stream", codec.NewCodec()), broker.Codec("application/octet-stream", codec.NewCodec()),
broker.Addrs(cluster.ListenAddrs()...), broker.Addrs(cluster.ListenAddrs()...),
bLogger,
kgo.CommitInterval(500*time.Millisecond), kgo.CommitInterval(500*time.Millisecond),
kgo.Options( kgo.Options(
kg.ClientID("test-2"), kg.ClientID("test-2"),

View File

@@ -79,8 +79,10 @@ func (s *Subscriber) Unsubscribe(ctx context.Context) error {
kc[ctp.t] = append(kc[ctp.t], ctp.p) kc[ctp.t] = append(kc[ctp.t], ctp.p)
} }
s.killConsumers(ctx, kc) s.killConsumers(ctx, kc)
s.mu.Lock()
close(s.done) close(s.done)
s.closed = true s.closed = true
s.mu.Unlock()
s.c.ResumeFetchTopics(s.topic) s.c.ResumeFetchTopics(s.topic)
return nil return nil