Skip to content

Commit 8838f29

Browse files
egeguneshors
andauthored
K8SPS-365: Fix crashes after MySQL version upgrade (#708)
Co-authored-by: Viacheslav Sarzhan <slava.sarzhan@percona.com>
1 parent 6871675 commit 8838f29

File tree

4 files changed

+15
-27
lines changed

4 files changed

+15
-27
lines changed

cmd/bootstrap/async_replication.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,6 @@ func bootstrapAsyncReplication(ctx context.Context) error {
3737
}
3838
log.Printf("Peers: %v", sets.List(peers))
3939

40-
exists, err := lockExists()
41-
if err != nil {
42-
return errors.Wrap(err, "lock file check")
43-
}
44-
if exists {
45-
log.Printf("Waiting for bootstrap.lock to be deleted")
46-
if err = waitLockRemoval(); err != nil {
47-
return errors.Wrap(err, "wait lock removal")
48-
}
49-
}
5040
primary, replicas, err := getTopology(ctx, peers)
5141
if err != nil {
5242
return errors.Wrap(err, "select donor")

cmd/bootstrap/group_replication.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -309,17 +309,6 @@ func bootstrapGroupReplication(ctx context.Context) error {
309309
log.Printf("bootstrap finished in %f seconds", timer.ElapsedSeconds("total"))
310310
}()
311311

312-
exists, err := lockExists()
313-
if err != nil {
314-
return errors.Wrap(err, "lock file check")
315-
}
316-
if exists {
317-
log.Printf("Waiting for bootstrap.lock to be deleted")
318-
if err = waitLockRemoval(); err != nil {
319-
return errors.Wrap(err, "wait lock removal")
320-
}
321-
}
322-
323312
log.Println("Bootstrap starting...")
324313

325314
localShell, err := connectToLocal(ctx)
@@ -393,8 +382,6 @@ func bootstrapGroupReplication(ctx context.Context) error {
393382
}
394383

395384
log.Printf("Added instance (%s) to InnoDB cluster", localShell.host)
396-
397-
os.Exit(1)
398385
}
399386

400387
rescanNeeded := false

cmd/bootstrap/main.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ func main() {
3434
os.Exit(0)
3535
}
3636

37+
exists, err := lockExists("bootstrap")
38+
if err != nil {
39+
log.Fatalf("failed to check bootstrap.lock: %s", err)
40+
}
41+
if exists {
42+
log.Printf("Waiting for bootstrap.lock to be deleted")
43+
if err = waitLockRemoval("bootstrap"); err != nil {
44+
log.Fatalf("failed to wait for bootstrap.lock: %s", err)
45+
}
46+
}
47+
3748
clusterType := os.Getenv("CLUSTER_TYPE")
3849
switch clusterType {
3950
case "group-replication":

cmd/bootstrap/utils.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ func lookup(svcName string) (sets.Set[string], error) {
6868
return endpoints, nil
6969
}
7070

71-
func lockExists() (bool, error) {
72-
return fileExists("/var/lib/mysql/bootstrap.lock")
71+
func lockExists(lockName string) (bool, error) {
72+
return fileExists(fmt.Sprintf("/var/lib/mysql/%s.lock", lockName))
7373
}
7474

7575
func fileExists(name string) (bool, error) {
@@ -83,9 +83,9 @@ func fileExists(name string) (bool, error) {
8383
return true, nil
8484
}
8585

86-
func waitLockRemoval() error {
86+
func waitLockRemoval(lockName string) error {
8787
for {
88-
exists, err := lockExists()
88+
exists, err := lockExists(lockName)
8989
if err != nil {
9090
return err
9191
}

0 commit comments

Comments
 (0)