Browse Source

Merge branch 'dtm-labs:main' into main

alpha
xyctruth 4 years ago
committed by GitHub
parent
commit
a22e7880c4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 24
      .github/workflows/release.yml
  2. 10
      dtmsvr/storage/sql/sql.go

24
.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

10
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`,

Loading…
Cancel
Save