This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new 8b3977bde6 feat(plc4go): more connection cache close tracing
8b3977bde6 is described below

commit 8b3977bde61b927c572bf0ee73b8e8e683a85fc5
Author: Sebastian Rühl <[email protected]>
AuthorDate: Fri Mar 7 12:49:08 2025 +0100

    feat(plc4go): more connection cache close tracing
---
 plc4go/pkg/api/cache/PlcConnectionCache.go | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/plc4go/pkg/api/cache/PlcConnectionCache.go 
b/plc4go/pkg/api/cache/PlcConnectionCache.go
index 93c34ee8d0..34135e4c0a 100644
--- a/plc4go/pkg/api/cache/PlcConnectionCache.go
+++ b/plc4go/pkg/api/cache/PlcConnectionCache.go
@@ -235,8 +235,10 @@ func (c *plcConnectionCache) Close() <-chan 
PlcConnectionCacheCloseResult {
        ch := make(chan PlcConnectionCacheCloseResult)
 
        go func() {
+               c.log.Trace().Msg("Acquire lock")
                c.cacheLock.Lock()
                defer c.cacheLock.Unlock()
+               c.log.Trace().Msg("lock acquired")
 
                if len(c.connections) == 0 {
                        responseDeliveryTimeout := time.NewTimer(10 * 
time.Millisecond)
@@ -249,11 +251,14 @@ func (c *plcConnectionCache) Close() <-chan 
PlcConnectionCacheCloseResult {
                }
 
                for _, cc := range c.connections {
+                       ccLog := c.log.With().Stringer("cc", cc).Logger()
+                       ccLog.Trace().Msg("Closing connection")
                        // Mark the connection as being closed to not try to 
re-establish it.
                        cc.closed = true
                        // Try to get a lease as this way we kow we're not 
closing the connection
                        // while some go func is still using it.
                        go func(container *connectionContainer) {
+                               ccLog.Trace().Msg("getting a lease")
                                leaseResults := container.lease()
                                closeTimeout := time.NewTimer(c.maxWaitTime)
                                select {
@@ -261,20 +266,22 @@ func (c *plcConnectionCache) Close() <-chan 
PlcConnectionCacheCloseResult {
                                // We also really don'c care if it worked, or 
not ... it's just an attempt of being
                                // nice.
                                case _ = <-leaseResults:
-                                       c.log.Debug().Str("connectionString", 
container.connectionString).Msg("Gracefully closing connection ...")
+                                       ccLog.Debug().Msg("Gracefully closing 
connection ...")
                                        // Give back the connection.
                                        if container.connection != nil {
+                                               ccLog.Trace().Msg("closing 
actual connection")
                                                container.connection.Close()
                                        }
                                // If we're timing out brutally kill the 
connection.
                                case <-closeTimeout.C:
-                                       c.log.Debug().Str("connectionString", 
container.connectionString).Msg("Forcefully closing connection ...")
+                                       ccLog.Debug().Msg("Forcefully closing 
connection ...")
                                        // Forcefully close this connection.
                                        if container.connection != nil {
                                                container.connection.Close()
                                        }
                                }
 
+                               c.log.Trace().Msg("Writing response")
                                responseDeliveryTimeout := time.NewTimer(10 * 
time.Millisecond)
                                select {
                                case ch <- 
newDefaultPlcConnectionCacheCloseResult(c, nil):

Reply via email to