satellite/metainfo/metabase: allow commmitting objects > 2 GiB
The total_plain_size and total_encrypted_size columns in the objects table were set as INT4, which limits the size of committed objects to just 2 GiB. This patch migrates the DB to change the type of these fields to INT8. Change-Id: Iad7e7b44a652e6c5b8e17b80588637bb48390fe6
This commit is contained in:
parent
ad3e3a38c5
commit
4fc61f7afa
@ -4,6 +4,7 @@
|
||||
package metabase_test
|
||||
|
||||
import (
|
||||
"math"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -1639,6 +1640,111 @@ func TestCommitObject(t *testing.T) {
|
||||
},
|
||||
}.Check(ctx, t, db)
|
||||
})
|
||||
|
||||
t.Run("large object over 2 GB", func(t *testing.T) {
|
||||
defer DeleteAll{}.Check(ctx, t, db)
|
||||
|
||||
BeginObjectExactVersion{
|
||||
Opts: metabase.BeginObjectExactVersion{
|
||||
ObjectStream: obj,
|
||||
Encryption: defaultTestEncryption,
|
||||
},
|
||||
Version: 1,
|
||||
}.Check(ctx, t, db)
|
||||
now := time.Now()
|
||||
|
||||
rootPieceID := testrand.PieceID()
|
||||
pieces := metabase.Pieces{{Number: 0, StorageNode: testrand.NodeID()}}
|
||||
encryptedKey := testrand.Bytes(32)
|
||||
encryptedKeyNonce := testrand.Bytes(32)
|
||||
|
||||
CommitSegment{
|
||||
Opts: metabase.CommitSegment{
|
||||
ObjectStream: obj,
|
||||
Position: metabase.SegmentPosition{Index: 0},
|
||||
RootPieceID: rootPieceID,
|
||||
Pieces: pieces,
|
||||
|
||||
EncryptedKey: encryptedKey,
|
||||
EncryptedKeyNonce: encryptedKeyNonce,
|
||||
|
||||
EncryptedSize: math.MaxInt32,
|
||||
PlainSize: math.MaxInt32,
|
||||
Redundancy: defaultTestRedundancy,
|
||||
},
|
||||
}.Check(ctx, t, db)
|
||||
|
||||
CommitSegment{
|
||||
Opts: metabase.CommitSegment{
|
||||
ObjectStream: obj,
|
||||
Position: metabase.SegmentPosition{Index: 1},
|
||||
RootPieceID: rootPieceID,
|
||||
Pieces: pieces,
|
||||
|
||||
EncryptedKey: encryptedKey,
|
||||
EncryptedKeyNonce: encryptedKeyNonce,
|
||||
|
||||
EncryptedSize: math.MaxInt32,
|
||||
PlainSize: math.MaxInt32,
|
||||
Redundancy: defaultTestRedundancy,
|
||||
},
|
||||
}.Check(ctx, t, db)
|
||||
|
||||
CommitObject{
|
||||
Opts: metabase.CommitObject{
|
||||
ObjectStream: obj,
|
||||
},
|
||||
}.Check(ctx, t, db)
|
||||
|
||||
Verify{
|
||||
Segments: []metabase.RawSegment{
|
||||
{
|
||||
StreamID: obj.StreamID,
|
||||
Position: metabase.SegmentPosition{Index: 0},
|
||||
|
||||
RootPieceID: rootPieceID,
|
||||
EncryptedKey: encryptedKey,
|
||||
EncryptedKeyNonce: encryptedKeyNonce,
|
||||
|
||||
EncryptedSize: math.MaxInt32,
|
||||
PlainSize: math.MaxInt32,
|
||||
|
||||
Redundancy: defaultTestRedundancy,
|
||||
|
||||
Pieces: pieces,
|
||||
},
|
||||
{
|
||||
StreamID: obj.StreamID,
|
||||
Position: metabase.SegmentPosition{Index: 1},
|
||||
|
||||
RootPieceID: rootPieceID,
|
||||
EncryptedKey: encryptedKey,
|
||||
EncryptedKeyNonce: encryptedKeyNonce,
|
||||
|
||||
EncryptedSize: math.MaxInt32,
|
||||
PlainSize: math.MaxInt32,
|
||||
|
||||
Redundancy: defaultTestRedundancy,
|
||||
|
||||
Pieces: pieces,
|
||||
},
|
||||
},
|
||||
Objects: []metabase.RawObject{
|
||||
{
|
||||
ObjectStream: obj,
|
||||
CreatedAt: now,
|
||||
Status: metabase.Committed,
|
||||
|
||||
SegmentCount: 2,
|
||||
FixedSegmentSize: math.MaxInt32,
|
||||
TotalPlainSize: 2 * math.MaxInt32,
|
||||
TotalEncryptedSize: 2 * math.MaxInt32,
|
||||
|
||||
Encryption: defaultTestEncryption,
|
||||
},
|
||||
},
|
||||
}.Check(ctx, t, db)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -131,6 +131,15 @@ func (db *DB) PostgresMigration() *migrate.Migration {
|
||||
)`,
|
||||
},
|
||||
},
|
||||
{
|
||||
DB: &db.db,
|
||||
Description: "change total_plain_size and total_encrypted_size to INT8",
|
||||
Version: 2,
|
||||
Action: migrate.SQL{
|
||||
`ALTER TABLE objects ALTER COLUMN total_plain_size TYPE INT8;`,
|
||||
`ALTER TABLE objects ALTER COLUMN total_encrypted_size TYPE INT8;`,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user