Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - prune active set from ballot blob #5032

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ In order to enable provide following configuration:
Ephemeral data are deleted and state compacted at the time of upgrade. In steady-state, data is pruned periodically.
* [#5021](https://github.com/spacemeshos/go-spacemesh/pull/5021) Drop support for old certificate sync protocol.
* [#5024](https://github.com/spacemeshos/go-spacemesh/pull/5024) Active set will be saved in state separately from ballots.
* [#5032](https://github.com/spacemeshos/go-spacemesh/pull/5032) Ativeset data pruned from ballots.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should put a bit more data about this. e.g expected time and amount of storage required to perform this migration (e.g. WAL is the size of database right?) . we can do that after benchmarking in cloud

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. WAL will be the size of the pre-vacuumed db (it's being used as a tmp storage during vacuum).
will update after testing.

* [#5035](https://github.com/spacemeshos/go-spacemesh/pull/5035) Fix possible nil pointer panic when node fails to persist nipost builder state.

## v1.1.5
Expand Down
10 changes: 5 additions & 5 deletions sql/ballots/util/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"errors"
"fmt"

"github.com/spacemeshos/go-spacemesh/codec"
"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/log"
"github.com/spacemeshos/go-spacemesh/sql"
Expand Down Expand Up @@ -42,11 +43,10 @@
} else if err == nil {
unique++
}
// TODO: prune ballot active set after migration 4 is released
//b.ActiveSet = nil
//if err := ballots.UpdateBlob(db, b.ID(), codec.MustEncode(b)); err != nil {
// return fmt.Errorf("update ballot %s: %w", b.ID().String(), err)
//}
b.ActiveSet = nil
if err := ballots.UpdateBlob(db, b.ID(), codec.MustEncode(b)); err != nil {
return fmt.Errorf("update ballot %s: %w", b.ID().String(), err)
}

Check warning on line 49 in sql/ballots/util/extract.go

View check run for this annotation

Codecov / codecov/patch

sql/ballots/util/extract.go#L48-L49

Added lines #L48 - L49 were not covered by tests
extracted++
}
}
Expand Down
4 changes: 1 addition & 3 deletions sql/ballots/util/extract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ func TestExtractActiveSet(t *testing.T) {
for _, b := range blts {
got, err := ballots.Get(db, b.ID())
require.NoError(t, err)
if b.Layer%3 != 2 {
require.NotEmpty(t, got.ActiveSet)
}
require.Nil(t, got.ActiveSet)
}
for i, h := range hashes {
got, err := activesets.Get(db, h)
Expand Down
8 changes: 2 additions & 6 deletions sql/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,8 @@ func Open(uri string, opts ...Opt) (*Database, error) {
if err != nil {
return nil, err
}
after, err := version(db)
if err != nil {
return nil, err
}
if before <= 4 && after == 5 && config.v5Migration != nil {
// v5 migration (active set extraction) needs the 4rd migration to execute first
if before <= 4 && config.v5Migration != nil {
// v5 migration (active set extraction) needs the 3rd migration to execute first
if err := config.v5Migration(db); err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion sql/migrations/0004_v1.1.7.sql
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CREATE INDEX ballots_by_atx_by_layer ON ballots (atx, layer asc);
CREATE INDEX ballots_by_atx_by_layer ON ballots (atx, layer asc);
2 changes: 1 addition & 1 deletion sql/migrations/0005_next.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
DELETE FROM proposals;
DELETE FROM proposal_transactions;
UPDATE certificates SET cert = NULL WHERE layer < 19000;
UPDATE certificates SET cert = NULL WHERE layer < 20000;