Skip to content

Commit

Permalink
fix: adding lock while discovering partitions, Closes #412 (#413)
Browse files Browse the repository at this point in the history
Signed-off-by: Yashash H L <yashashhl25@gmail.com>
  • Loading branch information
yhl25 authored and whynowy committed Dec 7, 2022
1 parent c439a6a commit 676ea1c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pkg/pbq/store/memory/stores.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ func (ms *memoryStores) CreateStore(ctx context.Context, partitionID partition.I
}

func (ms *memoryStores) DiscoverPartitions(ctx context.Context) ([]partition.ID, error) {
ms.RLock()
defer ms.RUnlock()
if ms.discoverFunc == nil {
partitionsIds := make([]partition.ID, 0)
for key := range ms.partitions {
Expand Down
4 changes: 2 additions & 2 deletions pkg/reduce/reduce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ func TestDataForward_WithContextClose(t *testing.T) {
// wait for the partitions to be created
for {
partitionsList := pbqManager.ListPartitions()
if len(partitionsList) > 0 {
if len(partitionsList) > 1 {
childCancel()
break
}
Expand All @@ -717,7 +717,7 @@ func TestDataForward_WithContextClose(t *testing.T) {
for {
discoveredPartitions, _ = storeProvider.DiscoverPartitions(ctx)

if len(discoveredPartitions) > 0 {
if len(discoveredPartitions) > 1 {
break
}
select {
Expand Down

0 comments on commit 676ea1c

Please sign in to comment.