Skip to content

Commit f13a942

Browse files
authored
Merge pull request #504 from ydb-platform/fix-with-commit
Reverted tx.WithCommit() and added options.WithCommit() option of ExecuteDataQuery
2 parents eceec46 + b1ebd2d commit f13a942

File tree

14 files changed

+167
-160
lines changed

14 files changed

+167
-160
lines changed

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ linters:
127127
disable-all: true
128128
enable:
129129
# - cyclop
130-
- deadcode
131130
- depguard
132131
- dogsled
133132
# - dupl
@@ -173,7 +172,6 @@ linters:
173172
- revive
174173
- staticcheck
175174
- stylecheck
176-
- structcheck
177175
# - tagliatelle
178176
# - testpackage
179177
# - thelper
@@ -183,7 +181,6 @@ linters:
183181
- unparam
184182
- unused
185183
# - varnamelen
186-
- varcheck
187184
- whitespace
188185
# - wrapcheck
189186
# - wsl

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
* Added retry policy options for topics: `topic/topicoptions.WithReaderCheckRetryErrorFunction`, `topic/topicoptions.WithReaderStartTimeout`, `topic/topicoptions.WithWriterCheckRetryErrorFunction`, `topic/topicoptions.WithWriterStartTimeout`
2-
* Refactored `internal/conn` middlewares for `DRY`
2+
* Refactored `internal/conn` middlewares
33
* Added `trace.tableSessionInfo.LastUsage()` method for get last usage timestamp
4+
* Reverted `tx.WithCommit()` changes for fix unstable behaviour of lazy transactions
5+
* Added `options.WithCommit()` option for execute query with auto-commit flag
6+
* Removed `trace.TableTransactionExecuteStartInfo.KeepInCache` field as redundant
47

58
## v3.41.0
69
* Added option for set interval of auth token update in topic streams

internal/cmd/gtrace/writer.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,6 @@ func (f flags) has(x flags) bool {
782782
}
783783

784784
const (
785-
//nolint
786785
zeroFlags flags = 1 << iota >> 1
787786
docs
788787
)

internal/table/session.go

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -671,25 +671,31 @@ func (s *session) Execute(
671671
return nil, nil, xerrors.WithStackTrace(err)
672672
}
673673

674-
return s.executeQueryResult(result, txControl)
674+
return s.executeQueryResult(result, request.TxControl)
675675
}
676676

677677
// executeQueryResult returns Transaction and result built from received
678678
// result.
679-
func (s *session) executeQueryResult(res *Ydb_Table.ExecuteQueryResult, txControl *table.TransactionControl) (
679+
func (s *session) executeQueryResult(
680+
res *Ydb_Table.ExecuteQueryResult, txControl *Ydb_Table.TransactionControl,
681+
) (
680682
table.Transaction, result.Result, error,
681683
) {
682-
t := &transaction{
684+
tx := &transaction{
683685
id: res.GetTxMeta().GetId(),
684686
s: s,
685-
c: txControl,
686687
}
687-
r := scanner.NewUnary(
688+
if txControl.CommitTx {
689+
tx.state = txStateCommitted
690+
} else {
691+
tx.state = txStateInitialized
692+
tx.control = table.TxControl(table.WithTxID(tx.id))
693+
}
694+
return tx, scanner.NewUnary(
688695
res.GetResultSets(),
689696
res.GetQueryStats(),
690697
scanner.WithIgnoreTruncated(s.config.IgnoreTruncated()),
691-
)
692-
return t, r, nil
698+
), nil
693699
}
694700

695701
// executeDataQuery executes data query.
@@ -1084,8 +1090,9 @@ func (s *session) BeginTransaction(
10841090
return
10851091
}
10861092
return &transaction{
1087-
id: result.GetTxMeta().GetId(),
1088-
s: s,
1089-
c: table.TxControl(table.WithTxID(result.GetTxMeta().GetId())),
1093+
id: result.GetTxMeta().GetId(),
1094+
state: txStateInitialized,
1095+
s: s,
1096+
control: table.TxControl(table.WithTxID(result.GetTxMeta().GetId())),
10901097
}, nil
10911098
}

internal/table/statement.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,20 @@ func (s *statement) Execute(
6363
onDone(txr, true, r, err)
6464
}()
6565

66-
return s.execute(ctx, a, request, txControl)
66+
return s.execute(ctx, a, request, request.TxControl)
6767
}
6868

6969
// execute executes prepared query without any tracing.
7070
func (s *statement) execute(
7171
ctx context.Context, a *allocator.Allocator,
72-
request *Ydb_Table.ExecuteDataQueryRequest, txControl *table.TransactionControl,
72+
request *Ydb_Table.ExecuteDataQueryRequest, txControl *Ydb_Table.TransactionControl,
7373
) (
7474
txr table.Transaction, r result.Result, err error,
7575
) {
7676
res, err := s.session.executeDataQuery(ctx, a, request)
7777
if err != nil {
7878
return nil, nil, xerrors.WithStackTrace(err)
7979
}
80-
8180
return s.session.executeQueryResult(res, txControl)
8281
}
8382

0 commit comments

Comments
 (0)