mirror of
https://github.com/danog/postgres.git
synced 2024-11-26 20:15:02 +01:00
Only mark connection busy on transaction
Underlying handle will take care of ordering other operations.
This commit is contained in:
parent
32369079e6
commit
4fc6425fd8
@ -51,13 +51,7 @@ abstract class AbstractConnection implements Connection {
|
|||||||
yield $this->busy->promise();
|
yield $this->busy->promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->busy = new Deferred;
|
return $this->handle->{$methodName}(...$args);
|
||||||
|
|
||||||
try {
|
|
||||||
return $this->handle->{$methodName}(...$args);
|
|
||||||
} finally {
|
|
||||||
$this->release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,12 +104,6 @@ abstract class AbstractConnection implements Connection {
|
|||||||
*/
|
*/
|
||||||
public function transaction(int $isolation = Transaction::COMMITTED): Promise {
|
public function transaction(int $isolation = Transaction::COMMITTED): Promise {
|
||||||
return call(function () use ($isolation) {
|
return call(function () use ($isolation) {
|
||||||
while ($this->busy) {
|
|
||||||
yield $this->busy->promise();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->busy = new Deferred;
|
|
||||||
|
|
||||||
switch ($isolation) {
|
switch ($isolation) {
|
||||||
case Transaction::UNCOMMITTED:
|
case Transaction::UNCOMMITTED:
|
||||||
yield $this->handle->query("BEGIN TRANSACTION ISOLATION LEVEL READ UNCOMMITTED");
|
yield $this->handle->query("BEGIN TRANSACTION ISOLATION LEVEL READ UNCOMMITTED");
|
||||||
@ -137,6 +125,8 @@ abstract class AbstractConnection implements Connection {
|
|||||||
throw new \Error("Invalid transaction type");
|
throw new \Error("Invalid transaction type");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->busy = new Deferred;
|
||||||
|
|
||||||
$transaction = new Transaction($this->handle, $isolation);
|
$transaction = new Transaction($this->handle, $isolation);
|
||||||
$transaction->onComplete($this->release);
|
$transaction->onComplete($this->release);
|
||||||
return $transaction;
|
return $transaction;
|
||||||
|
Loading…
Reference in New Issue
Block a user