From fc3c7665eada244b0cbbd8d473f176b8a6a0b260 Mon Sep 17 00:00:00 2001 From: gammazero Date: Thu, 24 Sep 2020 12:10:29 -0700 Subject: [PATCH 1/6] Fix integer overflow error when building for 386 The untyped const causes conversion to int, for which the value is too large. Use a typed const instead that is large enough to store value. --- value.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/value.go b/value.go index 9a3547fb5..f69678b72 100644 --- a/value.go +++ b/value.go @@ -48,7 +48,7 @@ import ( // maxVlogFileSize is the maximum size of the vlog file which can be created. Vlog Offset is of // uint32, so limiting at max uint32. -var maxVlogFileSize = math.MaxUint32 +var maxVlogFileSize = int64(math.MaxUint32) // Values have their first byte being byteData or byteDelete. This helps us distinguish between // a key that has never been seen and a key that has been explicitly deleted. From 00dbef12b747fa74931c3d26348124a6c4e082a8 Mon Sep 17 00:00:00 2001 From: gammazero Date: Thu, 24 Sep 2020 13:03:57 -0700 Subject: [PATCH 2/6] uint32 instead of int64 --- value.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/value.go b/value.go index f69678b72..d001f1fd7 100644 --- a/value.go +++ b/value.go @@ -48,7 +48,7 @@ import ( // maxVlogFileSize is the maximum size of the vlog file which can be created. Vlog Offset is of // uint32, so limiting at max uint32. -var maxVlogFileSize = int64(math.MaxUint32) +var maxVlogFileSize = uint32(math.MaxUint32) // Values have their first byte being byteData or byteDelete. This helps us distinguish between // a key that has never been seen and a key that has been explicitly deleted. From 0271bf64866e4abe385c82af71124e4bfcd0ee36 Mon Sep 17 00:00:00 2001 From: gammazero Date: Thu, 24 Sep 2020 13:25:43 -0700 Subject: [PATCH 3/6] additional 32bit fixes --- badger/cmd/backup.go | 2 +- badger/cmd/restore.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/badger/cmd/backup.go b/badger/cmd/backup.go index a2df7644e..1fdf9c250 100644 --- a/badger/cmd/backup.go +++ b/badger/cmd/backup.go @@ -55,7 +55,7 @@ func doBackup(cmd *cobra.Command, args []string) error { opt := badger.DefaultOptions(sstDir). WithValueDir(vlogDir). WithTruncate(truncate). - WithNumVersionsToKeep(math.MaxUint32) + WithNumVersionsToKeep(int(math.MaxUint32)) if numVersions > 0 { opt.NumVersionsToKeep = numVersions diff --git a/badger/cmd/restore.go b/badger/cmd/restore.go index ad7f133a8..4708e3ef7 100644 --- a/badger/cmd/restore.go +++ b/badger/cmd/restore.go @@ -68,7 +68,7 @@ func doRestore(cmd *cobra.Command, args []string) error { // Open DB db, err := badger.Open(badger.DefaultOptions(sstDir). WithValueDir(vlogDir). - WithNumVersionsToKeep(math.MaxUint32)) + WithNumVersionsToKeep(int(math.MaxUint32))) if err != nil { return err } From 8afebcba80e5115c2bbff43433a61b5071760cb8 Mon Sep 17 00:00:00 2001 From: gammazero Date: Thu, 24 Sep 2020 14:02:02 -0700 Subject: [PATCH 4/6] Use math.MaxInt32 as max int value --- badger/cmd/backup.go | 2 +- badger/cmd/restore.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/badger/cmd/backup.go b/badger/cmd/backup.go index 1fdf9c250..ed3688c71 100644 --- a/badger/cmd/backup.go +++ b/badger/cmd/backup.go @@ -55,7 +55,7 @@ func doBackup(cmd *cobra.Command, args []string) error { opt := badger.DefaultOptions(sstDir). WithValueDir(vlogDir). WithTruncate(truncate). - WithNumVersionsToKeep(int(math.MaxUint32)) + WithNumVersionsToKeep(int(math.MaxInt32)) if numVersions > 0 { opt.NumVersionsToKeep = numVersions diff --git a/badger/cmd/restore.go b/badger/cmd/restore.go index 4708e3ef7..899403599 100644 --- a/badger/cmd/restore.go +++ b/badger/cmd/restore.go @@ -68,7 +68,7 @@ func doRestore(cmd *cobra.Command, args []string) error { // Open DB db, err := badger.Open(badger.DefaultOptions(sstDir). WithValueDir(vlogDir). - WithNumVersionsToKeep(int(math.MaxUint32))) + WithNumVersionsToKeep(int(math.MaxInt32))) if err != nil { return err } From 5077e99776e7fd7ec59789d082d038e108b78e83 Mon Sep 17 00:00:00 2001 From: gammazero Date: Fri, 25 Sep 2020 17:30:52 -0700 Subject: [PATCH 5/6] remove unneeded cast --- badger/cmd/backup.go | 2 +- badger/cmd/restore.go | 2 +- value.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/badger/cmd/backup.go b/badger/cmd/backup.go index ed3688c71..7d8b38e64 100644 --- a/badger/cmd/backup.go +++ b/badger/cmd/backup.go @@ -55,7 +55,7 @@ func doBackup(cmd *cobra.Command, args []string) error { opt := badger.DefaultOptions(sstDir). WithValueDir(vlogDir). WithTruncate(truncate). - WithNumVersionsToKeep(int(math.MaxInt32)) + WithNumVersionsToKeep(math.MaxInt32) if numVersions > 0 { opt.NumVersionsToKeep = numVersions diff --git a/badger/cmd/restore.go b/badger/cmd/restore.go index 899403599..0c32f9dfd 100644 --- a/badger/cmd/restore.go +++ b/badger/cmd/restore.go @@ -68,7 +68,7 @@ func doRestore(cmd *cobra.Command, args []string) error { // Open DB db, err := badger.Open(badger.DefaultOptions(sstDir). WithValueDir(vlogDir). - WithNumVersionsToKeep(int(math.MaxInt32))) + WithNumVersionsToKeep(math.MaxInt32)) if err != nil { return err } diff --git a/value.go b/value.go index d001f1fd7..f69678b72 100644 --- a/value.go +++ b/value.go @@ -48,7 +48,7 @@ import ( // maxVlogFileSize is the maximum size of the vlog file which can be created. Vlog Offset is of // uint32, so limiting at max uint32. -var maxVlogFileSize = uint32(math.MaxUint32) +var maxVlogFileSize = int64(math.MaxUint32) // Values have their first byte being byteData or byteDelete. This helps us distinguish between // a key that has never been seen and a key that has been explicitly deleted. From 8163afd2cfd4529a2457f4cad73c5882761e6797 Mon Sep 17 00:00:00 2001 From: Andrew Gillis Date: Mon, 28 Sep 2020 10:47:32 -0700 Subject: [PATCH 6/6] Update value.go Co-authored-by: Ibrahim Jarif --- value.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/value.go b/value.go index f69678b72..1bc03d705 100644 --- a/value.go +++ b/value.go @@ -48,7 +48,7 @@ import ( // maxVlogFileSize is the maximum size of the vlog file which can be created. Vlog Offset is of // uint32, so limiting at max uint32. -var maxVlogFileSize = int64(math.MaxUint32) +var maxVlogFileSize uint32 = math.MaxUint32 // Values have their first byte being byteData or byteDelete. This helps us distinguish between // a key that has never been seen and a key that has been explicitly deleted.