Closed
Description
Hi,
tag: 2.0.3
I've recently started using this client library and have noticed some of the interfaces do not work as expected, most importantly WithSessionMonitor's callback never gets invoked even when the client completely loses its connection with the underlying DynamoDB lock table. I simulated this within a K8s pod in which I used iptables
to reject all messages to and from the DynamoDB IP range, and the call back never gets invoked. An example of the code is:
c, err := dynamolock.New(dynamodb.NewFromConfig(cfg),
"some-service.locks",
dynamolock.WithLeaseDuration(10 * time.Second),
dynamolock.WithHeartbeatPeriod(3 * time.Second),
dynamolock.WithOwnerName(hostname),
)
if err != nil {
return nil, errors.Wrap(err, "failed to create dynamolock client")
}
...
// Chan used to signal lock is close to expiration
done := make(chan struct{})
lock, err := c.AcquireLockWithContext(ctx, c.lockKey,
dynamolock.WithDeleteLockOnRelease(),
dynamolock.WithSessionMonitor(10*time.Second, func() {
glog.Warning("session monitoring triggered alert for lock approaching expiration, will release and try to acquire again")
// THIS CODE IS NEVER REACHED
// Close the channel
close(done)
}),
)
if err != nil {
...
select {
case <-ctx.Done():
return nil
case <-done:
return errors.New("lock expiring")
}
Please let me know if there's anything else I can provide. Would love to know if I'm doing something wrong here or how we can get this issue resolved. I'll file another issue for the other issues I have reproduced. Thanks!