8000 Add final commit/abort statistic · postgrespro/postgres_cluster@c2f8668 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c2f8668

Browse files
committed
Add final commit/abort statistic
1 parent cae87f3 commit c2f8668

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

contrib/pg_xtm/tests/transfers-fdw.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const (
1212
TRANSFER_CONNECTIONS = 8
1313
INIT_AMOUNT = 10000
1414
N_ITERATIONS = 10000
15-
N_ACCOUNTS = TRANSFER_CONNECTIONS//100000
15+
N_ACCOUNTS = 100000//TRANSFER_CONNECTIONS
1616
ISOLATION_LEVEL = "repeatable read"
1717
//ISOLATION_LEVEL = "read committed"
1818
)
@@ -70,7 +70,7 @@ func prepare_db() {
7070
exec(conn2, "commit")
7171
}
7272

73-
func progress(total int, cCommits chan int, cAborts chan int) {
73+
func progress(total int, cCommits chan int, cAborts chan int, wg *sync.WaitGroup) {
7474
commits := 0
7575
aborts := 0
7676
start := time.Now()
@@ -86,6 +86,8 @@ func progress(total int, cCommits chan int, cAborts chan int) {
8686
start = time.Now()
8787
}
8888
}
89+
fmt.Printf("Done: %d commits, %d aborts\n", commits, aborts)
90+
wg.Done()
8991
}
9092

9193
func transfer(id int, cCommits chan int, cAborts chan int, wg *sync.WaitGroup) {
@@ -164,12 +166,14 @@ func inspect(wg *sync.WaitGroup) {
164166
func main() {
165167
var transferWg sync.WaitGroup
166168
var inspectWg sync.WaitGroup
169+
var progressWg sync.WaitGroup
167170

168171
prepare_db()
169172

170173
cCommits := make(chan int)
171174
cAborts := make(chan int)
172-
go progress(TRANSFER_CONNECTIONS * N_ITERATIONS, cCommits, cAborts)
175+
progressWg.Add(1)
176+
go progress(TRANSFER_CONNECTIONS * N_ITERATIONS, cCommits, cAborts, &progressWg)
173177

174178
transferWg.Add(TRANSFER_CONNECTIONS)
175179
for i:=0; i<TRANSFER_CONNECTIONS; i++ {
@@ -183,7 +187,8 @@ func main() {
183187
running = false
184188
inspectWg.Wait()
185189

186-
fmt.Printf("done\n")
190+
close(cCommits)
191+
progressWg.Wait()
187192
}
188193

189194
func exec(conn *pgx.Conn, stmt string, arguments ...interface{}) {

0 commit comments

Comments
 (0)
0