use sync.Once to avoid to send drop cutover sentry table to mysql twice by MOON-CLJ · Pull Request #755 · github/gh-ost
i am not sure how to use https://golang.org/pkg/sync/#Once to ensure the following three places which cause drop table?
1, CreateAtomicCutOverSentryTable
| if err := this.CreateAtomicCutOverSentryTable(); err != nil { |
2, drop cut over table
| if _, err := tx.Exec(query); err != nil { |
3, defer clean sentry table
| this.applier.DropAtomicCutOverSentryTableIfExists() |
even more, atomicCutOver will retry some times。although will sleep 1s between retry,two call to goroutine AtomicCutOverMagicLock is not serialize,because atomicCutOver don't wait AtomicCutOverMagicLock to be finished。