PowerDNS / lightningstream

Lightning Stream syncs LMDB databases through S3 buckets between multiple servers, including PowerDNS Authoritative server 4.8+ LMDBs
https://doc.powerdns.com/lightningstream/
MIT License
25 stars 15 forks source link

Fix race in syncer test #43

Closed wojas closed 1 year ago

wojas commented 1 year ago

The test did not ensure that the previous Sync run was finished when the next Sync run was started.

It was reproducible locally with:

GOMAXPROCS=1 go test -race  -count=100 ./syncer | grep -A30 'DATA RACE'

Output:

WARNING: DATA RACE
Write at 0x00c000161e60 by goroutine 71:
  runtime.mapassign_faststr()
      /usr/local/Cellar/go/1.19.4/libexec/src/runtime/map_faststr.go:203 +0x0
  powerdns.com/platform/lightningstream/syncer.(*Syncer).LoadOnce()
      /Users/wojas/pdns/work-ls/lightningstream/syncer/sync.go:505 +0xc66
  ...

Previous read at 0x00c000161e60 by goroutine 64:
  runtime.mapiterinit()
      /usr/local/Cellar/go/1.19.4/libexec/src/runtime/map.go:815 +0x0
  powerdns.com/platform/lightningstream/syncer/cleaner.(*Worker).SetCommitted()
      /Users/wojas/pdns/work-ls/lightningstream/syncer/cleaner/cleaner.go:55 +0xee
  ...