Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@sters
Copy link

@sters sters commented Sep 5, 2022

I have a weird case of using BatchReadOnlyTransaction, please check f7 testcase.

I guess the reason is BatchReadOnlyTransaction.Close and ReadOnlyTransaction.Close are different.
https://github.com/googleapis/google-cloud-go/blob/main/spanner/batch.go#L246-L251

So, I added BatchReadOnlyTransaction.Close to close method list.
(I don't have confidence on my changes.)

@sters sters marked this pull request as ready for review September 5, 2022 08:31
@sters
Copy link
Author

sters commented Sep 5, 2022

@tenntenn @sinmetal
(I'm not sure the actual owner. I refered to the latest PR #45)

Please review this PR.


for {
_, err := iter.Next()
if err == iterator.Done {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

実際に実行するわけじゃないのだろうけど、err != nilだったら、一生このループ抜けられないのか・・・wって思ってしまったw

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

確かに、、 err != nil だけにしました。

Copy link
Member

@tenntenn tenntenn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I leave comments.

return nil
}

func f7(ctx context.Context, client *spanner.Client) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a test case which does not call Close method with a // want comment.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f5 is that the testcase.

func f5(ctx context.Context, client *spanner.Client) {
tx, _ := client.BatchReadOnlyTransaction(ctx, spanner.StrongRead()) // want "transaction must be closed"
_ = tx
}

continue
}
instrs := analysisutil.NotCalledIn(f, txTyp, methods...)
instrs := analysisutil.NotCalledIn(f, txTypeRo, methods...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the second argument of NotCalledIn is a receiver of the methods, it cannot find txTypeBatch's methods.

I think you should call NotCalledIn two times for txTypRo and txTypeBatch and merge theses return values into instrs.

Copy link
Author

@sters sters Sep 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I use this:

instrs := append(
	analysisutil.NotCalledIn(f, txTypeRo, methods...),
	analysisutil.NotCalledIn(f, txTypeBatch, methods...)...,
)
for _, instr := range instrs {
...

The test says:

/my/go/path/root/sters/zagane/passes/unclosetx/analysistest.go:446: a/a.go:55:42: unexpected diagnostic: transaction must be closed

it points to this test case:

image

I have no idea to solve this test failure. 🤔

@sters
Copy link
Author

sters commented May 14, 2024

Let me close this PR. Feel free to pick my commit. 🙏

@sters sters closed this May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants