Skip to content

Commit

Permalink
Add 2 more durability policies that allow RDONLY tablets to send semi…
Browse files Browse the repository at this point in the history
…-sync ACKs (#13698)

Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 authored Aug 21, 2023
1 parent ffb2410 commit c57f4ba
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 134 deletions.
10 changes: 9 additions & 1 deletion changelog/18.0/18.0.0/summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
- **[Docker](#docker)**
- [Debian: Bookworm added and made default](#debian-bookworm)
- [Debian: Buster removed](#debian-buster)
- **[Durability Policies](#durability-policies)**
- [New Durability Policies](#new-durability-policies)

## <a id="major-changes"/>Major Changes

Expand Down Expand Up @@ -120,4 +122,10 @@ Bullseye images will still be built and available as long as the OS build is cur

Buster LTS supports will stop in June 2024, and Vitess v18.0 will be supported through October 2024.
To prevent supporting a deprecated buster build for several months after June 2024, we are preemptively
removing Vitess support.
removing Vitess support.

### <a id="durability-policies"/>Durability Policies

#### <a id="new-durability-policies"/>New Durability Policies

2 new inbuilt durability policies have been added to Vitess in this release namely `semi_sync_with_rdonly_ack` and `cross_cell_with_rdonly_ack`. These policies are exactly like `semi_sync` and `cross_cell` respectively, and differ just in the part where the rdonly tablets can also send semi-sync ACKs.
30 changes: 26 additions & 4 deletions go/vt/vtctl/reparentutil/durability.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,24 @@ func init() {
return &durabilityNone{}
})
RegisterDurability("semi_sync", func() Durabler {
return &durabilitySemiSync{}
return &durabilitySemiSync{
rdonlySemiSync: false,
}
})
RegisterDurability("cross_cell", func() Durabler {
return &durabilityCrossCell{}
return &durabilityCrossCell{
rdonlySemiSync: false,
}
})
RegisterDurability("semi_sync_with_rdonly_ack", func() Durabler {
return &durabilitySemiSync{
rdonlySemiSync: true,
}
})
RegisterDurability("cross_cell_with_rdonly_ack", func() Durabler {
return &durabilityCrossCell{
rdonlySemiSync: true,
}
})
RegisterDurability("test", func() Durabler {
return &durabilityTest{}
Expand Down Expand Up @@ -141,7 +155,9 @@ func (d *durabilityNone) isReplicaSemiSync(primary, replica *topodatapb.Tablet)

// durabilitySemiSync has 1 semi-sync setup. It only allows Primary and Replica type servers to acknowledge semi sync
// It returns NeutralPromoteRule for Primary and Replica tablet types, MustNotPromoteRule for everything else
type durabilitySemiSync struct{}
type durabilitySemiSync struct {
rdonlySemiSync bool
}

// promotionRule implements the Durabler interface
func (d *durabilitySemiSync) promotionRule(tablet *topodatapb.Tablet) promotionrule.CandidatePromotionRule {
Expand All @@ -162,6 +178,8 @@ func (d *durabilitySemiSync) isReplicaSemiSync(primary, replica *topodatapb.Tabl
switch replica.Type {
case topodatapb.TabletType_PRIMARY, topodatapb.TabletType_REPLICA:
return true
case topodatapb.TabletType_RDONLY:
return d.rdonlySemiSync
}
return false
}
Expand All @@ -171,7 +189,9 @@ func (d *durabilitySemiSync) isReplicaSemiSync(primary, replica *topodatapb.Tabl
// durabilityCrossCell has 1 semi-sync setup. It only allows Primary and Replica type servers from a different cell to acknowledge semi sync.
// This means that a transaction must be in two cells for it to be acknowledged
// It returns NeutralPromoteRule for Primary and Replica tablet types, MustNotPromoteRule for everything else
type durabilityCrossCell struct{}
type durabilityCrossCell struct {
rdonlySemiSync bool
}

// promotionRule implements the Durabler interface
func (d *durabilityCrossCell) promotionRule(tablet *topodatapb.Tablet) promotionrule.CandidatePromotionRule {
Expand All @@ -192,6 +212,8 @@ func (d *durabilityCrossCell) isReplicaSemiSync(primary, replica *topodatapb.Tab
switch replica.Type {
case topodatapb.TabletType_PRIMARY, topodatapb.TabletType_REPLICA:
return primary.Alias.Cell != replica.Alias.Cell
case topodatapb.TabletType_RDONLY:
return d.rdonlySemiSync && primary.Alias.Cell != replica.Alias.Cell
}
return false
}
Expand Down
Loading

0 comments on commit c57f4ba

Please sign in to comment.