Skip to content

Commit

Permalink
fix: use existing mutable batch (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
istae authored Oct 10, 2023
1 parent 655c050 commit 5eead45
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 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
23 changes: 8 additions & 15 deletions pkg/check/smoke/smoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ type Options struct {
UploadGroups []string
DownloaderCount int
DownloadGroups []string
GasPrice string
MaxUseBatch time.Duration
}

Expand All @@ -42,15 +41,14 @@ func NewDefaultOptions() Options {
return Options{
ContentSize: 5000000,
RndSeed: time.Now().UnixNano(),
PostageAmount: 1000000,
PostageDepth: 20,
PostageAmount: 50_000_000,
PostageDepth: 24,
TxOnErrWait: 10 * time.Second,
RxOnErrWait: 10 * time.Second,
NodesSyncWait: time.Second * 30,
Duration: 12 * time.Hour,
UploadTimeout: 5 * time.Minute,
DownloadTimeout: 5 * time.Minute,
GasPrice: "100000000000",
MaxUseBatch: 12 * time.Hour,
}
}
Expand Down Expand Up @@ -91,8 +89,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 +145,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
1 change: 0 additions & 1 deletion pkg/config/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,6 @@ var Checks = map[string]CheckType{
RxOnErrWait *time.Duration `yaml:"rx-on-err-wait"`
NodesSyncWait *time.Duration `yaml:"nodes-sync-wait"`
Duration *time.Duration `yaml:"duration"`
MaxUseBatch *time.Duration `yaml:"max-use-batch"`
})
if err := check.Options.Decode(checkOpts); err != nil {
return nil, fmt.Errorf("decoding check %s options: %w", check.Type, err)
Expand Down

0 comments on commit 5eead45

Please sign in to comment.