diff --git a/plugins/database/cassandra/connection_producer.go b/plugins/database/cassandra/connection_producer.go index 2f7e06f86..c8aae5961 100644 --- a/plugins/database/cassandra/connection_producer.go +++ b/plugins/database/cassandra/connection_producer.go @@ -116,12 +116,15 @@ func (c *cassandraConnectionProducer) Initialize(ctx context.Context, conf map[s } func (c *cassandraConnectionProducer) Connection(_ context.Context) (interface{}, error) { + c.Lock() + defer c.Unlock() + if !c.Initialized { return nil, connutil.ErrNotInitialized } // If we already have a DB, return it - if c.session != nil { + if c.session != nil && !c.session.Closed() { return c.session, nil }