From 60abdfc6cdbedea29fe9297e824ac8d451ccaa57 Mon Sep 17 00:00:00 2001 From: yedf2 <120050102@qq.com> Date: Wed, 22 Jun 2022 15:31:32 +0800 Subject: [PATCH 1/2] next_cron_time query use time string. independent of db timezone --- dtmsvr/storage/sql/sql.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dtmsvr/storage/sql/sql.go b/dtmsvr/storage/sql/sql.go index 7ad4cbc..0ad3565 100644 --- a/dtmsvr/storage/sql/sql.go +++ b/dtmsvr/storage/sql/sql.go @@ -138,9 +138,10 @@ func (s *Store) TouchCronTime(global *storage.TransGlobalStore, nextCronInterval func (s *Store) LockOneGlobalTrans(expireIn time.Duration) *storage.TransGlobalStore { db := dbGet() owner := shortuuid.New() + nextCronTime := getTimeStr(int64(expireIn / time.Second)) where := map[string]string{ - dtmimp.DBTypeMysql: fmt.Sprintf(`next_cron_time < date_add(now(), interval %d second) and status in ('prepared', 'aborting', 'submitted') limit 1`, int(expireIn/time.Second)), - dtmimp.DBTypePostgres: fmt.Sprintf(`id in (select id from trans_global where next_cron_time < current_timestamp + interval '%d second' and status in ('prepared', 'aborting', 'submitted') limit 1 )`, int(expireIn/time.Second)), + dtmimp.DBTypeMysql: fmt.Sprintf(`next_cron_time < '%s' and status in ('prepared', 'aborting', 'submitted') limit 1`, nextCronTime), + dtmimp.DBTypePostgres: fmt.Sprintf(`id in (select id from trans_global where next_cron_time < '%s' and status in ('prepared', 'aborting', 'submitted') limit 1 )`, nextCronTime), }[conf.Store.Driver] sql := fmt.Sprintf(`UPDATE trans_global SET update_time='%s',next_cron_time='%s', owner='%s' WHERE %s`, @@ -162,9 +163,10 @@ func (s *Store) LockOneGlobalTrans(expireIn time.Duration) *storage.TransGlobalS // ResetCronTime reset nextCronTime // unfinished transactions need to be retried as soon as possible after business downtime is recovered func (s *Store) ResetCronTime(after time.Duration, limit int64) (succeedCount int64, hasRemaining bool, err error) { + nextCronTime := getTimeStr(int64(after / time.Second)) where := map[string]string{ - dtmimp.DBTypeMysql: fmt.Sprintf(`next_cron_time > date_add(now(), interval %d second) and status in ('prepared', 'aborting', 'submitted') limit %d`, int(after/time.Second), limit), - dtmimp.DBTypePostgres: fmt.Sprintf(`id in (select id from trans_global where next_cron_time > current_timestamp + interval '%d second' and status in ('prepared', 'aborting', 'submitted') limit %d )`, int(after/time.Second), limit), + dtmimp.DBTypeMysql: fmt.Sprintf(`next_cron_time > '%s' and status in ('prepared', 'aborting', 'submitted') limit %d`, nextCronTime, limit), + dtmimp.DBTypePostgres: fmt.Sprintf(`id in (select id from trans_global where next_cron_time > '%s' and status in ('prepared', 'aborting', 'submitted') limit %d )`, nextCronTime, limit), }[conf.Store.Driver] sql := fmt.Sprintf(`UPDATE trans_global SET update_time='%s',next_cron_time='%s' WHERE %s`, From 2e8508c43ef4b395eb862e33db9362773c94caa4 Mon Sep 17 00:00:00 2001 From: yedf2 <120050102@qq.com> Date: Wed, 22 Jun 2022 16:17:23 +0800 Subject: [PATCH 2/2] update release order --- .github/workflows/release.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 59a61df..2edc31e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,18 @@ jobs: - name: Check out code uses: actions/checkout@v3 + - name: Validates GO releaser config + uses: docker://goreleaser/goreleaser:v1.7.0 + with: + args: check + + - name: Create release on GitHub + uses: docker://goreleaser/goreleaser:v1.7.0 + with: + args: release -f helper/.goreleaser.yml --rm-dist + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + - name: Setup node uses: actions/setup-node@v3 with: @@ -49,18 +61,6 @@ jobs: echo > dist/placeholder cd .. - - name: Validates GO releaser config - uses: docker://goreleaser/goreleaser:v1.7.0 - with: - args: check - - - name: Create release on GitHub - uses: docker://goreleaser/goreleaser:v1.7.0 - with: - args: release -f helper/.goreleaser.yml --rm-dist - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} - - name: Create Docker id: meta uses: docker/metadata-action@v3