Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(PITR): create issue (#1283)
Yilong Li290432ac8f1a
diff --git a/api/issue.go b/api/issue.goindex f9046ab202..60aa47871f 100644--- a/api/issue.go+++ b/api/issue.go@@ -35,6 +35,8 @@ const (IssueDatabaseDataUpdate IssueType = "bb.issue.database.data.update"// IssueDataSourceRequest is the issue type for requesting database sources.IssueDataSourceRequest IssueType = "bb.issue.data-source.request"+ // IssueDatabasePITR is the issue type for performing a Point-in-time Recovery.+ IssueDatabasePITR IssueType = "bb.issue.database.pitr")// IssueFieldID is the field ID for an issue.@@ -178,6 +180,14 @@ type UpdateSchemaGhostContext struct {VCSPushEvent *vcs.PushEvent}+// PITRContext is the issue create context for performing a PITR in a database.+type PITRContext struct {+ DatabaseID int `json:"databaseId"`+ // After the PITR operations, the database will be recovered to the state at this time.+ // Represented in UNIX timestamp in seconds.+ PointInTimeTs int `json:"pointInTimeTs"`+}+// IssueFind is the API message for finding issues.type IssueFind struct {ID *intdiff --git a/api/task.go b/api/task.goindex 34b60bd3ca..532af15f16 100644--- a/api/task.go+++ b/api/task.go@@ -74,12 +74,35 @@ const (TaskDatabaseBackup TaskType = "bb.task.database.backup"// TaskDatabaseRestore is the task type for restoring databases.TaskDatabaseRestore TaskType = "bb.task.database.restore"+ // TaskDatabasePITRRestore is the task type for restoring databases using PITR.+ TaskDatabasePITRRestore TaskType = "bb.task.database.pitr.restore"+ // TaskDatabasePITRCutover is the task type for swapping the pitr and original database.+ TaskDatabasePITRCutover TaskType = "bb.task.database.pitr.cutover"+ // TaskDatabasePITRDelete is the task type fo deleting the original database.+ TaskDatabasePITRDelete TaskType = "bb.task.database.pitr.delete")// These payload types are only used when marshalling to the json format for saving into the database.// So we annotate with json tag using camelCase naming which is consistent with normal// json naming convention+// TaskDatabasePITRRestorePayload is the task payload for database PITR restore.+type TaskDatabasePITRRestorePayload struct {+ // The project owning the database.+ ProjectID int `json:"projectId,omitempty"`+ // After the PITR operations, the database will be recovered to the state at this time.+ // Represented in UNIX timestamp in seconds.+ PointInTimeTs int `json:"pointInTimeTs,omitempty"`+}++// TaskDatabasePITRCutoverPayload is the task payload for PITR cutover.+// It is currently only a placeholder.+type TaskDatabasePITRCutoverPayload struct{}++// TaskDatabasePITRDeletePayload is the task payload for deleting the original database after a successful PITR cutover.+// It is currently only a placeholder.+type TaskDatabasePITRDeletePayload struct{}+// TaskDatabaseCreatePayload is the task payload for creating databases.type TaskDatabaseCreatePayload struct {// The project owning the database.diff --git a/plugin/db/util/driverutil.go b/plugin/db/util/driverutil.goindex e297976309..24cdff6a13 100644--- a/plugin/db/util/driverutil.go+++ b/plugin/db/util/driverutil.go@@ -375,8 +375,8 @@ func Query(ctx context.Context, l *zap.Logger, sqldb *sql.DB, statement string,// FindMigrationHistoryList will find the list of migration history.func FindMigrationHistoryList(ctx context.Context, findMigrationHistoryListQuery string, queryParams []interface{}, driver db.Driver, database string, find *db.MigrationHistoryFind, baseQuery string) ([]*db.MigrationHistory, error) {- // To support `pg` option, util layer will not know which database `migration_history` is located in,- // so wo need connect database provided by params.+ // To support `pg` option, the util layer will not know which database where `migration_history` table is,+ // so we need to connect to the database provided by params.sqldb, err := driver.GetDbConnection(ctx, database)if err != nil {return nil, errdiff --git a/plugin/restore/mysql/mysql.go b/plugin/restore/mysql/mysql.goindex 9d4f1236ba..01a1cfdc58 100644--- a/plugin/restore/mysql/mysql.go+++ b/plugin/restore/mysql/mysql.go@@ -39,7 +39,7 @@ func (r *Restore) RestoreBinlog(ctx context.Context, config BinlogConfig) error// RestorePITR is a wrapper for restore a full backup and a range of incremental backupfunc (r *Restore) RestorePITR(ctx context.Context, fullBackup *bufio.Scanner, config BinlogConfig, database string, timestamp int64) error {- pitrDatabaseName := getPITRDatabaseName(database, timestamp)+ pitrDatabaseName := GetPITRDatabaseName(database, timestamp)query := fmt.Sprintf(""+// Create the pitr database."CREATE DATABASE `%s`;"+@@ -87,7 +87,7 @@ func (r *Restore) SwapPITRDatabase(ctx context.Context, database string, timestadefer txn.Rollback()pitrOldDatabase := getSafeName(database, "old")- pitrDatabaseName := getPITRDatabaseName(database, timestamp)+ pitrDatabaseName := GetPITRDatabaseName(database, timestamp)if _, err := txn.ExecContext(ctx, fmt.Sprintf("CREATE DATABASE `%s`", pitrOldDatabase)); err != nil {return err@@ -123,8 +123,8 @@ func (r *Restore) SwapPITRDatabase(ctx context.Context, database string, timestareturn nil}-// getPITRDatabaseName composes a pitr database name-func getPITRDatabaseName(database string, timestamp int64) string {+// GetPITRDatabaseName composes a pitr database name+func GetPITRDatabaseName(database string, timestamp int64) string {suffix := fmt.Sprintf("pitr_%d", timestamp)return getSafeName(database, suffix)}diff --git a/plugin/restore/mysql/mysql_test.go b/plugin/restore/mysql/mysql_test.goindex 3c20f01052..3e3d5bfbb2 100644--- a/plugin/restore/mysql/mysql_test.go+++ b/plugin/restore/mysql/mysql_test.go@@ -55,7 +55,7 @@ func TestGetPITRDatabaseName(t *testing.T) {},}for _, test := range tests {- name := getPITRDatabaseName(test.database, int64(test.timestamp))+ name := GetPITRDatabaseName(test.database, int64(test.timestamp))a.Equal(test.expected, name)}}diff --git a/server/issue.go b/server/issue.goindex 1dd45ed594..de17c6b231 100644--- a/server/issue.go+++ b/server/issue.go@@ -8,10 +8,12 @@ import ("net/http""strconv""strings"+ "time""github.com/bytebase/bytebase/api""github.com/bytebase/bytebase/common""github.com/bytebase/bytebase/plugin/db"+ restoremysql "github.com/bytebase/bytebase/plugin/restore/mysql""github.com/bytebase/bytebase/plugin/vcs"ghostsql "github.com/github/gh-ost/go/sql""github.com/google/jsonapi"@@ -398,6 +400,18 @@ func (s *Server) createPipelineFromIssue(ctx context.Context, issueCreate *api.Ireturn pipelineCreated, nil}+func (s *Server) getPipelineApprovalPolicyForEnv(ctx context.Context, envID int) (api.TaskStatus, error) {+ taskStatus := api.TaskPendingApproval+ policy, err := s.store.GetPipelineApprovalPolicy(ctx, envID)+ if err != nil {+ return "", fmt.Errorf("failed to get approval policy for environment ID %v, error %v", envID, err)+ }+ if policy.Value == api.PipelineApprovalValueManualNever {+ taskStatus = api.TaskPending+ }+ return taskStatus, nil+}+func (s *Server) getPipelineCreate(ctx context.Context, issueCreate *api.IssueCreate) (*api.PipelineCreate, error) {switch issueCreate.Type {case api.IssueDatabaseCreate:@@ -499,25 +513,22 @@ func (s *Server) getPipelineCreate(ctx context.Context, issueCreate *api.IssueCrschemaVersion = common.DefaultMigrationVersion()}- payload := api.TaskDatabaseCreatePayload{}- payload.ProjectID = issueCreate.ProjectID- payload.CharacterSet = c.CharacterSet- payload.Collation = c.Collation- payload.Labels = c.Labels- payload.SchemaVersion = schemaVersion+ payload := api.TaskDatabaseCreatePayload{+ ProjectID: issueCreate.ProjectID,+ CharacterSet: c.CharacterSet,+ Collation: c.Collation,+ Labels: c.Labels,+ SchemaVersion: schemaVersion,+ }payload.DatabaseName, payload.Statement = getDatabaseNameAndStatement(instance.Engine, c.DatabaseName, c.CharacterSet, c.Collation, schema)bytes, err := json.Marshal(payload)if err != nil {return nil, fmt.Errorf("failed to create database creation task, unable to marshal payload %w", err)}- taskStatus := api.TaskPendingApproval- policy, err := s.store.GetPipelineApprovalPolicy(ctx, instance.EnvironmentID)+ taskStatus, err := s.getPipelineApprovalPolicyForEnv(ctx, instance.EnvironmentID)if err != nil {- return nil, fmt.Errorf("failed to get approval policy for environment ID %v, error %v", instance.EnvironmentID, err)- }- if policy.Value == api.PipelineApprovalValueManualNever {- taskStatus = api.TaskPending+ return nil, err}if c.BackupID != 0 {@@ -573,7 +584,7 @@ func (s *Server) getPipelineCreate(ctx context.Context, issueCreate *api.IssueCr}return &api.PipelineCreate{- Name: fmt.Sprintf("Pipeline - Create database %v", payload.DatabaseName),+ Name: fmt.Sprintf("Pipeline - Create database %s", payload.DatabaseName),StageList: []api.StageCreate{{Name: "Create database",@@ -581,7 +592,7 @@ func (s *Server) getPipelineCreate(ctx context.Context, issueCreate *api.IssueCrTaskList: []api.TaskCreate{{InstanceID: c.InstanceID,- Name: fmt.Sprintf("Create database %v", payload.DatabaseName),+ Name: fmt.Sprintf("Create database %s", payload.DatabaseName),Status: taskStatus,Type: api.TaskDatabaseCreate,DatabaseName: payload.DatabaseName,@@ -592,6 +603,42 @@ func (s *Server) getPipelineCreate(ctx context.Context, issueCreate *api.IssueCr},}, nil+ case api.IssueDatabasePITR:+ c := api.PITRContext{}+ if err := json.Unmarshal([]byte(issueCreate.CreateContext), &c); err != nil {+ return nil, err+ }++ database, err := s.store.GetDatabase(ctx, &api.DatabaseFind{ID: &c.DatabaseID})+ if err != nil {+ return nil, echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch database ID: %v", c.DatabaseID)).SetInternal(err)+ }+ if database == nil {+ return nil, echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database ID not found: %d", c.DatabaseID))+ }++ taskStatus, err := s.getPipelineApprovalPolicyForEnv(ctx, database.Instance.EnvironmentID)+ if err != nil {+ return nil, err+ }++ taskCreateList, taskIndexDAGList, err := createPITRTaskList(database, issueCreate.ProjectID, taskStatus, c.PointInTimeTs)+ if err != nil {+ return nil, err+ }++ return &api.PipelineCreate{+ Name: "Database Point-in-time Recovery pipeline",+ StageList: []api.StageCreate{+ {+ Name: "PITR",+ EnvironmentID: database.Instance.Environment.ID,+ TaskList: taskCreateList,+ TaskIndexDAGList: taskIndexDAGList,+ },+ },+ }, nil+case api.IssueDatabaseSchemaUpdate, api.IssueDatabaseDataUpdate:c := api.UpdateSchemaContext{}if err := json.Unmarshal([]byte(issueCreate.CreateContext), &c); err != nil {@@ -661,14 +708,12 @@ func (s *Server) getPipelineCreate(ctx context.Context, issueCreate *api.IssueCrfor _, database := range databaseList {environmentSet[database.Instance.Environment.Name] = trueenvironmentID = database.Instance.EnvironmentID- taskStatus := api.TaskPendingApproval- policy, err := s.store.GetPipelineApprovalPolicy(ctx, environmentID)++ taskStatus, err := s.getPipelineApprovalPolicyForEnv(ctx, environmentID)if err != nil {- return nil, fmt.Errorf("failed to get approval policy for environment ID %v, error %v", environmentID, err)- }- if policy.Value == api.PipelineApprovalValueManualNever {- taskStatus = api.TaskPending+ return nil, err}+taskCreate, err := getUpdateTask(database, c.MigrationType, c.VCSPushEvent, d, schemaVersion, taskStatus)if err != nil {return nil, err@@ -703,13 +748,9 @@ func (s *Server) getPipelineCreate(ctx context.Context, issueCreate *api.IssueCrreturn nil, echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database ID not found: %d", d.DatabaseID))}- taskStatus := api.TaskPendingApproval- policy, err := s.store.GetPipelineApprovalPolicy(ctx, database.Instance.EnvironmentID)+ taskStatus, err := s.getPipelineApprovalPolicyForEnv(ctx, database.Instance.EnvironmentID)if err != nil {- return nil, fmt.Errorf("failed to get approval policy for environment ID %v, error %v", database.Instance.EnvironmentID, err)- }- if policy.Value == api.PipelineApprovalValueManualNever {- taskStatus = api.TaskPending+ return nil, err}taskCreate, err := getUpdateTask(database, c.MigrationType, c.VCSPushEvent, d, schemaVersion, taskStatus)@@ -763,13 +804,9 @@ func (s *Server) getPipelineCreate(ctx context.Context, issueCreate *api.IssueCrreturn nil, echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("database ID not found: %d", detail.DatabaseID))}- taskStatus := api.TaskPendingApproval- policy, err := s.store.GetPipelineApprovalPolicy(ctx, database.Instance.EnvironmentID)+ taskStatus, err := s.getPipelineApprovalPolicyForEnv(ctx, database.Instance.EnvironmentID)if err != nil {- return nil, fmt.Errorf("failed to get approval policy for environment ID %v, error %w", database.Instance.EnvironmentID, err)- }- if policy.Value == api.PipelineApprovalValueManualNever {- taskStatus = api.TaskPending+ return nil, err}taskCreateList, taskIndexDAGList, err := createGhostTaskList(database, c.VCSPushEvent, detail, schemaVersion, taskStatus)@@ -832,72 +869,137 @@ func getUpdateTask(database *api.Database, migrationType db.MigrationType, vcsPu}, nil}-// creates ghost TaskCreate list and dependency+// creates PITR TaskCreate list and dependency+func createPITRTaskList(database *api.Database, projectID int, taskStatus api.TaskStatus, recoveryTime int) ([]api.TaskCreate, []api.TaskIndexDAG, error) {+ var taskCreateList []api.TaskCreate++ pitrTimestamp := time.Now().Unix()+ pitrDatabaseName := restoremysql.GetPITRDatabaseName(database.Name, pitrTimestamp)++ // task: create and restore to PITR database+ payloadRestore := api.TaskDatabasePITRRestorePayload{+ ProjectID: projectID,+ PointInTimeTs: recoveryTime,+ }+ bytesRestore, err := json.Marshal(payloadRestore)+ if err != nil {+ return nil, nil, fmt.Errorf("failed to create PITR restore task, unable to marshal payload, error[%w]", err)+ }++ taskCreateList = append(taskCreateList, api.TaskCreate{+ Name: fmt.Sprintf("Restore PITR database %s", pitrDatabaseName),+ InstanceID: database.InstanceID,+ DatabaseID: &database.ID,+ Status: taskStatus,+ Type: api.TaskDatabasePITRRestore,+ Payload: string(bytesRestore),+ })++ // task: swap PITR and the original database+ payloadCutover := api.TaskDatabasePITRCutoverPayload{}+ bytesCutover, err := json.Marshal(payloadCutover)+ if err != nil {+ return nil, nil, fmt.Errorf("failed to create PITR cutover task, unable to marshal payload, error[%w]", err)+ }++ taskCreateList = append(taskCreateList, api.TaskCreate{+ Name: fmt.Sprintf("Swap PITR and the original database %s", pitrDatabaseName),+ InstanceID: database.InstanceID,+ DatabaseID: &database.ID,+ Status: taskStatus,+ Type: api.TaskDatabasePITRCutover,+ Payload: string(bytesCutover),+ })++ // task: delete the original database+ payloadDelete := api.TaskDatabasePITRDeletePayload{}+ BytesDelete, err := json.Marshal(payloadDelete)+ if err != nil {+ return nil, nil, fmt.Errorf("failed to create PITR delete task, unable to marshal payload, error[%w]", err)+ }++ taskCreateList = append(taskCreateList, api.TaskCreate{+ Name: fmt.Sprintf("Delete the original database %s", pitrDatabaseName),+ InstanceID: database.InstanceID,+ DatabaseID: &database.ID,+ Status: taskStatus,+ Type: api.TaskDatabasePITRDelete,+ Payload: string(BytesDelete),+ })++ taskIndexDAGList := []api.TaskIndexDAG{+ {FromIndex: 0, ToIndex: 1},+ {FromIndex: 1, ToIndex: 2},+ }++ return taskCreateList, taskIndexDAGList, nil+}++// creates gh-ost TaskCreate list and dependencyfunc createGhostTaskList(database *api.Database, vcsPushEvent *vcs.PushEvent, detail *api.UpdateSchemaGhostDetail, schemaVersion string, taskStatus api.TaskStatus) ([]api.TaskCreate, []api.TaskIndexDAG, error) {var taskCreateList []api.TaskCreate- { // task "sync"- payload := api.TaskDatabaseSchemaUpdateGhostSyncPayload{}- payload.Statement = detail.Statement- payload.SchemaVersion = schemaVersion- if vcsPushEvent != nil {- payload.VCSPushEvent = vcsPushEvent- }- bytes, err := json.Marshal(payload)- if err != nil {- return nil, nil, echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to marshal database schema update gh-ost sync payload, error: %v", err))- }- taskCreateList = append(taskCreateList, api.TaskCreate{- Name: fmt.Sprintf("Update %q schema gh-ost sync", database.Name),- InstanceID: database.InstanceID,- DatabaseID: &database.ID,- Status: taskStatus,- Type: api.TaskDatabaseSchemaUpdateGhostSync,- Statement: detail.Statement,- EarliestAllowedTs: detail.EarliestAllowedTs,- MigrationType: db.Migrate,- Payload: string(bytes),- })- }- { // task "cutover"- payload := api.TaskDatabaseSchemaUpdateGhostCutoverPayload{}- bytes, err := json.Marshal(payload)- if err != nil {- return nil, nil, echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to marshal database schema update ghost cutover payload, error: %v", err))- }- taskCreateList = append(taskCreateList, api.TaskCreate{- Name: fmt.Sprintf("Update %q schema gh-ost cutover", database.Name),- InstanceID: database.InstanceID,- DatabaseID: &database.ID,- Status: taskStatus,- Type: api.TaskDatabaseSchemaUpdateGhostCutover,- EarliestAllowedTs: detail.EarliestAllowedTs,- Payload: string(bytes),- })- }- { // task "drop original table"- parser := ghostsql.NewParserFromAlterStatement(detail.Statement)- tableName := ""- if parser.HasExplicitTable() {- tableName = fmt.Sprintf("_%v_del", parser.GetExplicitTable())- }- payload := api.TaskDatabaseSchemaUpdateGhostDropOriginalTablePayload{- DatabaseName: database.Name,- TableName: tableName,- }- bytes, err := json.Marshal(payload)- if err != nil {- return nil, nil, echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to marshal database schema update ghost drop original table payload, error: %v", err))- }- taskCreateList = append(taskCreateList, api.TaskCreate{- Name: "Update %q schema gh-ost drop original table",- InstanceID: database.Instance.ID,- DatabaseID: &database.ID,- Status: taskStatus,- Type: api.TaskDatabaseSchemaUpdateGhostDropOriginalTable,- EarliestAllowedTs: detail.EarliestAllowedTs,- Payload: string(bytes),- })+ // task "sync"+ payloadSync := api.TaskDatabaseSchemaUpdateGhostSyncPayload{+ Statement: detail.Statement,+ SchemaVersion: schemaVersion,+ VCSPushEvent: vcsPushEvent,+ }+ bytesSync, err := json.Marshal(payloadSync)+ if err != nil {+ return nil, nil, echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to marshal database schema update gh-ost sync payload, error: %v", err))+ }+ taskCreateList = append(taskCreateList, api.TaskCreate{+ Name: fmt.Sprintf("Update %q schema gh-ost sync", database.Name),+ InstanceID: database.InstanceID,+ DatabaseID: &database.ID,+ Status: taskStatus,+ Type: api.TaskDatabaseSchemaUpdateGhostSync,+ Statement: detail.Statement,+ EarliestAllowedTs: detail.EarliestAllowedTs,+ MigrationType: db.Migrate,+ Payload: string(bytesSync),+ })++ // task "cutover"+ payloadCutover := api.TaskDatabaseSchemaUpdateGhostCutoverPayload{}+ bytesCutover, err := json.Marshal(payloadCutover)+ if err != nil {+ return nil, nil, echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to marshal database schema update ghost cutover payload, error: %v", err))}+ taskCreateList = append(taskCreateList, api.TaskCreate{+ Name: fmt.Sprintf("Update %q schema gh-ost cutover", database.Name),+ InstanceID: database.InstanceID,+ DatabaseID: &database.ID,+ Status: taskStatus,+ Type: api.TaskDatabaseSchemaUpdateGhostCutover,+ EarliestAllowedTs: detail.EarliestAllowedTs,+ Payload: string(bytesCutover),+ })++ // task "drop original table"+ parser := ghostsql.NewParserFromAlterStatement(detail.Statement)+ tableName := ""+ if parser.HasExplicitTable() {+ tableName = fmt.Sprintf("_%v_del", parser.GetExplicitTable())+ }+ payloadDrop := api.TaskDatabaseSchemaUpdateGhostDropOriginalTablePayload{+ DatabaseName: database.Name,+ TableName: tableName,+ }+ bytesDrop, err := json.Marshal(payloadDrop)+ if err != nil {+ return nil, nil, echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to marshal database schema update ghost drop original table payload, error: %v", err))+ }+ taskCreateList = append(taskCreateList, api.TaskCreate{+ Name: "Update %q schema gh-ost drop original table",+ InstanceID: database.Instance.ID,+ DatabaseID: &database.ID,+ Status: taskStatus,+ Type: api.TaskDatabaseSchemaUpdateGhostDropOriginalTable,+ EarliestAllowedTs: detail.EarliestAllowedTs,+ Payload: string(bytesDrop),+ })+// The below list means that taskCreateList[0] blocks taskCreateList[1], and taskCreateList[1] blocks taskCreateList[2].// In other words, task "sync" blocks task "cutover", and task "cutover" blocks task "drop original table".taskIndexDAGList := []api.TaskIndexDAG{diff --git a/store/issue.go b/store/issue.goindex e81465605f..034c592c0f 100644--- a/store/issue.go+++ b/store/issue.go@@ -176,7 +176,7 @@ func (s *Store) CreatePipelineValidateOnly(ctx context.Context, create *api.PipeEnvironmentID: sc.EnvironmentID,}// We don't know IDs before inserting, so we use array index instead.- // indexBlockedByIndex[indexA] holds indexes of the tasks that block taskList[indexA]+ // indexBlockedByIndex[indexA] holds indices of the tasks that block taskList[indexA]indexBlockedByIndex := make(map[int][]int)for _, indexDAG := range sc.TaskIndexDAGList {indexBlockedByIndex[indexDAG.ToIndex] = append(indexBlockedByIndex[indexDAG.ToIndex], indexDAG.FromIndex)diff --git a/store/table_index.go b/store/table_index.goindex e2a6734bcf..a29e615a28 100644--- a/store/table_index.go+++ b/store/table_index.go@@ -30,7 +30,7 @@ func (s *Store) CreateIndex(ctx context.Context, create *api.IndexCreate) (*api.return index, nil}-// FindIndex retrieves a list of indexes based on find.+// FindIndex retrieves a list of indices based on find.func (s *Store) FindIndex(ctx context.Context, find *api.IndexFind) ([]*api.Index, error) {tx, err := s.db.BeginTx(ctx, nil)if err != nil {@@ -63,7 +63,7 @@ func (s *Store) GetIndex(ctx context.Context, find *api.IndexFind) (*api.Index,if len(list) == 0 {return nil, nil} else if len(list) > 1 {- return nil, &common.Error{Code: common.Conflict, Err: fmt.Errorf("found %d indexs with filter %+v, expect 1", len(list), find)}+ return nil, &common.Error{Code: common.Conflict, Err: fmt.Errorf("found %d indices with filter %+v, expect 1", len(list), find)}}return list[0], nil}