Skip to content

Commit

Permalink
pglock: fix logs
Browse files Browse the repository at this point in the history
  • Loading branch information
ucirello committed Sep 26, 2023
1 parent cc27b53 commit 50ca532
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ func (c *Client) AcquireContext(ctx context.Context, name string, opts ...LockOp
c.log.Debug("not acquired, exit")
return l, err
} else if err == ErrNotAcquired {
c.log.Debug("not acquired, wait:", l.leaseDuration)
c.log.Debug("not acquired, wait: %v", l.leaseDuration)
select {
case <-time.After(l.leaseDuration):
case <-ctx.Done():
return l, err
}
continue
} else if err != nil {
c.log.Error("error:", err)
c.log.Error("error: %v", err)
return nil, err
}
return l, nil
Expand Down Expand Up @@ -232,9 +232,9 @@ func (c *Client) storeAcquire(ctx context.Context, l *Lock) error {
if err != nil {
return typedError(err, "cannot create transaction for lock acquisition")
}
c.log.Debug("storeAcquire in", l.name, rvn, l.data, l.recordVersionNumber)
c.log.Debug("storeAcquire in: %v %v %v %v", l.name, rvn, l.data, l.recordVersionNumber)
defer func() {
c.log.Debug("storeAcquire out", l.name, rvn, l.data, l.recordVersionNumber)
c.log.Debug("storeAcquire out: %v %v %v %v", l.name, rvn, l.data, l.recordVersionNumber)
}()
_, err = tx.ExecContext(ctx, `
INSERT INTO `+c.tableName+`
Expand Down Expand Up @@ -361,13 +361,13 @@ func (c *Client) storeRelease(ctx context.Context, l *Lock) error {

func (c *Client) heartbeat(ctx context.Context, l *Lock) {
defer l.heartbeatWG.Done()
c.log.Debug("heartbeat started", l.name)
defer c.log.Debug("heartbeat stopped", l.name)
c.log.Debug("heartbeat started: %v", l.name)
defer c.log.Debug("heartbeat stopped: %v", l.name)
for {
if err := ctx.Err(); err != nil {
return
} else if err := c.SendHeartbeat(ctx, l); err != nil {
defer c.log.Error("heartbeat missed", err)
defer c.log.Error("heartbeat missed: %v", err)
return
}
select {
Expand Down Expand Up @@ -459,7 +459,7 @@ func (c *Client) GetContext(ctx context.Context, name string) (*Lock, error) {
return err
})
if notExist := (&NotExistError{}); err != nil && errors.As(err, &notExist) {
c.log.Error("missing lock entry:", err)
c.log.Error("missing lock entry: %v", err)
}
return l, err
}
Expand Down Expand Up @@ -506,7 +506,7 @@ func (c *Client) retry(ctx context.Context, f func() error) error {
if failedPrecondition := (&FailedPreconditionError{}); err == nil || !errors.As(err, &failedPrecondition) {
break
}
c.log.Debug("bad transaction, retrying:", err)
c.log.Debug("bad transaction, retrying: %v", err)
select {
case <-time.After(retryPeriod):
case <-ctx.Done():
Expand Down

0 comments on commit 50ca532

Please sign in to comment.