-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mo_account add column version_offset
- Loading branch information
1 parent
4af809a
commit 24ddae8
Showing
16 changed files
with
236 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright 2024 Matrix Origin | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package v2_1_0 | ||
|
||
import ( | ||
"github.com/matrixorigin/matrixone/pkg/bootstrap/versions" | ||
"github.com/matrixorigin/matrixone/pkg/catalog" | ||
"github.com/matrixorigin/matrixone/pkg/util/executor" | ||
) | ||
|
||
var clusterUpgEntries = []versions.UpgradeEntry{ | ||
upg_mo_account_version_offset, | ||
} | ||
|
||
var upg_mo_account_version_offset = versions.UpgradeEntry{ | ||
Schema: catalog.MO_CATALOG, | ||
TableName: catalog.MOAccountTable, | ||
UpgType: versions.ADD_COLUMN, | ||
UpgSql: "alter table mo_catalog.mo_account add column version_offset int unsigned default 0 after create_version", | ||
CheckFunc: func(txn executor.TxnExecutor, accountId uint32) (bool, error) { | ||
colInfo, err := versions.CheckTableColumn(txn, accountId, catalog.MO_CATALOG, catalog.MOAccountTable, "version_offset") | ||
if err != nil { | ||
return false, err | ||
} | ||
return colInfo.IsExits, nil | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright 2024 Matrix Origin | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package v2_1_0 | ||
|
||
import ( | ||
"github.com/matrixorigin/matrixone/pkg/common/log" | ||
"github.com/matrixorigin/matrixone/pkg/common/runtime" | ||
) | ||
|
||
func getLogger(sid string) *log.MOLogger { | ||
return runtime.ServiceRuntime(sid).Logger() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2024 Matrix Origin | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package v2_1_0 | ||
|
||
import ( | ||
"github.com/matrixorigin/matrixone/pkg/bootstrap/versions" | ||
) | ||
|
||
var tenantUpgEntries = []versions.UpgradeEntry{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
// Copyright 2024 Matrix Origin | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package v2_1_0 | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"go.uber.org/zap" | ||
|
||
"github.com/matrixorigin/matrixone/pkg/bootstrap/versions" | ||
"github.com/matrixorigin/matrixone/pkg/catalog" | ||
"github.com/matrixorigin/matrixone/pkg/common/moerr" | ||
"github.com/matrixorigin/matrixone/pkg/util/executor" | ||
) | ||
|
||
var ( | ||
Handler = &versionHandle{ | ||
metadata: versions.Version{ | ||
Version: "2.1.0", | ||
MinUpgradeVersion: "2.0.2", | ||
UpgradeCluster: versions.Yes, | ||
UpgradeTenant: versions.Yes, | ||
VersionOffset: uint32(len(clusterUpgEntries) + len(tenantUpgEntries)), | ||
}, | ||
} | ||
) | ||
|
||
type versionHandle struct { | ||
metadata versions.Version | ||
} | ||
|
||
func (v *versionHandle) Metadata() versions.Version { | ||
return v.metadata | ||
} | ||
|
||
func (v *versionHandle) Prepare( | ||
ctx context.Context, | ||
txn executor.TxnExecutor, | ||
final bool) error { | ||
txn.Use(catalog.MO_CATALOG) | ||
return nil | ||
} | ||
|
||
func (v *versionHandle) HandleTenantUpgrade( | ||
ctx context.Context, | ||
tenantID int32, | ||
txn executor.TxnExecutor) error { | ||
|
||
for _, upgEntry := range tenantUpgEntries { | ||
start := time.Now() | ||
|
||
err := upgEntry.Upgrade(txn, uint32(tenantID)) | ||
if err != nil { | ||
getLogger(txn.Txn().TxnOptions().CN).Error("tenant upgrade entry execute error", zap.Error(err), zap.Int32("tenantId", tenantID), zap.String("version", v.Metadata().Version), zap.String("upgrade entry", upgEntry.String())) | ||
return err | ||
} | ||
|
||
duration := time.Since(start) | ||
getLogger(txn.Txn().TxnOptions().CN).Info("tenant upgrade entry complete", | ||
zap.String("upgrade entry", upgEntry.String()), | ||
zap.Int64("time cost(ms)", duration.Milliseconds()), | ||
zap.Int32("tenantId", tenantID), | ||
zap.String("toVersion", v.Metadata().Version)) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (v *versionHandle) HandleClusterUpgrade( | ||
ctx context.Context, | ||
txn executor.TxnExecutor) error { | ||
for _, upgEntry := range clusterUpgEntries { | ||
start := time.Now() | ||
|
||
err := upgEntry.Upgrade(txn, catalog.System_Account) | ||
if err != nil { | ||
getLogger(txn.Txn().TxnOptions().CN).Error("cluster upgrade entry execute error", zap.Error(err), zap.String("version", v.Metadata().Version), zap.String("upgrade entry", upgEntry.String())) | ||
return err | ||
} | ||
|
||
duration := time.Since(start) | ||
getLogger(txn.Txn().TxnOptions().CN).Info("cluster upgrade entry complete", | ||
zap.String("upgrade entry", upgEntry.String()), | ||
zap.Int64("time cost(ms)", duration.Milliseconds()), | ||
zap.String("toVersion", v.Metadata().Version)) | ||
} | ||
return nil | ||
} | ||
|
||
func (v *versionHandle) HandleCreateFrameworkDeps(txn executor.TxnExecutor) error { | ||
return moerr.NewInternalErrorNoCtxf("Only v1.2.0 can initialize upgrade framework, current version is:%s", Handler.metadata.Version) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.