Skip to content

Commit

Permalink
fix(pg): replication test (#171)
Browse files Browse the repository at this point in the history
fanyang01 authored Nov 18, 2024
1 parent 1f08352 commit a5d014c
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion backend/connpool.go
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ import (
"context"
stdsql "database/sql"
"errors"
"strings"
"sync"

"github.com/apecloud/myduckserver/catalog"
@@ -156,7 +157,7 @@ func (p *ConnectionPool) Close() error {
})
var lastErr error
for _, tx := range txns {
if err := tx.Rollback(); err != nil {
if err := tx.Rollback(); err != nil && !strings.Contains(err.Error(), "no transaction is active") {
logrus.WithError(err).Warn("Failed to rollback transaction")
lastErr = err
}
3 changes: 2 additions & 1 deletion pgserver/logrepl/replication.go
Original file line number Diff line number Diff line change
@@ -207,6 +207,7 @@ func (r *LogicalReplicator) StartReplication(sqlCtx *sql.Context, slotName strin
state := &replicationState{
replicaCtx: sqlCtx,
slotName: slotName,
lastCommitLSN: lastWrittenLsn,
lastWrittenLSN: lastWrittenLsn,
typeMap: pgtype.NewMap(),
relations: map[uint32]*pglogrepl.RelationMessageV2{},
@@ -263,7 +264,7 @@ func (r *LogicalReplicator) StartReplication(sqlCtx *sql.Context, slotName strin
return handleErrWithRetry(err, false)
}

r.logger.Debugf("Sent Standby status message with WALWritePosition = %s, WALApplyPosition = %s\n", state.lastWrittenLSN+1, state.lastReceivedLSN+1)
r.logger.Debugf("Sent Standby status message with WALWritePosition = %s, WALApplyPosition = %s\n", state.lastReceivedLSN+1, state.lastWrittenLSN+1)
nextStandbyMessageDeadline = time.Now().Add(standbyMessageTimeout)
return nil
}
2 changes: 1 addition & 1 deletion pgserver/logrepl/replication_test.go
Original file line number Diff line number Diff line change
@@ -545,7 +545,7 @@ func RunReplicationScripts(t *testing.T, scripts []ReplicationTest) {
time.Sleep(500 * time.Millisecond)

// for i, script := range scripts {
// if i == 0 {
// if i == 9 {
// RunReplicationScript(t, dsn, script)
// }
// }

0 comments on commit a5d014c

Please sign in to comment.