diff --git a/.github/docker-compose.yml b/.github/docker-compose.yml index bb6bbcc8..68e1e517 100644 --- a/.github/docker-compose.yml +++ b/.github/docker-compose.yml @@ -174,8 +174,7 @@ services: ports: - "3306:3306" mysql-v8: - image: mysql:8-debian - platform: linux/x86_64 + image: mysql:8.0 environment: MYSQL_ROOT_PASSWORD: SoupOrSecret MYSQL_DATABASE: _replicator diff --git a/internal/sequencer/core/core.go b/internal/sequencer/core/core.go index 6d28b642..1f544b7d 100644 --- a/internal/sequencer/core/core.go +++ b/internal/sequencer/core/core.go @@ -127,8 +127,7 @@ func (s *Core) Start( // don't want to lose this update. // Synthesize a fake table name from the // group. - stat.Progress().Put(ident.NewTable( - group.Enclosing, group.Name), advanceTo) + stat.Progress().Put(group.GroupTable(), advanceTo) } else { for _, table := range group.Tables { stat.Progress().Put(table, advanceTo) diff --git a/internal/sequencer/sequencer.go b/internal/sequencer/sequencer.go index bb0ea5f3..b3a19c01 100644 --- a/internal/sequencer/sequencer.go +++ b/internal/sequencer/sequencer.go @@ -91,22 +91,35 @@ func NewStat(group *types.TableGroup, progress *ident.TableMap[hlc.Range]) Stat // in the group, or if the group is empty, [hlc.RangeEmpty] will be // returned. func CommonProgress(s Stat) hlc.Range { - if s == nil || len(s.Group().Tables) == 0 { + if s == nil { return hlc.RangeEmpty() } + group := s.Group() progress := s.Progress() commonMax := hlc.New(math.MaxInt64, math.MaxInt) - for _, table := range group.Tables { - ts, ok := progress.Get(table) + + if len(group.Tables) == 0 { + ts, ok := progress.Get(group.GroupTable()) if !ok { return hlc.RangeEmpty() } if hlc.Compare(ts.Max(), commonMax) < 0 { commonMax = ts.Max() } + } else { + for _, table := range group.Tables { + ts, ok := progress.Get(table) + if !ok { + return hlc.RangeEmpty() + } + if hlc.Compare(ts.Max(), commonMax) < 0 { + commonMax = ts.Max() + } + } } + return hlc.RangeExcluding(hlc.Zero(), commonMax) } diff --git a/internal/sequencer/sequtil/lease_group.go b/internal/sequencer/sequtil/lease_group.go index ed2f1f0f..4c356014 100644 --- a/internal/sequencer/sequtil/lease_group.go +++ b/internal/sequencer/sequtil/lease_group.go @@ -53,6 +53,10 @@ func LeaseGroup( names[idx] = fmt.Sprintf("sequtil.Lease.%s", table.Canonical().Raw()) } + if len(names) == 0 { + names = append(names, fmt.Sprintf("sequtil.Lease.%s", group.Name.Raw())) + } + // Run this in a loop in case of non-renewal. This is likely // caused by database overload or any other case where we can't // run SQL in a timely fashion. diff --git a/internal/types/table_group.go b/internal/types/table_group.go index 2c210178..3f4a9ec9 100644 --- a/internal/types/table_group.go +++ b/internal/types/table_group.go @@ -78,3 +78,10 @@ func (g *TableGroup) String() string { sb.WriteString(" ]") return sb.String() } + +// GroupTable is only used as a key when there is no table in this group +// (i.e. len(g.Tables()) == 0) but we still want to track progress of +// of the whole group. +func (g *TableGroup) GroupTable() ident.Table { + return ident.NewTable(g.Enclosing, g.Name) +}