Fix leaked contexts
This commit is contained in:
+2
-1
@@ -377,7 +377,8 @@ func (rc *ReplicationConn) StartReplication(slotName string, startLsn uint64, ti
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, _ := context.WithTimeout(context.Background(), initialReplicationResponseTimeout)
|
ctx, cancelFn := context.WithTimeout(context.Background(), initialReplicationResponseTimeout)
|
||||||
|
defer cancelFn()
|
||||||
|
|
||||||
// The first replication message that comes back here will be (in a success case)
|
// The first replication message that comes back here will be (in a success case)
|
||||||
// a empty CopyBoth that is (apparently) sent as the confirmation that the replication has
|
// a empty CopyBoth that is (apparently) sent as the confirmation that the replication has
|
||||||
|
|||||||
+2
-1
@@ -89,7 +89,8 @@ func TestSimpleReplicationConnection(t *testing.T) {
|
|||||||
for {
|
for {
|
||||||
var message *pgx.ReplicationMessage
|
var message *pgx.ReplicationMessage
|
||||||
|
|
||||||
ctx, _ := context.WithTimeout(context.Background(), time.Second)
|
ctx, cancelFn := context.WithTimeout(context.Background(), time.Second)
|
||||||
|
defer cancelFn()
|
||||||
message, err = replicationConn.WaitForReplicationMessage(ctx)
|
message, err = replicationConn.WaitForReplicationMessage(ctx)
|
||||||
if err != nil && err != context.DeadlineExceeded {
|
if err != nil && err != context.DeadlineExceeded {
|
||||||
t.Fatalf("Replication failed: %v %s", err, reflect.TypeOf(err))
|
t.Fatalf("Replication failed: %v %s", err, reflect.TypeOf(err))
|
||||||
|
|||||||
Reference in New Issue
Block a user