Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.25
FROM golang:1.26

WORKDIR /app
COPY ../go.mod go.sum ./
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion bin/go
2 changes: 1 addition & 1 deletion bin/gofmt
2 changes: 1 addition & 1 deletion bin/golangci-lint
10 changes: 4 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/block/polt

go 1.25.3

toolchain go1.25.6
go 1.26.1

require (
github.com/alecthomas/kong v0.8.0
Expand All @@ -14,13 +12,13 @@ require (
github.com/pingcap/tidb/pkg/parser v0.0.0-20250811102254-4230cf349b01
github.com/siddontang/loggers v1.0.3
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.10.0
github.com/stretchr/testify v1.11.1
golang.org/x/sync v0.16.0
)

require (
filippo.io/edwards25519 v1.1.0 // indirect
github.com/block/spirit v0.10.1
filippo.io/edwards25519 v1.1.1 // indirect
github.com/block/spirit v0.12.1-0.20260414195601-d7c75c14cdfa
github.com/rogpeppe/go-internal v1.11.0 // indirect
)

Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
filippo.io/edwards25519 v1.1.1 h1:YpjwWWlNmGIDyXOn8zLzqiD+9TyIlPhGFG96P39uBpw=
filippo.io/edwards25519 v1.1.1/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c h1:RGWPOewvKIROun94nF7v2cua9qP+thov/7M50KEoeSU=
github.com/JohnCGriffin/overflow v0.0.0-20211019200055-46fa312c352c/go.mod h1:X0CRv0ky0k6m906ixxpzmDRLvX58TFUKS2eePweuyxk=
github.com/alecthomas/assert/v2 v2.1.0 h1:tbredtNcQnoSd3QBhQWI7QZ3XHOVkw1Moklp2ojoH/0=
Expand Down Expand Up @@ -51,8 +51,8 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.33.9/go.mod h1:f6vjfZER1M17Fokn0Izss
github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro=
github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/block/spirit v0.10.1 h1:JTr5E7gKV3TUx3qX6ftflOk14dEf08pQQhATEigvJQM=
github.com/block/spirit v0.10.1/go.mod h1:lruAfWdjVMrcTem3sMIKVwvcYqDmHlf5Jsz2g/mE+ME=
github.com/block/spirit v0.12.1-0.20260414195601-d7c75c14cdfa h1:zRECYJxIaAn8WEkvWn7/efGeJ8IisaKr+mjtWwLqs8M=
github.com/block/spirit v0.12.1-0.20260414195601-d7c75c14cdfa/go.mod h1:TpxEit7CjSLSrhDG21K5ORu3abMED5OipGLDAadjX5Y=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -123,8 +123,8 @@ github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/xyproto/randomstring v1.0.5 h1:YtlWPoRdgMu3NZtP45drfy1GKoojuR7hmRcnhZqKjWU=
github.com/xyproto/randomstring v1.0.5/go.mod h1:rgmS5DeNXLivK7YprL0pY+lTuhNQW3iGxZ18UQApw/E=
github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ=
Expand Down
4 changes: 2 additions & 2 deletions pkg/archive/buffer_stager.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewBufferStager(sconfig *stage.StagerConfig, chkPt *audit.Checkpoint, schem
}

var totalRows int
err = b.db.QueryRow("SELECT COUNT(*) FROM " + b.srcTbl.QuotedName).Scan(&totalRows)
err = b.db.QueryRow("SELECT COUNT(*) FROM " + b.srcTbl.QuotedTableName).Scan(&totalRows)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -148,7 +148,7 @@ func (b *BufferStager) RetryableStageChunk(ctx context.Context, chunk *table.Chu
func (b *BufferStager) stageChunk(ctx context.Context, chunk *table.Chunk) (int64, error) {
var err error

copyChunkQuery := fmt.Sprintf("SELECT * FROM %s where %s LOCK IN SHARE MODE", b.srcTbl.QuotedName, chunk.String())
copyChunkQuery := fmt.Sprintf("SELECT * FROM %s where %s LOCK IN SHARE MODE", b.srcTbl.QuotedTableName, chunk.String())
b.logger.Infof("\nrunning chunk: %s, copyChunkQuery: %s", chunk.String(), copyChunkQuery)
rows, err := b.db.QueryContext(ctx, copyChunkQuery)
if err != nil {
Expand Down
17 changes: 2 additions & 15 deletions pkg/audit/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"

"github.com/block/spirit/pkg/dbconn"
"github.com/block/spirit/pkg/table"
)

const RunsTblName = "runs"
Expand Down Expand Up @@ -51,21 +50,9 @@ func CreateDB(ctx context.Context, db *sql.DB, auditDB string) error {
}

func CreateRunsTbl(ctx context.Context, db *sql.DB, auditDB string) error {
err := dbconn.Exec(ctx, db, RunsTblCreateStmt, auditDB, RunsTblName)
if err != nil {
return err
}
runsTable := table.NewTableInfo(db, auditDB, RunsTblName)

return runsTable.SetInfo(ctx)
return dbconn.Exec(ctx, db, RunsTblCreateStmt, auditDB, RunsTblName)
}

func CreateCheckpointTbl(ctx context.Context, db *sql.DB, auditDB string, runID string) error {
err := dbconn.Exec(ctx, db, checkPointTblCreateStmt, auditDB, CheckPtsTblName(runID))
if err != nil {
return err
}
chkptTable := table.NewTableInfo(db, auditDB, CheckPtsTblName(runID))

return chkptTable.SetInfo(ctx)
return dbconn.Exec(ctx, db, checkPointTblCreateStmt, auditDB, CheckPtsTblName(runID))
}
14 changes: 7 additions & 7 deletions pkg/stage/stager.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ func NewStager(sconfig *StagerConfig, chk *audit.Checkpoint) (*Stager, error) {
stageTbl: sconfig.StageTbl,
dryRun: sconfig.DryRun,
}
_, isCovIdx, err := query.GetIndex("SELECT COUNT(*) FROM "+s.srcTbl.QuotedName+" WHERE "+sconfig.Where, sconfig.DB)
_, isCovIdx, err := query.GetIndex("SELECT COUNT(*) FROM "+s.srcTbl.QuotedTableName+" WHERE "+sconfig.Where, sconfig.DB)
if err != nil {
return s, err
}
if isCovIdx {
s.estimates = true
err = s.db.QueryRow("SELECT COUNT(*) FROM " + s.srcTbl.QuotedName + " WHERE " + sconfig.Where).Scan(&s.totalRows)
err = s.db.QueryRow("SELECT COUNT(*) FROM " + s.srcTbl.QuotedTableName + " WHERE " + sconfig.Where).Scan(&s.totalRows)
if err != nil {
return s, err
}
Expand Down Expand Up @@ -224,12 +224,12 @@ func (s *Stager) stageChunk(ctx context.Context, tx *sql.Tx, chunk *table.Chunk)
// Use NonGeneratedColumns to exclude generated columns from INSERT
// Generated columns cannot be explicitly inserted, they are computed automatically
insertChunkQuery := fmt.Sprintf("INSERT IGNORE INTO %s (%s,%s) SELECT %s,%d FROM %s FORCE INDEX (%s) WHERE %s LOCK IN SHARE MODE",
s.stageTbl.QuotedName,
s.stageTbl.QuotedTableName,
strings.Join(s.srcTbl.NonGeneratedColumns, ", "),
boot.TryNumColName,
strings.Join(s.srcTbl.NonGeneratedColumns, ", "),
s.tryNum,
s.srcTbl.QuotedName,
s.srcTbl.QuotedTableName,
s.key,
chunk.String(),
)
Expand Down Expand Up @@ -260,7 +260,7 @@ func (s *Stager) stageChunk(ctx context.Context, tx *sql.Tx, chunk *table.Chunk)
// Delete the chunk, if not dry-run
if !s.dryRun {
deleteChunkQuery := fmt.Sprintf("DELETE FROM %s WHERE %s",
s.srcTbl.QuotedName,
s.srcTbl.QuotedTableName,
chunk.String(),
)
_, err = tx.ExecContext(ctx, deleteChunkQuery)
Expand Down Expand Up @@ -309,7 +309,7 @@ func (s *Stager) RetryableStageChunk(ctx context.Context, chunk *table.Chunk) er
func (s *Stager) checksumMatch(ctx context.Context, tx *sql.Tx, chunk *table.Chunk) error {
source := fmt.Sprintf("SELECT BIT_XOR(CRC32(CONCAT(%s))) as checksum FROM %s WHERE %s",
strings.Join(s.srcTbl.Columns, ", "),
s.srcTbl.QuotedName,
s.srcTbl.QuotedTableName,
chunk.String(),
)
// Filter the rows on the target/stage table to only the rows that were
Expand All @@ -320,7 +320,7 @@ func (s *Stager) checksumMatch(ctx context.Context, tx *sql.Tx, chunk *table.Chu
// only.
target := fmt.Sprintf("SELECT BIT_XOR(CRC32(CONCAT(%s))) as checksum FROM %s WHERE %s AND try_num=%d",
strings.Join(s.srcTbl.Columns, ", "),
s.stageTbl.QuotedName,
s.stageTbl.QuotedTableName,
chunk.String(),
s.tryNum,
)
Expand Down
Loading