Revert "fix: database lock by adding lock function when set schedule"
This reverts commit 0c784b4cc9
.
This commit is contained in:
parent
cb74b0d817
commit
a5c2b337f4
|
@ -96,28 +96,26 @@ func (api *API) PubsubStartDownloadSubreddit(ctx context.Context, params PubsubS
|
||||||
return errs.Wrapw(err, "failed to verify subreddit existence", "params", params)
|
return errs.Wrapw(err, "failed to verify subreddit existence", "params", params)
|
||||||
}
|
}
|
||||||
|
|
||||||
api.lockf(func() {
|
err = api.withTransaction(ctx, func(exec bob.Executor) error {
|
||||||
err = api.withTransaction(ctx, func(exec bob.Executor) error {
|
_, err := api.scheduleSet(ctx, exec, ScheduleSetParams{
|
||||||
_, err := api.scheduleSet(ctx, exec, ScheduleSetParams{
|
Subreddit: subreddit.Name,
|
||||||
Subreddit: subreddit.Name,
|
Status: ScheduleStatusEnqueued,
|
||||||
Status: ScheduleStatusEnqueued,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
payload, err := json.Marshal(subreddit)
|
|
||||||
if err != nil {
|
|
||||||
return errs.Wrapw(err, "failed to marshal subreddit")
|
|
||||||
}
|
|
||||||
|
|
||||||
err = api.publisher.Publish(downloadTopic, message.NewMessage(watermill.NewUUID(), payload))
|
|
||||||
if err != nil {
|
|
||||||
return errs.Wrapw(err, "failed to enqueue reddit download", "params", params)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
payload, err := json.Marshal(subreddit)
|
||||||
|
if err != nil {
|
||||||
|
return errs.Wrapw(err, "failed to marshal subreddit")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = api.publisher.Publish(downloadTopic, message.NewMessage(watermill.NewUUID(), payload))
|
||||||
|
if err != nil {
|
||||||
|
return errs.Wrapw(err, "failed to enqueue reddit download", "params", params)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
})
|
})
|
||||||
|
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue