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

[*] improve log messages for standalone tasks #616

Merged
merged 1 commit into from
Nov 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions internal/pgengine/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,15 @@ func (pge *PgEngine) ExecStandaloneTask(ctx context.Context, connf func() (PgxCo

// ExecRemoteSQLTask executes task against remote connection
func (pge *PgEngine) ExecRemoteSQLTask(ctx context.Context, task *ChainTask, paramValues []string) (string, error) {
log.GetLogger(ctx).Info("Switching to remote task mode")
return pge.ExecStandaloneTask(ctx,
func() (PgxConnIface, error) { return pge.GetRemoteDBConnection(ctx, task.ConnectString.String) },
task, paramValues)
}

// ExecAutonomousSQLTask executes autonomous task in an acquired connection from pool
func (pge *PgEngine) ExecAutonomousSQLTask(ctx context.Context, task *ChainTask, paramValues []string) (string, error) {
log.GetLogger(ctx).Info("Switching to autonomous task mode")
return pge.ExecStandaloneTask(ctx,
func() (PgxConnIface, error) { return pge.GetLocalDBConnection(ctx) },
task, paramValues)
Expand Down Expand Up @@ -158,7 +160,7 @@ func (pge *PgEngine) GetRemoteDBConnection(ctx context.Context, connectionString
// FinalizeDBConnection closes session
func (pge *PgEngine) FinalizeDBConnection(ctx context.Context, remoteDb PgxConnIface) {
l := log.GetLogger(ctx)
l.Info("Closing remote session")
l.Info("Closing standalone session")
if err := remoteDb.Close(ctx); err != nil {
l.WithError(err).Error("Cannot close database connection:", err)
}
Expand All @@ -170,15 +172,15 @@ func (pge *PgEngine) SetRole(ctx context.Context, executor executor, runUID pgty
if !runUID.Valid || strings.TrimSpace(runUID.String) == "" {
return nil
}
log.GetLogger(ctx).Info("Setting Role to ", runUID.String)
log.GetLogger(ctx).Info("Setting role to ", runUID.String)
_, err := executor.Exec(ctx, fmt.Sprintf("SET ROLE %v", runUID.String))
return err
}

// ResetRole - RESET forms reset the current user identifier to be the current session user identifier
func (pge *PgEngine) ResetRole(ctx context.Context, executor executor) {
l := log.GetLogger(ctx)
l.Info("Resetting Role")
l.Info("Resetting role")
_, err := executor.Exec(ctx, `RESET ROLE`)
if err != nil {
l.WithError(err).Error("Failed to set a role", err)
Expand Down