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

bug: something is wrong with DoTx + query.WithOnlineReadOnly() #1295

Open
pelageech opened this issue Jun 18, 2024 · 2 comments
Open

bug: something is wrong with DoTx + query.WithOnlineReadOnly() #1295

pelageech opened this issue Jun 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@pelageech
Copy link

Bug Report

YDB GO SDK version:
3.74.3

Environment
MacOS Sonoma 14.2.1 AMD64

Current behavior:

2024/06/18 13:06:47 queryconnError{node_id:1,address:'localhost:2136'}: operation/NOT_FOUND (code = 400140, address = localhost:2136, issues = [{#2015 'Transaction not found: '}]) at `github.com/ydb-platform/ydb-go-sdk/v3/internal/conn.(*grpcClientStream).RecvMsg(grpc_client_stream.go:178)` at `github.com/ydb-platform/ydb-go-sdk/v3/internal/query.nextPart(result.go:143)` at `github.com/ydb-platform/ydb-go-sdk/v3/internal/query.newResult(result.go:101)` at `github.com/ydb-platform/ydb-go-sdk/v3/internal/query.execute(execute_query.go:74)` at `github.com/ydb-platform/ydb-go-sdk/v3/internal/query.transaction.Execute(transaction.go:83)`

Expected behavior:
No error, 42 in stdout.

Steps to reproduce:
Run the code.

Related code:

package main

import (
	"context"
	"errors"
	"fmt"
	"io"
	"log"
	"time"

	"github.com/ydb-platform/ydb-go-sdk/v3"
	"github.com/ydb-platform/ydb-go-sdk/v3/query"
)

func main() {
	ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
	defer cancel()

	driver, err := ydb.Open(ctx, "grpc://localhost:2136/local")
	if err != nil {
		log.Fatal("open", err)
	}
	defer driver.Close(ctx)

	err = driver.Query().DoTx(ctx, func(ctx context.Context, s query.TxActor) error {
		res, err := s.Execute(ctx, `SELECT CAST(42 AS Uint32);`)
		if err != nil {
			log.Fatal("query", err)
		}

		var a uint32
		for set, err := res.NextResultSet(ctx); !errors.Is(err, io.EOF); set, err = res.NextResultSet(ctx) {
			if err != nil {
				return err
			}
			for row, err := set.NextRow(ctx); !errors.Is(err, io.EOF); row, err = set.NextRow(ctx) {
				if err != nil {
					return err
				}

				err = row.Scan(&a)
				if err != nil {
					return err
				}

				fmt.Println(a)
			}
		}
		return res.Err()
	}, query.WithIdempotent(), query.WithTxSettings(query.TxSettings(query.WithOnlineReadOnly())))

	if err != nil {
		log.Fatal(err)
	}
}

Other information:
There's no error if I remove query.WithTxSettings(query.TxSettings(query.WithOnlineReadOnly())).

@pelageech pelageech added the bug Something isn't working label Jun 18, 2024
@neyguvj
Copy link
Collaborator

neyguvj commented Jun 21, 2024

Ydb_Query.BeginTransactionResponse=status:BAD_REQUEST issues:{message:"Failed to begin transaction: open transactions not supported for transaction mode OnlineReadOnly, use tx_control field in ExecuteDataQueryRequest to begin transaction with this mode.

@neyguvj
Copy link
Collaborator

neyguvj commented Jun 21, 2024

Currently only two transaction modes are supported for interactive transactions:

  • Snapshot Read-Only
  • Serializable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants