You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by sr...@apache.org on 2023/06/15 15:40:27 UTC

[plc4x] branch develop updated: fix(plc4go): add more logging to hunt down race conditions

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 333f9b90d3 fix(plc4go): add more logging to hunt down race conditions
333f9b90d3 is described below

commit 333f9b90d3fb62bc5c270212f44681b772268dc7
Author: Sebastian Rühl <sr...@apache.org>
AuthorDate: Thu Jun 15 17:40:15 2023 +0200

    fix(plc4go): add more logging to hunt down race conditions
---
 plc4go/internal/cbus/Connection_test.go              | 6 +++++-
 plc4go/spi/default/DefaultCodec.go                   | 3 +++
 plc4go/spi/transactions/RequestTransactionManager.go | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/plc4go/internal/cbus/Connection_test.go b/plc4go/internal/cbus/Connection_test.go
index 65c66ba0f3..1e9909b41e 100644
--- a/plc4go/internal/cbus/Connection_test.go
+++ b/plc4go/internal/cbus/Connection_test.go
@@ -1812,10 +1812,15 @@ func TestConnection_startSubscriptionHandler(t *testing.T) {
 
 				fields.subscribers = []*Subscriber{NewSubscriber(nil, options.WithCustomLogger(testutils.ProduceTestingLogger(t)))}
 				codec := NewMessageCodec(nil, _options...)
+				written := make(chan struct{})
 				go func() {
 					codec.monitoredMMIs <- readWriteModel.NewCALReplyShort(0, nil, nil, nil)
 					codec.monitoredSALs <- readWriteModel.NewMonitoredSAL(0, nil)
+					close(written)
 				}()
+				t.Cleanup(func() {
+					<-written
+				})
 				t.Cleanup(func() {
 					assert.NoError(t, codec.Disconnect())
 				})
@@ -1837,7 +1842,6 @@ func TestConnection_startSubscriptionHandler(t *testing.T) {
 				log:               testutils.ProduceTestingLogger(t),
 			}
 			c.startSubscriptionHandler()
-			time.Sleep(50 * time.Millisecond)
 		})
 	}
 }
diff --git a/plc4go/spi/default/DefaultCodec.go b/plc4go/spi/default/DefaultCodec.go
index 321968bd84..194e599108 100644
--- a/plc4go/spi/default/DefaultCodec.go
+++ b/plc4go/spi/default/DefaultCodec.go
@@ -298,6 +298,7 @@ func (m *defaultCodec) HandleMessages(message spi.Message) bool {
 			m.log.Trace().Stringer("expectation", expectation).Msg("doesn't accept message")
 		}
 	}
+	m.log.Trace().Msgf("handled message = %t", messageHandled)
 	return messageHandled
 }
 
@@ -307,6 +308,8 @@ func (m *defaultCodec) Work(codec DefaultCodecRequirements) {
 	if !config.TraceDefaultMessageCodecWorker {
 		workerLog = zerolog.Nop()
 	}
+	workerLog.Trace().Msg("Starting work")
+	defer workerLog.Trace().Msg("work ended")
 
 	defer func(workerLog zerolog.Logger) {
 		if err := recover(); err != nil {
diff --git a/plc4go/spi/transactions/RequestTransactionManager.go b/plc4go/spi/transactions/RequestTransactionManager.go
index ca2fada4ce..00638ebe42 100644
--- a/plc4go/spi/transactions/RequestTransactionManager.go
+++ b/plc4go/spi/transactions/RequestTransactionManager.go
@@ -157,7 +157,7 @@ func (r *requestTransactionManager) processWorklog() {
 	for len(r.runningRequests) < r.numberOfConcurrentRequests && r.workLog.Len() > 0 {
 		front := r.workLog.Front()
 		next := front.Value.(*requestTransaction)
-		r.log.Debug().Msgf("Handling next %v. (Adding to running requests (length: %d))", next, len(r.runningRequests))
+		r.log.Debug().Msgf("Handling next\n%v\n. (Adding to running requests (length: %d))", next, len(r.runningRequests))
 		r.runningRequests = append(r.runningRequests, next)
 		completionFuture := r.executor.Submit(context.Background(), next.transactionId, next.operation)
 		next.completionFuture = completionFuture