Implement in-application mutex to reduce DB_LOCKED errors
This commit is contained in:
@@ -57,7 +57,7 @@ func (h APIHandler) ListChannels(pctx ginext.PreContext) ginext.HTTPResponse {
|
||||
}
|
||||
defer ctx.Cancel()
|
||||
|
||||
return h.app.DoRequest(ctx, g, func(ctx *logic.AppContext, finishSuccess func(r ginext.HTTPResponse) ginext.HTTPResponse) ginext.HTTPResponse {
|
||||
return h.app.DoRequest(ctx, g, models.TLockRead, func(ctx *logic.AppContext, finishSuccess func(r ginext.HTTPResponse) ginext.HTTPResponse) ginext.HTTPResponse {
|
||||
|
||||
if permResp := ctx.CheckPermissionUserRead(u.UserID); permResp != nil {
|
||||
return *permResp
|
||||
@@ -143,7 +143,7 @@ func (h APIHandler) GetChannel(pctx ginext.PreContext) ginext.HTTPResponse {
|
||||
}
|
||||
defer ctx.Cancel()
|
||||
|
||||
return h.app.DoRequest(ctx, g, func(ctx *logic.AppContext, finishSuccess func(r ginext.HTTPResponse) ginext.HTTPResponse) ginext.HTTPResponse {
|
||||
return h.app.DoRequest(ctx, g, models.TLockRead, func(ctx *logic.AppContext, finishSuccess func(r ginext.HTTPResponse) ginext.HTTPResponse) ginext.HTTPResponse {
|
||||
|
||||
if permResp := ctx.CheckPermissionUserRead(u.UserID); permResp != nil {
|
||||
return *permResp
|
||||
@@ -197,7 +197,7 @@ func (h APIHandler) CreateChannel(pctx ginext.PreContext) ginext.HTTPResponse {
|
||||
}
|
||||
defer ctx.Cancel()
|
||||
|
||||
return h.app.DoRequest(ctx, g, func(ctx *logic.AppContext, finishSuccess func(r ginext.HTTPResponse) ginext.HTTPResponse) ginext.HTTPResponse {
|
||||
return h.app.DoRequest(ctx, g, models.TLockReadWrite, func(ctx *logic.AppContext, finishSuccess func(r ginext.HTTPResponse) ginext.HTTPResponse) ginext.HTTPResponse {
|
||||
|
||||
if permResp := ctx.CheckPermissionUserAdmin(u.UserID); permResp != nil {
|
||||
return *permResp
|
||||
@@ -304,7 +304,7 @@ func (h APIHandler) UpdateChannel(pctx ginext.PreContext) ginext.HTTPResponse {
|
||||
}
|
||||
defer ctx.Cancel()
|
||||
|
||||
return h.app.DoRequest(ctx, g, func(ctx *logic.AppContext, finishSuccess func(r ginext.HTTPResponse) ginext.HTTPResponse) ginext.HTTPResponse {
|
||||
return h.app.DoRequest(ctx, g, models.TLockReadWrite, func(ctx *logic.AppContext, finishSuccess func(r ginext.HTTPResponse) ginext.HTTPResponse) ginext.HTTPResponse {
|
||||
|
||||
if permResp := ctx.CheckPermissionUserAdmin(u.UserID); permResp != nil {
|
||||
return *permResp
|
||||
@@ -428,7 +428,7 @@ func (h APIHandler) ListChannelMessages(pctx ginext.PreContext) ginext.HTTPRespo
|
||||
}
|
||||
defer ctx.Cancel()
|
||||
|
||||
return h.app.DoRequest(ctx, g, func(ctx *logic.AppContext, finishSuccess func(r ginext.HTTPResponse) ginext.HTTPResponse) ginext.HTTPResponse {
|
||||
return h.app.DoRequest(ctx, g, models.TLockRead, func(ctx *logic.AppContext, finishSuccess func(r ginext.HTTPResponse) ginext.HTTPResponse) ginext.HTTPResponse {
|
||||
|
||||
trimmed := langext.Coalesce(q.Trimmed, true)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user