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

Fix errcheck in ./common/persistence/ #3743

Merged
merged 1 commit into from
Dec 21, 2022
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
1 change: 1 addition & 0 deletions common/persistence/dataInterfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -1044,6 +1044,7 @@ type (
}

// Closeable is an interface for any entity that supports a close operation to release resources
// TODO: allow this method to return errors
Copy link
Member

Choose a reason for hiding this comment

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

It might not be easy :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing worth having comes easy!

Closeable interface {
Close()
}
Expand Down
5 changes: 4 additions & 1 deletion common/persistence/sql/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ func (m *SqlStore) GetName() string {

func (m *SqlStore) Close() {
if m.Db != nil {
m.Db.Close()
err := m.Db.Close()
if err != nil {
m.logger.Error("Error closing SQL database", tag.Error(err))
}
}
}

Expand Down
21 changes: 16 additions & 5 deletions common/persistence/tests/sqlite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"path"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"

"go.temporal.io/server/common/config"
Expand Down Expand Up @@ -179,7 +180,9 @@ func TestSQLiteTaskQueueTaskSuite(t *testing.T) {
func TestSQLiteFileExecutionMutableStateStoreSuite(t *testing.T) {
cfg := NewSQLiteFileConfig()
SetupSQLiteDatabase(cfg)
defer os.Remove(cfg.DatabaseName)
defer func() {
assert.NoError(t, os.Remove(cfg.DatabaseName))
}()
logger := log.NewNoopLogger()
factory := sql.NewFactory(
*cfg,
Expand Down Expand Up @@ -212,7 +215,9 @@ func TestSQLiteFileExecutionMutableStateStoreSuite(t *testing.T) {
func TestSQLiteFileExecutionMutableStateTaskStoreSuite(t *testing.T) {
cfg := NewSQLiteFileConfig()
SetupSQLiteDatabase(cfg)
defer os.Remove(cfg.DatabaseName)
defer func() {
assert.NoError(t, os.Remove(cfg.DatabaseName))
}()
logger := log.NewNoopLogger()
factory := sql.NewFactory(
*cfg,
Expand Down Expand Up @@ -245,7 +250,9 @@ func TestSQLiteFileExecutionMutableStateTaskStoreSuite(t *testing.T) {
func TestSQLiteFileHistoryStoreSuite(t *testing.T) {
cfg := NewSQLiteFileConfig()
SetupSQLiteDatabase(cfg)
defer os.Remove(cfg.DatabaseName)
defer func() {
assert.NoError(t, os.Remove(cfg.DatabaseName))
}()
logger := log.NewNoopLogger()
factory := sql.NewFactory(
*cfg,
Expand All @@ -268,7 +275,9 @@ func TestSQLiteFileHistoryStoreSuite(t *testing.T) {
func TestSQLiteFileTaskQueueSuite(t *testing.T) {
cfg := NewSQLiteFileConfig()
SetupSQLiteDatabase(cfg)
defer os.Remove(cfg.DatabaseName)
defer func() {
assert.NoError(t, os.Remove(cfg.DatabaseName))
}()
logger := log.NewNoopLogger()
factory := sql.NewFactory(
*cfg,
Expand All @@ -291,7 +300,9 @@ func TestSQLiteFileTaskQueueSuite(t *testing.T) {
func TestSQLiteFileTaskQueueTaskSuite(t *testing.T) {
cfg := NewSQLiteFileConfig()
SetupSQLiteDatabase(cfg)
defer os.Remove(cfg.DatabaseName)
defer func() {
assert.NoError(t, os.Remove(cfg.DatabaseName))
}()
logger := log.NewNoopLogger()
factory := sql.NewFactory(
*cfg,
Expand Down