diff --git a/CHANGELOG.md b/CHANGELOG.md index 7626d8ed..3ce42427 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ Types of changes - `Fixed` for any bug fixes. - `Security` in case of vulnerabilities. +## [3.1.1] + +- `Fixed` final commit on push + ## [3.1.0] - `Added` possibility to filter columns via `select` property in ingress descriptors diff --git a/pkg/push/driver.go b/pkg/push/driver.go index 96800ee4..755b28b8 100755 --- a/pkg/push/driver.go +++ b/pkg/push/driver.go @@ -26,6 +26,7 @@ import ( ) // Push write rows to target table +// nolint:gocyclo func Push(ri RowIterator, destination DataDestination, plan Plan, mode Mode, commitSize uint, disableConstraints bool, catchError RowWriter, translator Translator, whereField string, savepointPath string, autotruncate bool, observers ...Observer) (err *Error) { defer func() { for _, observer := range observers { @@ -44,6 +45,14 @@ func Push(ri RowIterator, destination DataDestination, plan Plan, mode Mode, com er1 := destination.Close() er2 := ri.Close() + if er1 != nil { + log.Warn().Msg(fmt.Sprintf("Failed to close data destination : %s", er1.Error())) + } + + if er2 != nil { + log.Warn().Msg(fmt.Sprintf("Failed to close connection : %s", er1.Error())) + } + switch { case er1 != nil && er2 == nil && err == nil: err = er1 @@ -109,6 +118,12 @@ func Push(ri RowIterator, destination DataDestination, plan Plan, mode Mode, com } } + log.Info().Msg("Final commit") + if errCommit := destination.Commit(); errCommit != nil { + return errCommit + } + IncCommitsCount() + if ri.Error() != nil { return ri.Error() } diff --git a/tests/suites/push/stats.yml b/tests/suites/push/stats.yml index 6455bfe9..cdaa31ba 100644 --- a/tests/suites/push/stats.yml +++ b/tests/suites/push/stats.yml @@ -39,7 +39,7 @@ testcases: assertions: - result.code ShouldEqual 0 - result.systemout ShouldBeEmpty - - result.systemerr ShouldContainSubstring {"level":"info","stats":{"inputLinesCount":1,"createdLinesCount":{},"deletedLinesCount":{"staff":1,"store":1},"commitsCount":0 + - result.systemerr ShouldContainSubstring {"level":"info","stats":{"inputLinesCount":1,"createdLinesCount":{},"deletedLinesCount":{"staff":1,"store":1},"commitsCount":1 - script: lino pull dest --limit 1 -f store_id=2 assertions: @@ -58,12 +58,12 @@ testcases: assertions: - result.code ShouldEqual 0 - result.systemout ShouldBeEmpty - - result.systemerr ShouldContainSubstring {"level":"info","stats":{"inputLinesCount":1,"createdLinesCount":{},"deletedLinesCount":{"staff":1,"store":1},"commitsCount":0,"duration" + - result.systemerr ShouldContainSubstring {"level":"info","stats":{"inputLinesCount":1,"createdLinesCount":{},"deletedLinesCount":{"staff":1,"store":1},"commitsCount":1,"duration" - result.systemerr ShouldContainSubstring },"return":0 - script: cat lino-push-delete-stats.json assertions: - - result.systemout ShouldContainSubstring {"inputLinesCount":1,"createdLinesCount":{},"deletedLinesCount":{"staff":1,"store":1},"commitsCount":0,"duration" + - result.systemout ShouldContainSubstring {"inputLinesCount":1,"createdLinesCount":{},"deletedLinesCount":{"staff":1,"store":1},"commitsCount":1,"duration" - name: restore with stats steps: