Skip to content

Commit 8868ebe

Browse files
ACPT-1413
Removed getProcessConnectionName from lib/internal/Magento/Framework/App/ResourceConnection.php We cannot have separate connections in this class based on the process id. The reason is that because some objects have references to the connection object before the fork, and therefore the child would be accessing a different data connection in some classes, which could break the expected transaction functionality. In other words, the getProcessConnectionName functionality did not work in cases where objects used by child process had a member variable to the parent process's connection (Mysql Adapter). We added avoidReusingParentProcessConnection() in Mysql adapter to avoid using the parent's connection.
1 parent d1c64cc commit 8868ebe

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

lib/internal/Magento/Framework/App/ResourceConnection.php

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function closeConnection($resourceName = self::DEFAULT_CONNECTION)
128128
}
129129
$this->connections = [];
130130
} else {
131-
$processConnectionName = $this->getProcessConnectionName($this->config->getConnectionName($resourceName));
131+
$processConnectionName = $this->config->getConnectionName($resourceName);
132132
if (isset($this->connections[$processConnectionName])) {
133133
if ($this->connections[$processConnectionName] !== null) {
134134
$this->connections[$processConnectionName]->closeConnection();
@@ -147,9 +147,8 @@ public function closeConnection($resourceName = self::DEFAULT_CONNECTION)
147147
*/
148148
public function getConnectionByName($connectionName)
149149
{
150-
$processConnectionName = $this->getProcessConnectionName($connectionName);
151-
if (isset($this->connections[$processConnectionName])) {
152-
return $this->connections[$processConnectionName];
150+
if (isset($this->connections[$connectionName])) {
151+
return $this->connections[$connectionName];
153152
}
154153

155154
$connectionConfig = $this->deploymentConfig->get(
@@ -162,26 +161,10 @@ public function getConnectionByName($connectionName)
162161
throw new \DomainException('Connection "' . $connectionName . '" is not defined');
163162
}
164163

165-
$this->connections[$processConnectionName] = $connection;
164+
$this->connections[$connectionName] = $connection;
166165
return $connection;
167166
}
168167

169-
/**
170-
* Get conneciton name for process.
171-
*
172-
* @param string $connectionName
173-
* @return string
174-
*/
175-
private function getProcessConnectionName($connectionName)
176-
{
177-
// Note: We cannot have separate connections in this class based ond the process id.
178-
// The reason is because some objects have references to the connection object before the fork,
179-
// and therefore the child would be accessing a different data connection in some classes, which could break
180-
// the expected transaction functionality.
181-
// We added avoidReusingParentProcessConnection() in Mysql adapter to avoid using the parent's connection.
182-
return $connectionName;
183-
}
184-
185168
/**
186169
* Get resource table name, validated by db adapter.
187170
*

0 commit comments

Comments
 (0)