Merge pull request #17249 from ahrtr/meta_bucket_20240115

Replace `CreateBucket` with `CreateBucketIfNotExists`
This commit is contained in:
Benjamin Wang 2024-01-16 10:22:54 +00:00 committed by GitHub
commit e3c70c8a99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,8 +112,7 @@ func (t *batchTx) Unlock() {
}
func (t *batchTx) UnsafeCreateBucket(bucket Bucket) {
_, err := t.tx.CreateBucket(bucket.Name())
if err != nil && err != bolt.ErrBucketExists {
if _, err := t.tx.CreateBucketIfNotExists(bucket.Name()); err != nil {
t.backend.lg.Fatal(
"failed to create a bucket",
zap.Stringer("bucket-name", bucket),