-
Notifications
You must be signed in to change notification settings - Fork 1
add postgresql_script resource #18
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
Conversation
|
||
# postgresql\_script | ||
|
||
The ``postgresql_script`` execute a script given as parameter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ``postgresql_script`` execute a script given as parameter. | |
The ``postgresql_script`` execute a script given as parameter. This script will be executed each time it changes. |
|
||
func executeCommands(db *DBConnection, commands []any, tries int, timeout int) error { | ||
for _, command := range commands { | ||
for i := 1; ; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fuyar Should we retry all commands, or just the last one. I think we need to retry the whole batch, may be with a session reset between the retries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends on if the failed SQL query is within a BEGIN END block I guess ?
If not, you can just retry latest.
If within, it's harder ... You'd have to rollback and retry the whole block
const ( | ||
scriptCommandsAttr = "commands" | ||
scriptTriesAttr = "tries" | ||
scriptTimeoutAttr = "timeout" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's not really a timeout. More a backoff ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, can you rename?
|
||
func executeCommands(db *DBConnection, commands []any, tries int, timeout int) error { | ||
for _, command := range commands { | ||
for i := 1; ; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends on if the failed SQL query is within a BEGIN END block I guess ?
If not, you can just retry latest.
If within, it's harder ... You'd have to rollback and retry the whole block
|
||
if err != nil { | ||
log.Println("[DEBUG] Error catched:", err) | ||
if _, err := db.Query("ROLLBACK"); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plase use a different variable name
Co-authored-by: Bertrand Paquet <bertrand.paquet@gmail.com>
Co-authored-by: Bertrand Paquet <bertrand.paquet@gmail.com>
Add a
postgresql_script
resource enabling to execute an array of sql queries.