landed fixseen and got rid of all explicit LOCK TABLES operations (not needed in modern MySQL, especially with transaction semantics)

This commit is contained in:
2026-01-30 18:20:58 -07:00
parent f8e7816f62
commit a0d3f3715a
8 changed files with 87 additions and 76 deletions
+1 -23
View File
@@ -349,14 +349,6 @@ func (t *Topic) Delete(ctx context.Context, u *User, ipaddr string, background *
}
}()
unlock := true
tx.ExecContext(ctx, "LOCK TABLES confs WRITE, topics WRITE, topicsettings WRITE, topicbozo WRITE;")
defer func() {
if unlock {
tx.ExecContext(ctx, "UNLOCK TABLES;")
}
}()
conf, err := AmGetConference(ctx, t.ConfId)
if err != nil {
return err
@@ -373,12 +365,9 @@ func (t *Topic) Delete(ctx context.Context, u *User, ipaddr string, background *
return err
}
err = conf.TouchUpdate(ctx, tx, time.Now())
if err != nil {
if err = conf.TouchUpdate(ctx, tx, time.Now()); err != nil {
return err
}
tx.ExecContext(ctx, "UNLOCK TABLES;")
unlock = false
if err = tx.Commit(); err != nil {
return err
}
@@ -670,14 +659,6 @@ func AmNewTopic(ctx context.Context, conf *Conference, user *User, title string,
}
}()
unlock := true
tx.ExecContext(ctx, "LOCK TABLES confs WRITE, topics WRITE, topicsettings WRITE, posts WRITE, postdata WRITE;")
defer func() {
if unlock {
tx.ExecContext(ctx, "UNLOCK TABLES;")
}
}()
// Insert the new topic into the database.
conf.Mutex.Lock()
rs, err := tx.ExecContext(ctx, "INSERT INTO topics (confid, num, creator_uid, createdate, lastupdate, name) VALUES (?, ?, ?, NOW(), NOW(), ?)",
@@ -732,9 +713,6 @@ func AmNewTopic(ctx context.Context, conf *Conference, user *User, title string,
return nil, err
}
tx.ExecContext(ctx, "UNLOCK TABLES;")
unlock = false
// update the "last posted" date in the conference settings
_, err = conf.TouchPost(ctx, tx, user, topic.CreateDate)
if err != nil {