Skip to content

Commit 68cc55f

Browse files
authored
Revert "Add recovery window (#21451)" (#21497)
Revert "Add recovery window" Approved by: @XuPeng-SH, @qingxinhome, @ouyuanning, @heni02, @LeftHandCold, @iamlinjunhong, @sukki37
1 parent 605903c commit 68cc55f

30 files changed

+9759
-11712
lines changed

pkg/bootstrap/upgrade.go

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ func (s *service) initUpgrade() {
3939
// TODO: When v2.0.1 release, open the commented code as follows, Enable v2.0.2 upgrade package
4040
s.handles = append(s.handles, v2_0_2.Handler)
4141
s.handles = append(s.handles, v2_0_3.Handler)
42-
4342
}
4443

4544
func (s *service) getFinalVersionHandle() VersionHandle {

pkg/bootstrap/versions/v2_0_3/cluster_upgrade_list.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ var upg_mo_pitr_add_status = versions.UpgradeEntry{
3434
UpgType: versions.ADD_COLUMN,
3535
UpgSql: "alter table mo_catalog.mo_pitr add column pitr_status TINYINT UNSIGNED DEFAULT 1 after pitr_unit",
3636
CheckFunc: func(txn executor.TxnExecutor, accountId uint32) (bool, error) {
37-
colInfo, err := versions.CheckTableColumn(txn, accountId, catalog.MO_CATALOG, catalog.MO_PITR, "pitr_status")
37+
_, err := versions.CheckTableColumn(txn, accountId, catalog.MO_CATALOG, catalog.MO_PITR, "pitr_status")
3838
if err != nil {
3939
return false, err
4040
}
41-
return colInfo.IsExits, nil
41+
return true, nil
4242
},
4343
}
4444

@@ -48,11 +48,11 @@ var upg_mo_pitr_add_status_changed_time = versions.UpgradeEntry{
4848
UpgType: versions.ADD_COLUMN,
4949
UpgSql: "alter table mo_catalog.mo_pitr add column pitr_status_changed_time TIMESTAMP DEFAULT UTC_TIMESTAMP after pitr_status",
5050
CheckFunc: func(txn executor.TxnExecutor, accountId uint32) (bool, error) {
51-
colInfo, err := versions.CheckTableColumn(txn, accountId, catalog.MO_CATALOG, catalog.MO_PITR, "pitr_status_changed_time")
51+
_, err := versions.CheckTableColumn(txn, accountId, catalog.MO_CATALOG, catalog.MO_PITR, "pitr_status_changed_time")
5252
if err != nil {
5353
return false, err
5454
}
55-
return colInfo.IsExits, nil
55+
return true, nil
5656
},
5757
}
5858

pkg/bootstrap/versions/v2_0_3/upgrade_test.go renamed to pkg/bootstrap/versions/v2_0_3/upgarde_test.go

-52
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@ package v2_0_3
1616

1717
import (
1818
"context"
19-
"strings"
2019
"testing"
2120

2221
"github.com/golang/mock/gomock"
2322
"github.com/stretchr/testify/assert"
2423

2524
"github.com/matrixorigin/matrixone/pkg/bootstrap/versions"
2625
"github.com/matrixorigin/matrixone/pkg/common/moerr"
27-
"github.com/matrixorigin/matrixone/pkg/common/mpool"
2826
"github.com/matrixorigin/matrixone/pkg/common/runtime"
29-
"github.com/matrixorigin/matrixone/pkg/container/types"
3027
mock_frontend "github.com/matrixorigin/matrixone/pkg/frontend/test"
3128
"github.com/matrixorigin/matrixone/pkg/pb/txn"
3229
"github.com/matrixorigin/matrixone/pkg/util/executor"
@@ -149,52 +146,3 @@ func Test_HandleTenantUpgrade2(t *testing.T) {
149146
)
150147
assert.Nil(t, err)
151148
}
152-
153-
func Test_UpgEntry(t *testing.T) {
154-
checkSql := `att_comment AS COLUMN_COMMENT FROM mo_catalog.mo_columns`
155-
156-
sid := ""
157-
// test upg_mo_user_add_password_last_changed
158-
runtime.RunTest(
159-
sid,
160-
func(rt runtime.Runtime) {
161-
txnOperator := mock_frontend.NewMockTxnOperator(gomock.NewController(t))
162-
txnOperator.EXPECT().TxnOptions().Return(txn.TxnOptions{CN: sid}).AnyTimes()
163-
executor := executor.NewMemTxnExecutor(func(sql string) (executor.Result, error) {
164-
if strings.Contains(strings.ToLower(sql), strings.ToLower(checkSql)) {
165-
typs := []types.Type{
166-
types.New(types.T_varchar, 64, 0), // DATA_TYPE
167-
types.New(types.T_varchar, 64, 0), // IS_NULLABLE
168-
types.New(types.T_int64, 0, 0), // CHARACTER_MAXIMUM_LENGTH
169-
types.New(types.T_int64, 0, 0), // NUMERIC_PRECISION
170-
types.New(types.T_int64, 0, 0), // NUMERIC_SCALE
171-
types.New(types.T_int64, 0, 0), // NUMERIC_SCALE
172-
types.New(types.T_int32, 0, 0), // ORDINAL_POSITION
173-
types.New(types.T_varchar, 1024, 0), // COLUMN_DEFAULT
174-
types.New(types.T_varchar, 1024, 0), // EXTRA
175-
types.New(types.T_varchar, 1024, 0), // COLUMN_COMMENT
176-
}
177-
178-
memRes := executor.NewMemResult(
179-
typs,
180-
mpool.MustNewZero())
181-
memRes.NewBatch()
182-
executor.AppendStringRows(memRes, 0, []string{"DATA_TYPE_str"})
183-
executor.AppendStringRows(memRes, 1, []string{"YES"}) // or "NO"
184-
executor.AppendFixedRows(memRes, 2, []int64{0})
185-
executor.AppendFixedRows(memRes, 3, []int64{0})
186-
executor.AppendFixedRows(memRes, 4, []int64{0})
187-
executor.AppendFixedRows(memRes, 5, []int64{0})
188-
executor.AppendFixedRows(memRes, 6, []int32{0})
189-
executor.AppendStringRows(memRes, 7, []string{"COLUMN_DEFAULT"})
190-
executor.AppendStringRows(memRes, 8, []string{"EXTRA"}) // '' or 'auto_increment'
191-
executor.AppendStringRows(memRes, 9, []string{"COLUMN_COMMENT"})
192-
return memRes.GetResult(), nil
193-
}
194-
return executor.Result{}, nil
195-
}, txnOperator)
196-
upg_mo_pitr_add_status.Upgrade(executor, uint32(0))
197-
upg_mo_pitr_add_status_changed_time.Upgrade(executor, uint32(0))
198-
},
199-
)
200-
}

pkg/catalog/types.go

-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ const (
157157
MO_PITR_ACCOUNT_ID = "account_id"
158158
MO_PITR_DB_NAME = "database_name"
159159
MO_PITR_TABLE_NAME = "table_name"
160-
MO_PITR_STATUS = "pitr_status"
161-
MO_PITR_CHANGED_TIME = "pitr_status_changed_time"
162160

163161
MO_RETENTION = "mo_retention"
164162

pkg/frontend/authenticate.go

+6-7
Original file line numberDiff line numberDiff line change
@@ -3941,12 +3941,6 @@ func doDropAccount(ctx context.Context, ses *Session, da *dropAccount) (err erro
39413941
return rtnErr
39423942
}
39433943
}
3944-
3945-
// update pitr
3946-
rtnErr = updatePitrObjectId(ctx, bh, da.Name, uint64(accountId))
3947-
if rtnErr != nil {
3948-
return rtnErr
3949-
}
39503944
return rtnErr
39513945
}
39523946

@@ -5561,7 +5555,7 @@ func determinePrivilegeSetOfStatement(stmt tree.Statement) *privilege {
55615555
*tree.ShowTableValues, *tree.ShowNodeList, *tree.ShowRolesStmt,
55625556
*tree.ShowLocks, *tree.ShowFunctionOrProcedureStatus, *tree.ShowPublications, *tree.ShowSubscriptions,
55635557
*tree.ShowBackendServers, *tree.ShowStages, *tree.ShowConnectors, *tree.DropConnector,
5564-
*tree.PauseDaemonTask, *tree.CancelDaemonTask, *tree.ResumeDaemonTask, *tree.ShowRecoveryWindow:
5558+
*tree.PauseDaemonTask, *tree.CancelDaemonTask, *tree.ResumeDaemonTask:
55655559
objType = objectTypeNone
55665560
kind = privilegeKindNone
55675561
canExecInRestricted = true
@@ -7510,6 +7504,11 @@ func InitGeneralTenant(ctx context.Context, ses *Session, ca *createAccount) (er
75107504
return rtnErr
75117505
}
75127506

7507+
rtnErr = updatePitrObjectId(ctx, bh, newTenant.GetTenant(), uint64(newTenant.GetTenantID()))
7508+
if rtnErr != nil {
7509+
return rtnErr
7510+
}
7511+
75137512
return rtnErr
75147513
}
75157514

pkg/frontend/mysql_cmd_executor.go

-9
Original file line numberDiff line numberDiff line change
@@ -1554,15 +1554,6 @@ func handleShowAccounts(ses FeSession, execCtx *ExecCtx, sa *tree.ShowAccounts)
15541554
return err
15551555
}
15561556

1557-
// handleShowRecoveryWindow lists the info of recovery window
1558-
func handleShowRecoveryWindow(ses FeSession, execCtx *ExecCtx, srw *tree.ShowRecoveryWindow) error {
1559-
err := doShowRecoveryWindow(execCtx.reqCtx, ses.(*Session), srw)
1560-
if err != nil {
1561-
return err
1562-
}
1563-
return err
1564-
}
1565-
15661557
// handleShowCollation lists the info of collation
15671558
func handleShowCollation(ses FeSession, execCtx *ExecCtx, sc *tree.ShowCollation) error {
15681559
err := doShowCollation(ses.(*Session), execCtx, execCtx.proc, sc)

pkg/frontend/pitr.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ var (
7373
getPubInfoWithPitrFormat = `select pub_name, database_name, database_id, table_list, account_list, created_time, update_time, owner, creator, comment from mo_catalog.mo_pubs {MO_TS = %d} where account_id = %d and database_name = '%s';`
7474

7575
// update mo_pitr object id
76-
updateMoPitrAccountObjectIdFmt = `update mo_catalog.mo_pitr set pitr_status = 0, pitr_status_changed_time = default where account_name = '%s' and pitr_status = 1 and obj_id = %d;`
76+
updateMoPitrAccountObjectIdFmt = `update mo_catalog.mo_pitr set obj_id = %d, modified_time = '%s' where account_name = '%s';`
7777
)
7878

7979
type pitrRecord struct {
@@ -156,8 +156,8 @@ func getPubInfoWithPitr(ts int64, accountId uint32, dbName string) string {
156156
return fmt.Sprintf(getPubInfoWithPitrFormat, ts, accountId, dbName)
157157
}
158158

159-
func getSqlForUpdateMoPitrAccountObjectId(accountName string, objId uint64) string {
160-
return fmt.Sprintf(updateMoPitrAccountObjectIdFmt, accountName, objId)
159+
func getSqlForUpdateMoPitrAccountObjectId(accountName string, objId uint64, modifiedTime string) string {
160+
return fmt.Sprintf(updateMoPitrAccountObjectIdFmt, objId, modifiedTime, accountName)
161161
}
162162

163163
func checkPitrDup(ctx context.Context, bh BackgroundExec, createAccount string, createAccountId uint64, stmt *tree.CreatePitr) (bool, error) {
@@ -198,14 +198,14 @@ func getSqlForCheckPitrDup(createAccount string, createAccountId uint64, stmt *t
198198
return getSqlForCheckDupPitrFormat(createAccountId, math.MaxUint64)
199199
case tree.PITRLEVELACCOUNT:
200200
if len(stmt.AccountName) > 0 {
201-
return fmt.Sprintf(sql, createAccountId) + fmt.Sprintf(" and account_name = '%s' and level = 'account' and pitr_status = 1;", stmt.AccountName)
201+
return fmt.Sprintf(sql, createAccountId) + fmt.Sprintf(" and account_name = '%s' and level = 'account';", stmt.AccountName)
202202
} else {
203-
return fmt.Sprintf(sql, createAccountId) + fmt.Sprintf(" and account_name = '%s' and level = 'account' and pitr_status = 1;", createAccount)
203+
return fmt.Sprintf(sql, createAccountId) + fmt.Sprintf(" and account_name = '%s' and level = 'account';", createAccount)
204204
}
205205
case tree.PITRLEVELDATABASE:
206-
return fmt.Sprintf(sql, createAccountId) + fmt.Sprintf(" and database_name = '%s' and level = 'database' and pitr_status = 1;", stmt.DatabaseName)
206+
return fmt.Sprintf(sql, createAccountId) + fmt.Sprintf(" and database_name = '%s' and level = 'database';", stmt.DatabaseName)
207207
case tree.PITRLEVELTABLE:
208-
return fmt.Sprintf(sql, createAccountId) + fmt.Sprintf(" and database_name = '%s' and table_name = '%s' and level = 'table' and pitr_status = 1;", stmt.DatabaseName, stmt.TableName)
208+
return fmt.Sprintf(sql, createAccountId) + fmt.Sprintf(" and database_name = '%s' and table_name = '%s' and level = 'table';", stmt.DatabaseName, stmt.TableName)
209209
}
210210
return sql
211211
}
@@ -2371,7 +2371,7 @@ func updatePitrObjectId(ctx context.Context,
23712371
sql := getSqlForUpdateMoPitrAccountObjectId(
23722372
accountName,
23732373
objId,
2374-
)
2374+
types.CurrentTimestamp().String2(time.UTC, 0))
23752375
err = bh.Exec(ctx, sql)
23762376
if err != nil {
23772377
return

pkg/frontend/pitr_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -1302,15 +1302,15 @@ func TestGetSqlForCheckPitrDup(t *testing.T) {
13021302
stmt: &tree.CreatePitr{
13031303
Level: tree.PITRLEVELACCOUNT,
13041304
},
1305-
expected: "select pitr_id from mo_catalog.mo_pitr where create_account = 0 and account_name = 'sys' and level = 'account' and pitr_status = 1;",
1305+
expected: "select pitr_id from mo_catalog.mo_pitr where create_account = 0 and account_name = 'sys' and level = 'account';",
13061306
},
13071307
{
13081308
createAccount: "testAccount",
13091309
createAccountId: 1,
13101310
stmt: &tree.CreatePitr{
13111311
Level: tree.PITRLEVELACCOUNT,
13121312
},
1313-
expected: "select pitr_id from mo_catalog.mo_pitr where create_account = 1 and account_name = 'testAccount' and level = 'account' and pitr_status = 1;",
1313+
expected: "select pitr_id from mo_catalog.mo_pitr where create_account = 1 and account_name = 'testAccount' and level = 'account';",
13141314
},
13151315
{
13161316
createAccount: "sys",
@@ -1319,7 +1319,7 @@ func TestGetSqlForCheckPitrDup(t *testing.T) {
13191319
Level: tree.PITRLEVELACCOUNT,
13201320
AccountName: "testAccountName",
13211321
},
1322-
expected: "select pitr_id from mo_catalog.mo_pitr where create_account = 0 and account_name = 'testAccountName' and level = 'account' and pitr_status = 1;",
1322+
expected: "select pitr_id from mo_catalog.mo_pitr where create_account = 0 and account_name = 'testAccountName' and level = 'account';",
13231323
},
13241324
{
13251325
createAccount: "sys",
@@ -1328,7 +1328,7 @@ func TestGetSqlForCheckPitrDup(t *testing.T) {
13281328
Level: tree.PITRLEVELDATABASE,
13291329
DatabaseName: "testDb",
13301330
},
1331-
expected: "select pitr_id from mo_catalog.mo_pitr where create_account = 0 and database_name = 'testDb' and level = 'database' and pitr_status = 1;",
1331+
expected: "select pitr_id from mo_catalog.mo_pitr where create_account = 0 and database_name = 'testDb' and level = 'database';",
13321332
},
13331333
{
13341334
createAccount: "testAccount",
@@ -1337,7 +1337,7 @@ func TestGetSqlForCheckPitrDup(t *testing.T) {
13371337
Level: tree.PITRLEVELDATABASE,
13381338
DatabaseName: "testDb",
13391339
},
1340-
expected: "select pitr_id from mo_catalog.mo_pitr where create_account = 1 and database_name = 'testDb' and level = 'database' and pitr_status = 1;",
1340+
expected: "select pitr_id from mo_catalog.mo_pitr where create_account = 1 and database_name = 'testDb' and level = 'database';",
13411341
},
13421342
{
13431343
createAccount: "sys",
@@ -1347,7 +1347,7 @@ func TestGetSqlForCheckPitrDup(t *testing.T) {
13471347
DatabaseName: "testDb",
13481348
TableName: "testTable",
13491349
},
1350-
expected: "select pitr_id from mo_catalog.mo_pitr where create_account = 0 and database_name = 'testDb' and table_name = 'testTable' and level = 'table' and pitr_status = 1;",
1350+
expected: "select pitr_id from mo_catalog.mo_pitr where create_account = 0 and database_name = 'testDb' and table_name = 'testTable' and level = 'table';",
13511351
},
13521352
{
13531353
createAccount: "testAccount",
@@ -1357,7 +1357,7 @@ func TestGetSqlForCheckPitrDup(t *testing.T) {
13571357
DatabaseName: "testDb",
13581358
TableName: "testTable",
13591359
},
1360-
expected: "select pitr_id from mo_catalog.mo_pitr where create_account = 1 and database_name = 'testDb' and table_name = 'testTable' and level = 'table' and pitr_status = 1;",
1360+
expected: "select pitr_id from mo_catalog.mo_pitr where create_account = 1 and database_name = 'testDb' and table_name = 'testTable' and level = 'table';",
13611361
},
13621362
}
13631363

@@ -2541,7 +2541,7 @@ func Test_doCreatePitr(t *testing.T) {
25412541
mrs := newMrsForPitrRecord([][]interface{}{})
25422542
bh.sql2result[sql] = mrs
25432543

2544-
sql = fmt.Sprintf("select pitr_id from mo_catalog.mo_pitr where create_account = %d", sysAccountID) + fmt.Sprintf(" and account_name = '%s' and level = 'account' and pitr_status = 1;", sysAccountName)
2544+
sql = fmt.Sprintf("select pitr_id from mo_catalog.mo_pitr where create_account = %d", sysAccountID) + fmt.Sprintf(" and account_name = '%s' and level = 'account';", sysAccountName)
25452545
mrs = newMrsForPitrRecord([][]interface{}{})
25462546
bh.sql2result[sql] = mrs
25472547

pkg/frontend/predefined.go

-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ var (
151151
obj_id bigint unsigned,
152152
pitr_length tinyint unsigned,
153153
pitr_unit varchar(10),
154-
pitr_status tinyint unsigned default 1 comment '1: active, 0: inactive',
155-
pitr_status_changed_time timestamp default UTC_TIMESTAMP,
156154
primary key(pitr_name, create_account)
157155
)`, catalog.MO_CATALOG, catalog.MO_PITR)
158156

pkg/frontend/query_result.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ func simpleAstMarshal(stmt tree.Statement) ([]byte, error) {
423423
*tree.ShowTableNumber, *tree.ShowColumnNumber,
424424
*tree.ShowTableValues, *tree.ShowNodeList,
425425
*tree.ShowLocks, *tree.ShowFunctionOrProcedureStatus, *tree.ShowConnectors,
426-
*tree.ShowLogserviceReplicas, *tree.ShowLogserviceStores, *tree.ShowLogserviceSettings, *tree.ShowRecoveryWindow:
426+
*tree.ShowLogserviceReplicas, *tree.ShowLogserviceStores, *tree.ShowLogserviceSettings:
427427
s.Typ = int(astShowNone)
428428
case *tree.ExplainFor, *tree.ExplainAnalyze, *tree.ExplainStmt:
429429
s.Typ = int(astExplain)

pkg/frontend/self_handle.go

-6
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,6 @@ func execInFrontend(ses *Session, execCtx *ExecCtx) (stats statistic.StatsArray,
456456
if err != nil {
457457
return
458458
}
459-
case *tree.ShowRecoveryWindow:
460-
ses.EnterFPrint(FPShowRecoveryWindow)
461-
defer ses.ExitFPrint(FPShowRecoveryWindow)
462-
if err = handleShowRecoveryWindow(ses, execCtx, st); err != nil {
463-
return
464-
}
465459
case *tree.SetConnectionID:
466460
ses.EnterFPrint(FPSetConnectionID)
467461
defer ses.ExitFPrint(FPSetConnectionID)

0 commit comments

Comments
 (0)