8000 WithSessionMonitor does not work as expected · Issue #446 · cirello-io/dynamolock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
WithSessionMonitor does not work as expected #446
Closed
@allanliu

Description

@allanliu

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0