Skip to content

Commit

Permalink
format & fix rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
Code-Fight committed Nov 19, 2022
1 parent 44d5813 commit 76f5743
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ require (
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/goccy/go-json v0.9.7
github.com/goccy/go-json v0.9.7 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
Expand Down
6 changes: 4 additions & 2 deletions pkg/datasource/sql/conn_at.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
gosql "database/sql"
"database/sql/driver"

"github.com/seata/seata-go/pkg/util/log"

"github.com/seata/seata-go/pkg/datasource/sql/exec"
Expand Down Expand Up @@ -167,8 +168,9 @@ func (c *ATConn) createNewTxOnExecIfNeed(ctx context.Context, f func() (types.Ex
}
}
defer func() {
if recoverErr := recover(); recoverErr != nil {
log.Errorf("conn at rollback panic:%v", recoverErr)
recoverErr := recover()
if err != nil || recoverErr != nil {
log.Errorf("conn at rollback error:%v or recoverErr:%v", err, recoverErr)
if tx != nil {
rollbackErr := tx.Rollback()
log.Errorf("conn at rollback error:%v", rollbackErr)
Expand Down
3 changes: 2 additions & 1 deletion pkg/datasource/sql/undo/base/undo.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import (
"database/sql/driver"
"encoding/json"
"fmt"
"github.com/seata/seata-go/pkg/util/convert"
"strconv"
"strings"

"github.com/seata/seata-go/pkg/util/convert"

"github.com/arana-db/parser/mysql"
"github.com/pkg/errors"

Expand Down
15 changes: 15 additions & 0 deletions sample/dockercompose/mysql/order.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
-- Licensed to the Apache Software Foundation (ASF) under one or more
-- contributor license agreements. See the NOTICE file distributed with
-- this work for additional information regarding copyright ownership.
-- The ASF licenses this file to You under the Apache License, Version 2.0
-- (the "License"); you may not use this file except in compliance with
-- the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

CREATE database if NOT EXISTS `seata_client` default character set utf8mb4 collate utf8mb4_unicode_ci;
USE `seata_client`;

Expand Down

0 comments on commit 76f5743

Please sign in to comment.