Skip to content
Open
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions pkg/push/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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()
}
Expand Down
6 changes: 3 additions & 3 deletions tests/suites/push/stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down