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

CASSGO-28 Retry type Ignore is not different from Rethrow (error is still returned) #1808

Open
Rikkuru opened this issue Sep 2, 2024 · 4 comments · May be fixed by #1811
Open

CASSGO-28 Retry type Ignore is not different from Rethrow (error is still returned) #1808

Rikkuru opened this issue Sep 2, 2024 · 4 comments · May be fixed by #1811

Comments

@Rikkuru
Copy link

Rikkuru commented Sep 2, 2024

What version of Cassandra are you using?

Scylla Enterprise 2024.1.8 or scylla 5.1

What version of Gocql are you using?

github.com/gocql/gocql v1.6.0

What version of Go are you using?

go 1.21.11

What did you do?

used RetryType Ignore (https://pkg.go.dev/github.com/gocql/gocql#RetryType) on write query

What did you expect to see?

I expected that query.Exec() would not return error

What did you see instead?

the error is returned.


Maybe the documentation is not clear on how Ignore and Rethrow are different?

I thought Ignore would make it so that Exec does not return error ? Maybe this would be strange on read ops but it can be used on writes (in Downgrading CL retry policy for example ). But they both return error and I don't see any difference between those retry types

Is there any difference in Rethrow and Ignore retry types ?

@Rikkuru
Copy link
Author

Rikkuru commented Sep 2, 2024

Example (on empty cluster , keyspace error is ok for our test )

MyRetryPolicy can return Ignore or Rethrow - it changes nothing

package main

import (
	"context"
	"fmt"
	"time"

	"github.com/gocql/gocql"
)

type MyRetryPolicy struct {
}

func (*MyRetryPolicy) Attempt(q gocql.RetryableQuery) bool {
	if q.Attempts() > 2 {
		return false
	}
	return true
}

func (*MyRetryPolicy) GetRetryType(error) gocql.RetryType {
	return gocql.Ignore
}

type LoggingObserver struct{}

func (*LoggingObserver) ObserveQuery(ctx context.Context, q gocql.ObservedQuery) {
	fmt.Printf("observer attempt: %d err: %s\n", q.Attempt, q.Err)
}

func main() {
	cluster := gocql.NewCluster("node-1")
	cluster.Authenticator = gocql.PasswordAuthenticator{
		Username: "scylla",
		Password: "***",
	}

	s, err := gocql.NewSession(*cluster)
	if err != nil {
		fmt.Printf("session err: %s\n", err)
	}
	defer s.Close()

	q := s.Query("INSERT INTO  my.events(event_id, time, args) VALUES (?,?,?)", 1, gocql.UUIDFromTime(time.Now()), "test")

	q.RetryPolicy(&MyRetryPolicy{})
	q.Observer(&LoggingObserver{})

	fmt.Printf("QUERY IsIdempotent: %v\n", q.IsIdempotent())

	err = q.Exec()
	if err != nil {
		fmt.Printf("exec err: %s\n", err)
	}

}

Output

➜  test go run main.go
QUERY IsIdempotent: false
observer attempt: 0 err: Keyspace my does not exist
exec err: Keyspace my does not exist

@Rikkuru Rikkuru changed the title Retry type Ignore does not clear error documentation(?): Retry type Ignore is not different from Rethrow (error is still returned) Sep 2, 2024
@Rikkuru Rikkuru changed the title documentation(?): Retry type Ignore is not different from Rethrow (error is still returned) Retry type Ignore is not different from Rethrow (error is still returned) Sep 2, 2024
@Rikkuru Rikkuru linked a pull request Sep 4, 2024 that will close this issue
@Rikkuru
Copy link
Author

Rikkuru commented Sep 4, 2024

need to add ignored error in ObserverdQuery too

@joao-r-reis
Copy link
Contributor

I honestly don't see a use case for Ignore, we should probably just deprecate it.

@joao-r-reis
Copy link
Contributor

Hmm other drivers also have Ignore so we can probably keep it as well but we need to fix the behavior and add tests to ensure it's properly fixed and there's no regressions in the future.

@joao-r-reis joao-r-reis changed the title Retry type Ignore is not different from Rethrow (error is still returned) CASSGO-28 Retry type Ignore is not different from Rethrow (error is still returned) Nov 5, 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 a pull request may close this issue.

2 participants