Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
dc0c52d
fix
zhangxu19830126 Jul 24, 2025
89795e9
fix
zhangxu19830126 Jul 24, 2025
898cf76
Merge branch 'main' of https://github.com/matrixorigin/matrixone into…
zhangxu19830126 Jul 27, 2025
2c53e7d
fix
zhangxu19830126 Jul 27, 2025
1bdc2a3
fix
zhangxu19830126 Jul 27, 2025
d71fed0
fix
zhangxu19830126 Jul 27, 2025
0d508c6
fix
zhangxu19830126 Jul 27, 2025
03c498e
Merge branch 'main' of https://github.com/matrixorigin/matrixone into…
zhangxu19830126 Jul 29, 2025
96e1e51
Merge branch 'main' of https://github.com/matrixorigin/matrixone into…
zhangxu19830126 Aug 8, 2025
e9114ba
fix
zhangxu19830126 Aug 12, 2025
548d829
Merge remote-tracking branch 'upstream/main' into reopen_partition_bvt
zhangxu19830126 Aug 12, 2025
8d03e61
fix
zhangxu19830126 Aug 12, 2025
1938605
remove escape singleQuoteString
iamlinjunhong Aug 12, 2025
cab3c43
Merge pull request #42 from iamlinjunhong/r_p_b
zhangxu19830126 Aug 12, 2025
5c2bc81
fix
zhangxu19830126 Aug 18, 2025
9fe316f
Merge remote-tracking branch 'upstream/main' into reopen_partition_bvt
zhangxu19830126 Aug 18, 2025
9800956
fix
zhangxu19830126 Aug 18, 2025
e576931
fix
zhangxu19830126 Aug 18, 2025
a6e22e1
fix
zhangxu19830126 Aug 18, 2025
8d6b53f
fix
zhangxu19830126 Aug 19, 2025
c37e3d8
fix
zhangxu19830126 Aug 19, 2025
185b042
add func of hash partition
iamlinjunhong Aug 19, 2025
c816986
Merge pull request #43 from iamlinjunhong/f1-p
zhangxu19830126 Aug 19, 2025
02a72ec
Merge branch 'reopen_partition_bvt' of https://github.com/zhangxu1983…
zhangxu19830126 Aug 19, 2025
f168ab2
fix
zhangxu19830126 Aug 19, 2025
6dc599f
fix
zhangxu19830126 Aug 20, 2025
5f6d092
fix
zhangxu19830126 Aug 20, 2025
d6cfa93
clone partition table
gouhongshen Aug 21, 2025
14c5bf9
clone code
gouhongshen Aug 21, 2025
d443590
Merge pull request #44 from gouhongshen/clone_partition_table
zhangxu19830126 Aug 21, 2025
030f49f
fix
zhangxu19830126 Aug 22, 2025
18fc716
fix
zhangxu19830126 Aug 23, 2025
e3b9627
fix
zhangxu19830126 Aug 25, 2025
39d12f0
fix
zhangxu19830126 Aug 25, 2025
023809b
fix
zhangxu19830126 Aug 25, 2025
da7960a
fix
zhangxu19830126 Aug 25, 2025
243f6bf
fix
zhangxu19830126 Aug 26, 2025
0bd3f1a
Merge branch 'main' into reopen_partition_bvt
mergify[bot] Aug 26, 2025
2c6a929
fix ut
zhangxu19830126 Aug 26, 2025
890222a
Merge branch 'reopen_partition_bvt' of https://github.com/zhangxu1983…
zhangxu19830126 Aug 26, 2025
48df1e7
Merge remote-tracking branch 'upstream/main' into reopen_partition_bvt
zhangxu19830126 Aug 26, 2025
20cdb84
fix
zhangxu19830126 Aug 27, 2025
572aa2b
Merge remote-tracking branch 'upstream/main' into reopen_partition_bvt
zhangxu19830126 Aug 27, 2025
dda7fab
fix
zhangxu19830126 Aug 27, 2025
7ccf6b5
fix
zhangxu19830126 Aug 28, 2025
b70ab22
Merge remote-tracking branch 'upstream/main' into reopen_partition_bvt
zhangxu19830126 Aug 28, 2025
e65a0a6
fix
zhangxu19830126 Aug 29, 2025
98ae5b1
information_schema.partition and range maxvalue
iamlinjunhong Aug 27, 2025
d9c1eb6
Merge pull request #45 from iamlinjunhong/m1-rpb
zhangxu19830126 Sep 1, 2025
91c392a
fix
zhangxu19830126 Sep 2, 2025
9f533b1
fix
zhangxu19830126 Sep 2, 2025
4693990
fix
zhangxu19830126 Sep 2, 2025
462847f
fix
zhangxu19830126 Sep 2, 2025
34cfec4
fix
zhangxu19830126 Sep 4, 2025
424eb5f
fix
zhangxu19830126 Sep 4, 2025
3058b75
fix
zhangxu19830126 Sep 4, 2025
c2edf5d
fix
zhangxu19830126 Sep 4, 2025
320c5d7
fix
zhangxu19830126 Sep 5, 2025
47bafe2
fix
zhangxu19830126 Sep 5, 2025
a949bba
fix
zhangxu19830126 Sep 5, 2025
6cfdbf1
fix
zhangxu19830126 Sep 5, 2025
ae88df9
fix upgrade
zhangxu19830126 Sep 5, 2025
b5d19e5
Merge remote-tracking branch 'upstream/main' into reopen_partition_bvt
zhangxu19830126 Sep 6, 2025
9b91cd3
fix
zhangxu19830126 Sep 6, 2025
6a217c8
fix
zhangxu19830126 Sep 6, 2025
a3f054e
fix
zhangxu19830126 Sep 8, 2025
dfbebfd
fix
zhangxu19830126 Sep 8, 2025
b33ea5d
fix
zhangxu19830126 Sep 9, 2025
ff3a27f
fix
zhangxu19830126 Sep 9, 2025
c64d783
fix
zhangxu19830126 Sep 9, 2025
6d7b39b
fix
zhangxu19830126 Sep 9, 2025
9052318
fix
zhangxu19830126 Sep 9, 2025
711c569
fix
zhangxu19830126 Sep 9, 2025
d0d437d
fix
zhangxu19830126 Sep 9, 2025
756a0f6
fix
zhangxu19830126 Sep 9, 2025
284aa08
fix
zhangxu19830126 Sep 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion etc/launch-dynamic-with-proxy/launch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cn-template = "./etc/launch-dynamic-with-proxy/cn.toml.base"
# how many cn service can be launched
service-count = 2
# how many cpu can used pr cn instance
cpu-count = 2
cpu-count = 8

[dynamic.chaos]
enable = false
Expand Down
3 changes: 3 additions & 0 deletions pkg/bootstrap/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/matrixorigin/matrixone/pkg/container/vector"
"github.com/matrixorigin/matrixone/pkg/frontend"
"github.com/matrixorigin/matrixone/pkg/logutil"
"github.com/matrixorigin/matrixone/pkg/partitionservice"
"github.com/matrixorigin/matrixone/pkg/pb/timestamp"
"github.com/matrixorigin/matrixone/pkg/predefine"
"github.com/matrixorigin/matrixone/pkg/shardservice"
Expand Down Expand Up @@ -102,6 +103,8 @@ func init() {
initSQLs = append(initSQLs, trace.InitSQLs...)

initSQLs = append(initSQLs, shardservice.InitSQLs...)

initSQLs = append(initSQLs, partitionservice.InitSQLs...)
}

type service struct {
Expand Down
2 changes: 2 additions & 0 deletions pkg/bootstrap/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/matrixorigin/matrixone/pkg/bootstrap/versions/v2_1_0"
"github.com/matrixorigin/matrixone/pkg/bootstrap/versions/v2_2_0"
"github.com/matrixorigin/matrixone/pkg/bootstrap/versions/v3_0_0"
"github.com/matrixorigin/matrixone/pkg/bootstrap/versions/v4_0_0"
)

// initUpgrade all versions need create a upgrade handle in pkg/bootstrap/versions
Expand All @@ -45,6 +46,7 @@ func (s *service) initUpgrade() {
s.handles = append(s.handles, v2_1_0.Handler)
s.handles = append(s.handles, v2_2_0.Handler)
s.handles = append(s.handles, v3_0_0.Handler)
s.handles = append(s.handles, v4_0_0.Handler)
}

func (s *service) getFinalVersionHandle() VersionHandle {
Expand Down
21 changes: 21 additions & 0 deletions pkg/bootstrap/versions/v4_0_0/cluster_upgrade_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2025 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 v4_0_0

import (
"github.com/matrixorigin/matrixone/pkg/bootstrap/versions"
)

var clusterUpgEntries = []versions.UpgradeEntry{}
24 changes: 24 additions & 0 deletions pkg/bootstrap/versions/v4_0_0/log.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2025 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 v4_0_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()
}
49 changes: 49 additions & 0 deletions pkg/bootstrap/versions/v4_0_0/tenant_upgrade_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright 2025 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 v4_0_0

import (
"github.com/matrixorigin/matrixone/pkg/bootstrap/versions"
"github.com/matrixorigin/matrixone/pkg/catalog"
"github.com/matrixorigin/matrixone/pkg/partitionservice"
"github.com/matrixorigin/matrixone/pkg/util/executor"
)

var tenantUpgEntries = []versions.UpgradeEntry{
enablePartitionMetadata,
enablePartitionTables,
}

var enablePartitionMetadata = versions.UpgradeEntry{
Schema: catalog.MO_CATALOG,
TableName: catalog.MOPartitionMetadata,
UpgType: versions.CREATE_NEW_TABLE,
UpgSql: partitionservice.PartitionTableMetadataSQL,
CheckFunc: func(txn executor.TxnExecutor, accountId uint32) (bool, error) {
exist, err := versions.CheckTableDefinition(txn, accountId, catalog.MO_CATALOG, partitionservice.PartitionTableMetadataSQL)
return exist, err
},
}

var enablePartitionTables = versions.UpgradeEntry{
Schema: catalog.MO_CATALOG,
TableName: catalog.MOPartitionTables,
UpgType: versions.CREATE_NEW_TABLE,
UpgSql: partitionservice.PartitionTablesSQL,
CheckFunc: func(txn executor.TxnExecutor, accountId uint32) (bool, error) {
exist, err := versions.CheckTableDefinition(txn, accountId, catalog.MO_CATALOG, partitionservice.PartitionTablesSQL)
return exist, err
},
}
126 changes: 126 additions & 0 deletions pkg/bootstrap/versions/v4_0_0/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
// Copyright 2025 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 v4_0_0

import (
"context"
"time"

"github.com/matrixorigin/matrixone/pkg/logutil"

"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"
"go.uber.org/zap"
)

var (
Handler = &versionHandle{
metadata: versions.Version{
Version: "4.0.0",
MinUpgradeVersion: "3.0.0",
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 {

var (
err error
goon bool
logger func(msg string, fields ...zap.Field)
)

for _, upgEntry := range tenantUpgEntries {
goon = false
logger = logutil.Error

start := time.Now()
err = upgEntry.Upgrade(txn, uint32(tenantID))

duration := time.Since(start)

if err == nil {
logger = logutil.Info
goon = true
}

logger("tenant upgrade",
zap.String("cn", txn.Txn().TxnOptions().CN),
zap.String("entry", upgEntry.String()),
zap.Int32("tenantId", tenantID),
zap.String("version", v.metadata.Version),
zap.Duration("duration", duration),
zap.Error(err),
)

if goon {
continue
}
return err
}

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)
}
84 changes: 84 additions & 0 deletions pkg/bootstrap/versions/v4_0_0/upgrade_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright 2025 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 v4_0_0

import (
"context"
"testing"

"github.com/golang/mock/gomock"
"github.com/matrixorigin/matrixone/pkg/bootstrap/versions"
"github.com/matrixorigin/matrixone/pkg/common/moerr"
"github.com/matrixorigin/matrixone/pkg/common/runtime"
mock_frontend "github.com/matrixorigin/matrixone/pkg/frontend/test"
"github.com/matrixorigin/matrixone/pkg/pb/txn"
"github.com/matrixorigin/matrixone/pkg/util/executor"
"github.com/stretchr/testify/assert"
)

func Test_Upgrade(t *testing.T) {
sid := ""
runtime.RunTest(
sid,
func(rt runtime.Runtime) {
txnOperator := mock_frontend.NewMockTxnOperator(gomock.NewController(t))
txnOperator.EXPECT().TxnOptions().Return(txn.TxnOptions{CN: sid}).AnyTimes()

executor := executor.NewMemTxnExecutor(func(sql string) (executor.Result, error) {
return executor.Result{}, nil
}, txnOperator)

metadata := Handler.Metadata()
t.Logf("version metadata:%v", metadata)

if err := Handler.Prepare(context.Background(), executor, true); err != nil {
t.Errorf("Prepare() error = %v", err)
}

if err := Handler.HandleCreateFrameworkDeps(executor); err == nil {
t.Errorf("HandleCreateFrameworkDeps() should report err")
}

if err := Handler.HandleClusterUpgrade(context.Background(), executor); err != nil {
t.Errorf("HandleClusterUpgrade() error = %v", err)
}

if err := Handler.HandleTenantUpgrade(context.Background(), 0, executor); err != nil {
t.Errorf("HandleTenantUpgrade() error = %v", err)
}
},
)
}

func Test_versionHandle_HandleClusterUpgrade(t *testing.T) {
clusterUpgEntries = []versions.UpgradeEntry{}

v := &versionHandle{
metadata: versions.Version{
Version: "v4.0.0",
},
}
sid := ""
txnOperator := mock_frontend.NewMockTxnOperator(gomock.NewController(t))
txnOperator.EXPECT().TxnOptions().Return(txn.TxnOptions{CN: sid}).AnyTimes()
executor2 := executor.NewMemTxnExecutor(func(sql string) (executor.Result, error) {
return executor.Result{}, moerr.NewInvalidInputNoCtx("return error")
}, txnOperator)

err := v.HandleClusterUpgrade(context.Background(),
executor2,
)
assert.Nil(t, err)
}
1 change: 1 addition & 0 deletions pkg/common/reuse/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func init() {
switch strings.ToLower(enable) {
case "true":
enableChecker.Store(true)
enableVerbose.Store(true)
}
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/defines/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ type TenantIDKey struct{}
type UserIDKey struct{}
type RoleIDKey struct{}
type NodeIDKey struct{}
type InternalExecutorKey struct{}

func IsInternalExecutor(ctx context.Context) bool {
if v := ctx.Value(InternalExecutorKey{}); v != nil {
return v.(bool)
}
return false
}

func GetAccountId(ctx context.Context) (uint32, error) {
if v := ctx.Value(TenantIDKey{}); v != nil {
Expand Down
Loading
Loading