Skip to content

Commit

Permalink
[release-21.0] [Direct PR] Add RPC to read the reparent journal posit…
Browse files Browse the repository at this point in the history
…ion (#16982)

Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 authored Oct 18, 2024
1 parent b4780ce commit 3fce8ca
Show file tree
Hide file tree
Showing 19 changed files with 2,445 additions and 1,353 deletions.
10 changes: 10 additions & 0 deletions go/test/endtoend/tabletmanager/replication_manager/tablet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,13 @@ func TestReplicationRepairAfterPrimaryTabletChange(t *testing.T) {
// sidecardb should find the desired _vt schema and not apply any new creates or upgrades when the tablet comes up again
require.Equal(t, sidecarDDLCount, int64(0))
}

func TestReparentJournalInfo(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
for _, vttablet := range clusterInstance.Keyspaces[0].Shards[0].Vttablets {
length, err := tmClient.ReadReparentJournalInfo(ctx, getTablet(vttablet.GrpcPort))
require.NoError(t, err)
require.EqualValues(t, 1, length)
}
}
6 changes: 6 additions & 0 deletions go/vt/mysqlctl/reparent.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ This file contains the reparenting methods for mysqlctl.

import (
"context"
"fmt"
"time"

"vitess.io/vitess/go/constants/sidecar"
Expand Down Expand Up @@ -53,6 +54,11 @@ func PopulateReparentJournal(timeCreatedNS int64, actionName, primaryAlias strin
timeCreatedNS, actionName, primaryAlias, posStr).Query
}

// ReadReparentJournalInfoQuery returns the query we use to read information required from Reparent Journal.
func ReadReparentJournalInfoQuery() string {
return fmt.Sprintf("SELECT COUNT(*) FROM %s.reparent_journal", sidecar.GetIdentifier())
}

// queryReparentJournal returns the SQL query to use to query the database
// for a reparent_journal row.
func queryReparentJournal(timeCreatedNS int64) string {
Expand Down
Loading

0 comments on commit 3fce8ca

Please sign in to comment.