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

[no-release-notes] Change some tests to use t.TempDir instead of os.TempDir so that their temporary files get cleaned up. #8792

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
41fe1ac
[no-release-notes] Change some tests to use t.TempDir instead of os.T…
reltuk Jan 25, 2025
742f276
go/cmd/dolt: signed_commits_test.go: Try to close DoltDBs so that win…
reltuk Jan 28, 2025
be448ee
go/cmd/dolt: signed_commits_test.go: Try a different way to cleanup t…
reltuk Jan 28, 2025
98547ce
Bug fix: fixing ref conflict case that can cause tags to be temporari…
fulghum Jan 24, 2025
2e8fded
Fixing a merge error that included the env section twice
fulghum Jan 24, 2025
f9affcc
[ga-bump-release] Update Dolt version to 1.47.2 and release v1.47.2
coffeegoddd Jan 24, 2025
bd8c834
[ga-bump-dep] Bump dependency in Dolt by jycor (#8790)
coffeegoddd Jan 27, 2025
cce2336
Add the dirty column to the dolt_branches system table
macneale4 Jan 27, 2025
ecea68c
Tests for the dolt_branches dirty column
macneale4 Jan 27, 2025
4bda2e4
[ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/upda…
macneale4 Jan 27, 2025
ccb34c4
Fix workbench tests to expect dirty column
macneale4 Jan 27, 2025
7f7f2c6
Don't error out when no workingset is found
macneale4 Jan 27, 2025
83bbd17
[ga-bump-release] Update Dolt version to 1.48.0 and release v1.48.0
coffeegoddd Jan 28, 2025
8f25c11
go/store/nbs: store.go: Add a mechanism to bracket outstanding read r…
reltuk Jan 15, 2025
1f4b487
go/store/nbs: chunkReader,chunkSource: GC: Add the ability to take de…
reltuk Jan 15, 2025
2f47ac2
go/store/nbs: Add GC keeper calls on reads through NomsBlockStore.
reltuk Jan 16, 2025
7c06b6b
go/store/nbs: tablePersister: Add GC dependency capturing to written …
reltuk Jan 16, 2025
8a5689e
go/store/nbs: table_set: append: Thread GC dependency tracking throug…
reltuk Jan 16, 2025
f69f4a4
go/store/nbs: store.go: MarkAndSweepChunks: After adding read trackin…
reltuk Jan 16, 2025
de5c178
repofmt.sh.
reltuk Jan 16, 2025
bba09b1
go/store/nbs: store.go: Fix errgroup context usage-after-Wait bug in …
reltuk Jan 23, 2025
c2ec3de
go: binlogreplication: Add Session{{Begin,End}Command,End} lifecycle …
reltuk Jan 28, 2025
09816e3
go: cmd/dolt: sqlengine: Actually call DoltBinlogReplicaController.Cl…
reltuk Jan 28, 2025
6f6207b
[ga-bump-dep] Bump dependency in Dolt by zachmu
zachmu Jan 28, 2025
c8e47a8
go/store/nbs: generational_chunk_store.go: In GCMode_Full, also take …
reltuk Jan 28, 2025
872f8d9
/go/libraries/doltcore/env/actions: make iter resolved tags paginated…
coffeegoddd Jan 21, 2025
a80e71b
/go/libraries/doltcore/env/actions/tag.go: reinstage iterresolved tag…
coffeegoddd Jan 30, 2025
d4dd7aa
[ga-bump-dep] Bump dependency in Dolt by Hydrocharged
Hydrocharged Jan 31, 2025
72ec11f
Include deleteErr message in returned error.
fulghum Jan 31, 2025
eed637b
go: store/types: Fix dolt_gc on databases that use vector indexes.
reltuk Jan 30, 2025
d3b9e44
go: sqlserver: Clean up how remotesrv gets a handle to the mrEnv.File…
reltuk Jan 28, 2025
86acc8c
go: sqle,remotesrv: Implement sql.Session lifecycle callbacks for sql…
reltuk Jan 28, 2025
ff7aebb
Fix typo in error message.
reltuk Jan 30, 2025
29cb66e
go/cmd/dolt/commands: Declare bankruptcy on signed commit test for now.
reltuk Jan 31, 2025
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: 0 additions & 2 deletions .github/workflows/ci-check-repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ jobs:
cwd: "."
pull: "--ff"
- name: Check generated protobufs
env:
USE_BAZEL_VERSION: 7.4.0
working-directory: ./proto
env:
USE_BAZEL_VERSION: 7.4.0
Expand Down
10 changes: 10 additions & 0 deletions go/cmd/dolt/commands/engine/sqlengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/statspro"
"github.com/dolthub/dolt/go/libraries/doltcore/sqle/writer"
"github.com/dolthub/dolt/go/libraries/utils/config"
"github.com/dolthub/dolt/go/libraries/utils/filesys"
)

// SqlEngine packages up the context necessary to run sql queries against dsqle.
Expand All @@ -55,6 +56,7 @@ type SqlEngine struct {
contextFactory contextFactory
dsessFactory sessionFactory
engine *gms.Engine
fs filesys.Filesys
}

type sessionFactory func(mysqlSess *sql.BaseSession, pro sql.DatabaseProvider) (*dsess.DoltSession, error)
Expand Down Expand Up @@ -194,6 +196,7 @@ func NewSqlEngine(
sqlEngine.contextFactory = sqlContextFactory()
sqlEngine.dsessFactory = sessFactory
sqlEngine.engine = engine
sqlEngine.fs = pro.FileSystem()

// configuring stats depends on sessionBuilder
// sessionBuilder needs ref to statsProv
Expand Down Expand Up @@ -314,8 +317,15 @@ func (se *SqlEngine) GetUnderlyingEngine() *gms.Engine {
return se.engine
}

func (se *SqlEngine) FileSystem() filesys.Filesys {
return se.fs
}

func (se *SqlEngine) Close() error {
if se.engine != nil {
if se.engine.Analyzer.Catalog.BinlogReplicaController != nil {
dblr.DoltBinlogReplicaController.Close()
}
return se.engine.Close()
}
return nil
Expand Down
13 changes: 10 additions & 3 deletions go/cmd/dolt/commands/sqlserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,21 +559,27 @@ func ConfigureServices(
}

listenaddr := fmt.Sprintf(":%d", port)
sqlContextInterceptor := sqle.SqlContextServerInterceptor{
Factory: sqlEngine.NewDefaultContext,
}
args := remotesrv.ServerArgs{
Logger: logrus.NewEntry(lgr),
ReadOnly: apiReadOnly || serverConfig.ReadOnly(),
HttpListenAddr: listenaddr,
GrpcListenAddr: listenaddr,
ConcurrencyControl: remotesapi.PushConcurrencyControl_PUSH_CONCURRENCY_CONTROL_ASSERT_WORKING_SET,
Options: sqlContextInterceptor.Options(),
HttpInterceptor: sqlContextInterceptor.HTTP(nil),
}
var err error
args.FS, args.DBCache, err = sqle.RemoteSrvFSAndDBCache(sqlEngine.NewDefaultContext, sqle.DoNotCreateUnknownDatabases)
args.FS = sqlEngine.FileSystem()
args.DBCache, err = sqle.RemoteSrvDBCache(sqle.GetInterceptorSqlContext, sqle.DoNotCreateUnknownDatabases)
if err != nil {
lgr.Errorf("error creating SQL engine context for remotesapi server: %v", err)
return err
}

authenticator := newAccessController(sqlEngine.NewDefaultContext, sqlEngine.GetUnderlyingEngine().Analyzer.Catalog.MySQLDb)
authenticator := newAccessController(sqle.GetInterceptorSqlContext, sqlEngine.GetUnderlyingEngine().Analyzer.Catalog.MySQLDb)
args = sqle.WithUserPasswordAuth(args, authenticator)
args.TLSConfig = serverConf.TLSConfig

Expand Down Expand Up @@ -621,6 +627,7 @@ func ConfigureServices(
lgr.Errorf("error creating SQL engine context for remotesapi server: %v", err)
return err
}
args.FS = sqlEngine.FileSystem()

clusterRemoteSrvTLSConfig, err := LoadClusterTLSConfig(serverConfig.ClusterConfig())
if err != nil {
Expand All @@ -634,7 +641,7 @@ func ConfigureServices(
lgr.Errorf("error creating remotesapi server on port %d: %v", *serverConfig.RemotesapiPort(), err)
return err
}
clusterController.RegisterGrpcServices(sqlEngine.NewDefaultContext, clusterRemoteSrv.srv.GrpcServer())
clusterController.RegisterGrpcServices(sqle.GetInterceptorSqlContext, clusterRemoteSrv.srv.GrpcServer())

clusterRemoteSrv.lis, err = clusterRemoteSrv.srv.Listeners()
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/dolt/doltversion/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
package doltversion

const (
Version = "1.47.1"
Version = "1.48.0"
)
2 changes: 1 addition & 1 deletion go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0
github.com/creasty/defaults v1.6.0
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
github.com/dolthub/go-mysql-server v0.19.1-0.20250123004221-f5a5bcea7eed
github.com/dolthub/go-mysql-server v0.19.1-0.20250131110511-67aa2a430366
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63
github.com/dolthub/swiss v0.1.0
github.com/esote/minmaxheap v1.0.0
Expand Down
4 changes: 2 additions & 2 deletions go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U=
github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0=
github.com/dolthub/go-icu-regex v0.0.0-20241215010122-db690dd53c90 h1:Sni8jrP0sy/w9ZYXoff4g/ixe+7bFCZlfCqXKJSU+zM=
github.com/dolthub/go-icu-regex v0.0.0-20241215010122-db690dd53c90/go.mod h1:ylU4XjUpsMcvl/BKeRRMXSH7e7WBrPXdSLvnRJYrxEA=
github.com/dolthub/go-mysql-server v0.19.1-0.20250123004221-f5a5bcea7eed h1:2EQHWtMkjyN/SNfbg/nh/a0RANq8V8gxNynYum2Kq+s=
github.com/dolthub/go-mysql-server v0.19.1-0.20250123004221-f5a5bcea7eed/go.mod h1:jYEJ8tNkA7K3k39X8iMqaX3MSMmViRgh222JSLHDgVc=
github.com/dolthub/go-mysql-server v0.19.1-0.20250131110511-67aa2a430366 h1:pJ+upgX6hrhyqgpkmk9Ye9lIPSualMHZcUMs8kWknV4=
github.com/dolthub/go-mysql-server v0.19.1-0.20250131110511-67aa2a430366/go.mod h1:jYEJ8tNkA7K3k39X8iMqaX3MSMmViRgh222JSLHDgVc=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=
Expand Down
8 changes: 4 additions & 4 deletions go/libraries/doltcore/doltdb/commit_hooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestPushOnWriteHook(t *testing.T) {
ctx := context.Background()

// destination repo
testDir, err := test.ChangeToTestDir("TestReplicationDest")
testDir, err := test.ChangeToTestDir(t.TempDir(), "TestReplicationDest")

if err != nil {
panic("Couldn't change the working directory to the test directory.")
Expand All @@ -62,7 +62,7 @@ func TestPushOnWriteHook(t *testing.T) {
destDB, _ := LoadDoltDB(context.Background(), types.Format_Default, LocalDirDoltDB, filesys.LocalFS)

// source repo
testDir, err = test.ChangeToTestDir("TestReplicationSource")
testDir, err = test.ChangeToTestDir(t.TempDir(), "TestReplicationSource")

if err != nil {
panic("Couldn't change the working directory to the test directory.")
Expand Down Expand Up @@ -183,7 +183,7 @@ func TestAsyncPushOnWrite(t *testing.T) {
ctx := context.Background()

// destination repo
testDir, err := test.ChangeToTestDir("TestReplicationDest")
testDir, err := test.ChangeToTestDir(t.TempDir(), "TestReplicationDest")

if err != nil {
panic("Couldn't change the working directory to the test directory.")
Expand All @@ -202,7 +202,7 @@ func TestAsyncPushOnWrite(t *testing.T) {
destDB, _ := LoadDoltDB(context.Background(), types.Format_Default, LocalDirDoltDB, filesys.LocalFS)

// source repo
testDir, err = test.ChangeToTestDir("TestReplicationSource")
testDir, err = test.ChangeToTestDir(t.TempDir(), "TestReplicationSource")

if err != nil {
panic("Couldn't change the working directory to the test directory.")
Expand Down
6 changes: 3 additions & 3 deletions go/libraries/doltcore/doltdb/doltdb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func TestEmptyInMemoryRepoCreation(t *testing.T) {
}

func TestLoadNonExistentLocalFSRepo(t *testing.T) {
_, err := test.ChangeToTestDir("TestLoadRepo")
_, err := test.ChangeToTestDir(t.TempDir(), "TestLoadRepo")

if err != nil {
panic("Couldn't change the working directory to the test directory.")
Expand All @@ -231,7 +231,7 @@ func TestLoadNonExistentLocalFSRepo(t *testing.T) {
}

func TestLoadBadLocalFSRepo(t *testing.T) {
testDir, err := test.ChangeToTestDir("TestLoadRepo")
testDir, err := test.ChangeToTestDir(t.TempDir(), "TestLoadRepo")

if err != nil {
panic("Couldn't change the working directory to the test directory.")
Expand All @@ -246,7 +246,7 @@ func TestLoadBadLocalFSRepo(t *testing.T) {
}

func TestLDNoms(t *testing.T) {
testDir, err := test.ChangeToTestDir("TestLoadRepo")
testDir, err := test.ChangeToTestDir(t.TempDir(), "TestLoadRepo")

if err != nil {
panic("Couldn't change the working directory to the test directory.")
Expand Down
8 changes: 1 addition & 7 deletions go/libraries/doltcore/dtestutils/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package dtestutils

import (
"context"
"os"
"path/filepath"

"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
Expand All @@ -41,12 +40,7 @@ func CreateTestEnv() *env.DoltEnv {
// CreateTestEnvForLocalFilesystem creates a new DoltEnv for testing, using a local FS, instead of an in-memory
// filesystem, for persisting files. This is useful for tests that require a disk-based filesystem and will not
// work correctly with an in-memory filesystem and in-memory blob store (e.g. dolt_undrop() tests).
func CreateTestEnvForLocalFilesystem() *env.DoltEnv {
tempDir, err := os.MkdirTemp(os.TempDir(), "dolt-*")
if err != nil {
panic(err)
}

func CreateTestEnvForLocalFilesystem(tempDir string) *env.DoltEnv {
fs, err := filesys.LocalFilesysWithWorkingDir(tempDir)
if err != nil {
panic(err)
Expand Down
8 changes: 2 additions & 6 deletions go/libraries/doltcore/dtestutils/sql_server_driver/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,9 @@ type DoltUser struct {
var _ DoltCmdable = DoltUser{}
var _ DoltDebuggable = DoltUser{}

func NewDoltUser() (DoltUser, error) {
tmpdir, err := os.MkdirTemp("", "go-sql-server-driver-")
if err != nil {
return DoltUser{}, err
}
func NewDoltUser(tmpdir string) (DoltUser, error) {
res := DoltUser{tmpdir}
err = res.DoltExec("config", "--global", "--add", "metrics.disabled", "true")
err := res.DoltExec("config", "--global", "--add", "metrics.disabled", "true")
if err != nil {
return DoltUser{}, err
}
Expand Down
101 changes: 91 additions & 10 deletions go/libraries/doltcore/env/actions/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"github.com/dolthub/dolt/go/store/datas"
)

const DefaultPageSize = 100

type TagProps struct {
TaggerName string
TaggerEmail string
Expand Down Expand Up @@ -97,6 +99,30 @@ func DeleteTagsOnDB(ctx context.Context, ddb *doltdb.DoltDB, tagNames ...string)
return nil
}

// IterUnresolvedTags iterates over tags in dEnv.DoltDB, and calls cb() for each with an unresolved Tag.
func IterUnresolvedTags(ctx context.Context, ddb *doltdb.DoltDB, cb func(tag *doltdb.TagResolver) (stop bool, err error)) error {
tagRefs, err := ddb.GetTags(ctx)
if err != nil {
return err
}

tagResolvers, err := ddb.GetTagResolvers(ctx, tagRefs)
if err != nil {
return err
}

for _, tagResolver := range tagResolvers {
stop, err := cb(&tagResolver)
if err != nil {
return err
}
if stop {
break
}
}
return nil
}

// IterResolvedTags iterates over tags in dEnv.DoltDB from newest to oldest, resolving the tag to a commit and calling cb().
func IterResolvedTags(ctx context.Context, ddb *doltdb.DoltDB, cb func(tag *doltdb.Tag) (stop bool, err error)) error {
tagRefs, err := ddb.GetTags(ctx)
Expand Down Expand Up @@ -138,26 +164,81 @@ func IterResolvedTags(ctx context.Context, ddb *doltdb.DoltDB, cb func(tag *dolt
return nil
}

// IterUnresolvedTags iterates over tags in dEnv.DoltDB, and calls cb() for each with an unresovled Tag.
func IterUnresolvedTags(ctx context.Context, ddb *doltdb.DoltDB, cb func(tag *doltdb.TagResolver) (stop bool, err error)) error {
// IterResolvedTagsPaginated iterates over tags in dEnv.DoltDB in their default lexicographical order, resolving the tag to a commit and calling cb().
// Returns the next tag name if there are more results available.
func IterResolvedTagsPaginated(ctx context.Context, ddb *doltdb.DoltDB, startTag string, cb func(tag *doltdb.Tag) (stop bool, err error)) (string, error) {
// tags returned here are sorted lexicographically
tagRefs, err := ddb.GetTags(ctx)
if err != nil {
return err
return "", err
}

tagResolvers, err := ddb.GetTagResolvers(ctx, tagRefs)
if err != nil {
return err
// find starting index based on start tag
startIdx := 0
if startTag != "" {
for i, tr := range tagRefs {
if tr.GetPath() == startTag {
startIdx = i + 1 // start after the given tag
break
}
}
}

for _, tagResolver := range tagResolvers {
stop, err := cb(&tagResolver)
// get page of results
endIdx := startIdx + DefaultPageSize
if endIdx > len(tagRefs) {
endIdx = len(tagRefs)
}

pageTagRefs := tagRefs[startIdx:endIdx]

// resolve tags for this page
for _, tr := range pageTagRefs {
tag, err := ddb.ResolveTag(ctx, tr.(ref.TagRef))
if err != nil {
return err
return "", err
}

stop, err := cb(tag)
if err != nil {
return "", err
}

if stop {
break
}
}
return nil

// return next tag name if there are more results
if endIdx < len(tagRefs) {
lastTag := pageTagRefs[len(pageTagRefs)-1]
return lastTag.GetPath(), nil
}

return "", nil
}

// VisitResolvedTag iterates over tags in ddb until the given tag name is found, then calls cb() with the resolved tag.
func VisitResolvedTag(ctx context.Context, ddb *doltdb.DoltDB, tagName string, cb func(tag *doltdb.Tag) error) error {
tagRefs, err := ddb.GetTags(ctx)
if err != nil {
return err
}

for _, r := range tagRefs {
tr, ok := r.(ref.TagRef)
if !ok {
return fmt.Errorf("DoltDB.GetTags() returned non-tag DoltRef")
}

if tr.GetPath() == tagName {
tag, err := ddb.ResolveTag(ctx, tr)
if err != nil {
return err
}
return cb(tag)
}
}

return doltdb.ErrTagNotFound
}
Loading
Loading