Skip to content

Commit

Permalink
fix: use existing mutable batch
Browse files Browse the repository at this point in the history
  • Loading branch information
istae committed Oct 4, 2023
1 parent 655c050 commit e8d40a8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
7 changes: 4 additions & 3 deletions pkg/bee/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,11 @@ func (c *Client) GetOrCreateBatch(ctx context.Context, amount int64, depth uint6
if !b.Exists {
continue
}
max := 1 << (b.Depth - b.BucketDepth)
hasFreeSlots := b.Utilization < uint32(max)
if b.ImmutableFlag { // skip immutable batches
continue
}

if b.Usable && (b.BatchTTL == -1 || b.BatchTTL > 0) && hasFreeSlots {
if b.Usable && (b.BatchTTL == -1 || b.BatchTTL > 0) {
return b.BatchID, nil
}
}
Expand Down
17 changes: 6 additions & 11 deletions pkg/check/smoke/smoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int

time.Sleep(5 * time.Second) // Wait for the nodes to warmup.

batches := NewStore(o.MaxUseBatch)

test := &test{clients: clients, logger: c.logger}

for i := 0; true; i++ {
Expand Down Expand Up @@ -149,15 +147,12 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int
txCtx, txCancel = context.WithTimeout(ctx, o.UploadTimeout)

c.metrics.BatchCreateAttempts.Inc()
batchID := batches.Get(txName)
if batchID == "" {
batchID, err = clients[txName].CreatePostageBatch(txCtx, o.PostageAmount, o.PostageDepth, "load-test", true)
if err != nil {
c.logger.Errorf("create new batch: %v", err)
c.metrics.BatchCreateErrors.Inc()
continue
}
batches.Store(txName, batchID)

batchID, err := clients[txName].GetOrCreateBatch(txCtx, o.PostageAmount, o.PostageDepth, "load-test")
if err != nil {
c.logger.Errorf("create new batch: %v", err)
c.metrics.BatchCreateErrors.Inc()
continue
}

c.metrics.UploadAttempts.Inc()
Expand Down

0 comments on commit e8d40a8

Please sign in to comment.