-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
bugSomething isn't workingSomething isn't workingloggingsupport_rotationA good task to pick up during support rotationA good task to pick up during support rotation
Description
Is this a new bug in dbt-core?
- I believe this is a new bug in dbt-core
- I have searched the existing issues, and I could not find an existing issue for this bug
Current Behavior
The connection reused event does not show in the logs: Re-using an available connection from the pool (formerly {self.conn_name})
I think this is because the connection reused event is never fired.
I am not completely sure if I am reading the code below correctly, but I think the ConnectionReused is misplaced and maybe never reached:
conn = self.get_if_exists()
if conn is None:
conn = Connection(
type=Identifier(self.TYPE),
name=None,
state=ConnectionState.INIT,
transaction_open=False,
handle=None,
credentials=self.profile.credentials,
)
self.set_thread_connection(conn)
if conn.name == conn_name and conn.state == "open":
return conn
fire_event(NewConnection(conn_name=conn_name, conn_type=self.TYPE))
if conn.state == "open":
fire_event(ConnectionReused(conn_name=conn_name))
else:
conn.handle = LazyHandle(self.open)
conn.name = conn_name
return connI read the following
- The code fetches an existing connection
- If no connection exists, it creates a new one and adds the connection to be used later
- If the connection has the same name and is open, the connection is returned immediately
- If not, a new connection event is sent
- Then if the connection is open, a connection reused event is sent
- Else lazy handler is set
- Connection is returned
I do not understand why the connection reused event might be sent right after the new connection event is sent.
Also, I do not understand when this conn.name == conn_name evaluates to False. When is a different connection name used within the same thread?
Expected Behavior
conn = self.get_if_exists()
if conn is None:
conn = Connection(
type=Identifier(self.TYPE),
name=None,
state=ConnectionState.INIT,
transaction_open=False,
handle=None,
credentials=self.profile.credentials,
)
self.set_thread_connection(conn)
if conn.state == ConnectionState.OPEN.
fire_event(ConnectionReused(conn_name=conn_name))
else:
fire_event(NewConnection(conn_name=conn_name, conn_type=self.TYPE))
conn.handle = LazyHandle(self.open)
conn.name = conn_name
return connSteps To Reproduce
NA
Relevant log output
NAEnvironment
- OS: NA
- Python: NA
- dbt: v.1.3.0Which database adapter are you using with dbt?
No response
Additional Context
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingloggingsupport_rotationA good task to pick up during support rotationA good task to pick up during support rotation