Skip to content

Commit de17ad4

Browse files
authored
fix(blob-uploader): orm function InsertOrUpdateBlobUpload and s3 bucket region configuration (#1679)
Co-authored-by: yiweichi <[email protected]>
1 parent 4233ad9 commit de17ad4

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

common/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"runtime/debug"
66
)
77

8-
var tag = "v4.5.29"
8+
var tag = "v4.5.30"
99

1010
var commit = func() string {
1111
if info, ok := debug.ReadBuildInfo(); ok {

rollup/cmd/blob_uploader/app/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func action(ctx *cli.Context) error {
7070
log.Crit("failed to create l2 relayer", "config file", cfgFile, "error", err)
7171
}
7272

73-
go utils.Loop(subCtx, 2*time.Second, blobUploader.UploadBlobToS3)
73+
go utils.Loop(subCtx, 1*time.Second, blobUploader.UploadBlobToS3)
7474

7575
// Finish start all blob-uploader functions.
7676
log.Info("Start blob-uploader successfully", "version", version.Version)

rollup/internal/controller/blob_uploader/s3_sender.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ type S3Uploader struct {
2525
func NewS3Uploader(cfg *config.AWSS3Config) (*S3Uploader, error) {
2626
// load AWS config
2727
var opts []func(*awsconfig.LoadOptions) error
28-
opts = append(opts, awsconfig.WithRegion(cfg.Region))
29-
3028
// if AccessKey && SecretKey provided, use it
3129
if cfg.AccessKey != "" && cfg.SecretKey != "" {
3230
opts = append(opts, awsconfig.WithCredentialsProvider(
@@ -38,6 +36,10 @@ func NewS3Uploader(cfg *config.AWSS3Config) (*S3Uploader, error) {
3836
)
3937
}
4038

39+
if cfg.Region != "" {
40+
opts = append(opts, awsconfig.WithRegion(cfg.Region))
41+
}
42+
4143
awsCfg, err := awsconfig.LoadDefaultConfig(context.Background(), opts...)
4244
if err != nil {
4345
return nil, fmt.Errorf("failed to load default config: %w", err)

rollup/internal/orm/blob_upload.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ func (o *BlobUpload) InsertOrUpdateBlobUpload(ctx context.Context, batchIndex ui
115115
return fmt.Errorf("BlobUpload.InsertOrUpdateBlobUpload query error: %w, batch index: %v, batch_hash: %v, platform: %v", err, batchIndex, batchHash, platform)
116116
}
117117

118-
if err := db.Model(&existing).Update("status", int16(status)).Error; err != nil {
118+
if err := db.Model(&existing).Where("batch_index = ? AND batch_hash = ? AND platform = ? AND deleted_at IS NULL",
119+
batchIndex, batchHash, int16(platform)).Update("status", int16(status)).Error; err != nil {
119120
return fmt.Errorf("BlobUpload.InsertOrUpdateBlobUpload update error: %w, batch index: %v, batch_hash: %v, platform: %v", err, batchIndex, batchHash, platform)
120121
}
121122

0 commit comments

Comments
 (0)