Skip to content

Modernize bis#404

Open
simondeziel wants to merge 15 commits intocanonical:v3from
simondeziel:modernize-bis
Open

Modernize bis#404
simondeziel wants to merge 15 commits intocanonical:v3from
simondeziel:modernize-bis

Conversation

@simondeziel
Copy link
Copy Markdown
Member

@simondeziel simondeziel commented Sep 7, 2025

Goes hand in hand with canonical/dqlite-ppa#13 now that Focal/20.04 and newer have a golang-1.22-go package available.

This is a reworked version of #396 but that keeps the same OS compatibility (Focal and up).

Also superseds #395 (mattn/go-sqlite3 update).

@simondeziel simondeziel force-pushed the modernize-bis branch 3 times, most recently from 9da4644 to e2d3d84 Compare September 7, 2025 21:24
@simondeziel simondeziel marked this pull request as ready for review September 7, 2025 22:18
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
```
go get -t -v -u ./...   # Update gomod dependencies

go get golang.org/x/sync@v0.11.0  # Pin to last version supporting old Go, later need 1.23+

go get github.com/mattn/go-sqlite3@v1.14.32
go get github.com/stretchr/testify@v1.11.1

go mod tidy -go=1.22.2  # Enforce minimum Go version

go get toolchain@none   # Use the bundled toolchain that meets the minimum Go version
```

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
…eadAll()`

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Copy link
Copy Markdown
Collaborator

@marco6 marco6 left a comment

Choose a reason for hiding this comment

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

Hi @simondeziel! Thanks for this. Few comments below

Comment thread app/app_test.go
t.Helper()

dir, err := ioutil.TempDir("", "dqlite-app-test-")
dir, err := os.MkdirTemp("", "dqlite-app-test-")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

While modernizing I think we should get rid of this function altogether. Go now has (*T).TempDir which is the better equivalent of this function.

In this sense, it also has (*T).Cleanup which should be used everywhere instead of returning a cleanup function (for example in newAppWithNoTLS).

Comment thread app/roles.go
for node, metadata := range c.State {
if node.Role == role && metadata != nil == online {
if domains == nil || (domains != nil && domains[metadata.FailureDomain]) {
if domains == nil || domains[metadata.FailureDomain] {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This line still has a problem as metadata can bi nil in case online is false

@@ -22,7 +21,7 @@ const (
func bmSetup(t *testing.T, addr string, join []string) (string, *app.App, *sql.DB, func()) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same comment as in the other test. We now have a way for helper functions to register cleanups. In the case of temp dirs, it's even easier. Let's use those features and simplify the flow here.

Comment thread client/client_test.go
t.Helper()

dir, err := ioutil.TempDir("", "dqlite-replication-test-")
dir, err := os.MkdirTemp("", "dqlite-replication-test-")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same as other temp dir stuff.

duration := backoffFunc(attempt)
// Duration might be negative in case of integer overflow.
if !(0 < duration && duration <= cap) {
if 0 >= duration || duration > cap {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

While not a big deal, is there a reason for this change?

slot := r.message.lastByte()
if slot == 0xee {
switch slot {
case 0xee:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can we name these value as constants given that we are changing this code?

Something like:

const rowsPartMarker = 0xEE;
const rowsDoneMarker = 0xFF;

@marco6
Copy link
Copy Markdown
Collaborator

marco6 commented Sep 12, 2025

Also @simondeziel, somehow, don't know why the CLA Check is failing. Could you check why? The other PR went through...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants