Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
295 commits
Select commit Hold shift + click to select a range
36bc11f
bug fix view
cpegeric May 16, 2025
3d70d9a
add tests
cpegeric May 22, 2025
3d94c96
Merge branch 'main' into cdc_sqlexecutor
cpegeric May 22, 2025
3967bb6
update
cpegeric May 22, 2025
6db0cb6
add tests
cpegeric May 22, 2025
d123d51
add sync test
cpegeric May 23, 2025
35ca423
update tests
cpegeric May 23, 2025
dd2ecdb
delete all tests
cpegeric May 23, 2025
5356fd9
update tests
cpegeric May 23, 2025
69dffe1
add test
cpegeric May 23, 2025
48a3f59
add test
cpegeric May 23, 2025
4a0db76
update
cpegeric May 23, 2025
03b7f3b
remove InsertMeta
cpegeric May 23, 2025
fc450b1
start with empty
cpegeric May 23, 2025
862cd46
delete 2 files
cpegeric May 23, 2025
fd6eee9
shuffle test
cpegeric May 23, 2025
8c51bbe
update shuffle
cpegeric May 23, 2025
3e5f164
create/drop index
cpegeric May 27, 2025
2f00775
remove new cdc sql syntax
cpegeric May 27, 2025
4deaa70
Merge branch 'main' into cdc_sqlexecutor_cleanup
mergify[bot] May 27, 2025
9006006
update sca
cpegeric May 27, 2025
543ad89
Merge branch 'cdc_sqlexecutor_cleanup' of github.com:cpegeric/matrixo…
cpegeric May 27, 2025
c2a30cb
fix sca test
cpegeric May 27, 2025
04f097d
check nil vector
cpegeric May 27, 2025
d21748a
fix sca
cpegeric May 27, 2025
5747b92
bug fix
cpegeric May 27, 2025
ea5e8e6
add test
cpegeric Jun 2, 2025
390e907
clear cache after cdc sync
cpegeric Jun 2, 2025
66eef84
add bvt test
cpegeric Jun 2, 2025
eddf530
fix test
cpegeric Jun 2, 2025
3f355c7
update unittest
cpegeric Jun 2, 2025
53e2f96
bug fix check channel closed
cpegeric Jun 2, 2025
89efa85
fix sca
cpegeric Jun 2, 2025
f6609de
fix sca
cpegeric Jun 2, 2025
1575bd9
fix sca
cpegeric Jun 2, 2025
94549ac
check vector dimension when cast from string
cpegeric Jun 3, 2025
e34c04f
bypass dimension check when width is max dimension
cpegeric Jun 3, 2025
1f626f3
fix bvt
cpegeric Jun 3, 2025
22eee6b
test atomicBatch
cpegeric Jun 4, 2025
ecfeab8
check errors
cpegeric Jun 4, 2025
d9a6023
test sendX
cpegeric Jun 4, 2025
ea82266
update bvt with manual pitr and cdc task
cpegeric Jun 4, 2025
6539fff
increase sleep
cpegeric Jun 4, 2025
917356b
update
cpegeric Jun 4, 2025
397f518
add tests
cpegeric Jun 5, 2025
e74e66d
fix bvt test on multi-cn env
cpegeric Jun 5, 2025
8f5f976
add more tests
cpegeric Jun 5, 2025
598d60f
cleanup and remove stderr
cpegeric Jun 5, 2025
50be8db
update and comments
cpegeric Jun 5, 2025
b9ea603
Merge branch 'main' into cdc_sqlexecutor_cleanup
cpegeric Jun 5, 2025
9144730
debug
cpegeric Jun 6, 2025
e00b89a
fix sca
cpegeric Jun 6, 2025
fe08c31
Merge branch 'main' into cdc_sqlexecutor_cleanup
cpegeric Jun 9, 2025
6da9b68
add test
cpegeric Jun 9, 2025
b381acd
add license
cpegeric Jun 9, 2025
644fbfa
performance
cpegeric Jun 9, 2025
1f7654c
update
cpegeric Jun 9, 2025
8b6975c
update
cpegeric Jun 9, 2025
b8c3c15
fix thread safe
cpegeric Jun 10, 2025
a964de2
cleanup
cpegeric Jun 10, 2025
8b962d0
never unload when insertAll
cpegeric Jun 10, 2025
dc4cbbd
merge fix
cpegeric Jun 11, 2025
3d7be05
better message
cpegeric Jun 11, 2025
ae92606
Merge branch 'main' into cdc_sqlexecutor_cleanup
cpegeric Jun 12, 2025
652783c
fix bvt -- drop pitr
cpegeric Jun 12, 2025
c0f162b
cleanup
cpegeric Jun 12, 2025
4ce4a5d
take timing
cpegeric Jun 13, 2025
ba61a0f
support values as input
cpegeric Jun 19, 2025
67feed9
Comment on composite primary key
cpegeric Jun 19, 2025
1b8735b
comments
cpegeric Jun 19, 2025
a12d40d
add sql writer
cpegeric Jun 19, 2025
acb4387
update
cpegeric Jun 20, 2025
edc33bb
update
cpegeric Jun 20, 2025
0a1f61c
update
cpegeric Jun 20, 2025
c393b7c
update
cpegeric Jun 20, 2025
dabe24b
update
cpegeric Jun 20, 2025
56bc1df
update ivfflat
cpegeric Jun 20, 2025
5e0a2bd
update ivfflat
cpegeric Jun 20, 2025
56b6a28
update
cpegeric Jun 20, 2025
04097a4
add db
cpegeric Jun 20, 2025
9210d80
reset
cpegeric Jun 20, 2025
5aa4712
empty
cpegeric Jun 20, 2025
09de3b1
hnsw sql writer
cpegeric Jun 20, 2025
5a664e6
update hnsw
cpegeric Jun 20, 2025
77037ae
template
cpegeric Jun 20, 2025
5200881
update
cpegeric Jun 20, 2025
fa50232
add test
cpegeric Jun 20, 2025
cfe6a0b
update test
cpegeric Jun 20, 2025
0b04c8f
ivf
cpegeric Jun 20, 2025
da1d2ec
update
cpegeric Jun 20, 2025
581a07d
version
cpegeric Jun 20, 2025
09dc52d
update
cpegeric Jun 20, 2025
e04b63c
update
cpegeric Jun 20, 2025
17057d7
bug fix
cpegeric Jun 20, 2025
d437339
index sinker with IndexSqlWriter
cpegeric Jun 23, 2025
5c648f3
remove comment
cpegeric Jun 23, 2025
53b6438
rename hsnw to index
cpegeric Jun 23, 2025
8069eb0
delete if vector is nil
cpegeric Jun 23, 2025
4afbe23
rename file
cpegeric Jun 23, 2025
4772c2f
support multi-indexes
cpegeric Jun 23, 2025
12429c2
cleanup
cpegeric Jun 23, 2025
b32d846
cleanup
cpegeric Jun 23, 2025
dd93d28
use constant
cpegeric Jun 23, 2025
173589a
rename file
cpegeric Jun 23, 2025
a44aacf
todo
cpegeric Jun 23, 2025
9aa078c
bvt test
cpegeric Jun 23, 2025
01fc88d
cleanup
cpegeric Jun 23, 2025
a39fa82
cleanup
cpegeric Jun 23, 2025
613544e
sca
cpegeric Jun 23, 2025
1a38d8b
add license
cpegeric Jun 23, 2025
be20232
bug fix
cpegeric Jun 23, 2025
622a888
more comments
cpegeric Jun 23, 2025
95a9a5c
delete sql
cpegeric Jun 23, 2025
4f06629
cleanup
cpegeric Jun 23, 2025
3c34919
cleanup
cpegeric Jun 23, 2025
d60145c
bug fix delete row only have 1 column pk
cpegeric Jun 24, 2025
84d945c
bug fix pre-defined column name
cpegeric Jun 24, 2025
789fa58
hardcode composite primary key column to varbinary
cpegeric Jun 24, 2025
504b616
bug fix
cpegeric Jun 24, 2025
e97612c
disable fulltext and ivfflat
cpegeric Jun 24, 2025
3e5ead4
bug fix
cpegeric Jun 24, 2025
f64f6de
Merge branch 'cdc_sqlexecutor_cleanup' into cdc_fulltext
cpegeric Jun 24, 2025
2806c24
only enable hnsw
cpegeric Jun 24, 2025
9ba390e
add async option
cpegeric Jun 25, 2025
ef894ea
skip async with DML
cpegeric Jun 25, 2025
1de75a6
catalog.IsIndexAsync
cpegeric Jun 25, 2025
9f83f62
async
cpegeric Jun 25, 2025
4d9cca5
Merge branch 'cdc_fulltext' into cdc_sqlexecutor_cleanup
cpegeric Jun 25, 2025
4e527c4
update
cpegeric Jun 25, 2025
99ce5a6
fix sca
cpegeric Jun 25, 2025
0f89628
fix merge
cpegeric Jun 25, 2025
14b0e7f
Merge branch 'main' into cdc_fulltext
cpegeric Jun 26, 2025
5143b81
Merge branch 'main' into cdc_fulltext
cpegeric Jun 27, 2025
72231a7
add cdc util
cpegeric Jun 27, 2025
7f7e096
create/delete cdc task
cpegeric Jun 27, 2025
884102e
update
cpegeric Jun 27, 2025
82b76f8
update
cpegeric Jun 27, 2025
959b527
update
cpegeric Jun 27, 2025
662fd57
Merge branch 'cdc_fulltext' into cdc_sqlexecutor_cleanup
cpegeric Jun 27, 2025
c16cf90
truncate table
cpegeric Jun 27, 2025
b423bcc
truncate table
cpegeric Jun 27, 2025
20fb6e5
update
cpegeric Jun 27, 2025
5caab53
cleanup
cpegeric Jun 27, 2025
43e9116
update
cpegeric Jun 27, 2025
a4a753d
update
cpegeric Jun 27, 2025
42a9adc
hnsw disable alter reindex
cpegeric Jun 27, 2025
2ed6051
alter reindex
cpegeric Jun 27, 2025
164693e
sca
cpegeric Jun 27, 2025
7757192
bug fix
cpegeric Jun 27, 2025
38775df
bug fix
cpegeric Jun 27, 2025
852b8c2
update
cpegeric Jun 30, 2025
d7241ae
use pitr_name
cpegeric Jun 30, 2025
b6639d2
add check pitr before create
cpegeric Jun 30, 2025
49a4cef
update
cpegeric Jun 30, 2025
f09eb13
update
cpegeric Jun 30, 2025
22e91b3
update
cpegeric Jun 30, 2025
04393a1
consumer
cpegeric Jun 30, 2025
3400935
license
cpegeric Jun 30, 2025
11c74ff
update
cpegeric Jun 30, 2025
7d106fb
update
cpegeric Jun 30, 2025
d4e19e6
use transaction from DataRetriever
cpegeric Jul 1, 2025
1704875
update watermark
cpegeric Jul 1, 2025
4c4c3a8
update
cpegeric Jul 1, 2025
7b02d81
update
cpegeric Jul 1, 2025
16600d3
statement option
cpegeric Jul 1, 2025
ab06863
statement option
cpegeric Jul 1, 2025
e83058f
snapshot
cpegeric Jul 1, 2025
952b57a
run
cpegeric Jul 1, 2025
06af88a
update
cpegeric Jul 1, 2025
c72197d
move to idxcdc
cpegeric Jul 1, 2025
1d2b203
update
cpegeric Jul 1, 2025
ffa5da7
update
cpegeric Jul 1, 2025
fc4b7d2
update idxcdc
cpegeric Jul 1, 2025
3b0ca17
update
cpegeric Jul 1, 2025
fab81f1
tail use insert, snapshot use upsert
cpegeric Jul 1, 2025
268ab6e
update
cpegeric Jul 1, 2025
d06cb28
update
cpegeric Jul 1, 2025
76b2c62
mock retriever
cpegeric Jul 1, 2025
98439c8
flush at the end
cpegeric Jul 1, 2025
e0aca74
update test
cpegeric Jul 2, 2025
352655d
update
cpegeric Jul 2, 2025
2567793
add test
cpegeric Jul 2, 2025
ed0c94b
merge fix watermarkUpdater
cpegeric Jul 2, 2025
ccf384c
update
cpegeric Jul 2, 2025
9afc4df
Merge branch 'main' into cdc_fulltext
cpegeric Jul 3, 2025
0b6cfd9
add cnUUID
cpegeric Jul 3, 2025
97113c4
remove unneccessary code
cpegeric Jul 3, 2025
7259ddc
update
cpegeric Jul 3, 2025
5aa0926
api
cpegeric Jul 3, 2025
55258af
merge fix
cpegeric Jul 8, 2025
7a6ba7e
bug fix cdc
cpegeric Jul 8, 2025
a5ed284
bvt test
cpegeric Jul 8, 2025
839a494
fix drop index
cpegeric Jul 8, 2025
6ed579a
fix sca
cpegeric Jul 8, 2025
381665e
Merge branch 'main' into cdc_fulltext
cpegeric Jul 9, 2025
346f32c
Merge branch 'main' into cdc_sqlexecutor_cleanup
cpegeric Jul 9, 2025
9edbd11
bug fix thread id
cpegeric Jul 9, 2025
e744672
Merge branch 'cdc_sqlexecutor_cleanup' into cdc_fulltext
cpegeric Jul 9, 2025
f1b1962
rename idxcdc to iscp
cpegeric Jul 22, 2025
51a0044
merge fix function id
cpegeric Jul 22, 2025
44c63ff
fix sca
cpegeric Jul 22, 2025
254f20e
fix sca
cpegeric Jul 23, 2025
cef2cac
merge fix
cpegeric Aug 18, 2025
8db5fe7
merge fix
cpegeric Aug 19, 2025
cb1f323
new index consumer
cpegeric Aug 19, 2025
16c0cd3
uncomment used code
cpegeric Aug 20, 2025
3f9d25e
Merge branch 'main' into cdc_fulltext_merge
cpegeric Aug 20, 2025
718ca4b
merge fix
cpegeric Aug 22, 2025
6e02233
update
cpegeric Aug 22, 2025
19a52a3
rename
cpegeric Aug 22, 2025
5819c2d
update async bvt
cpegeric Aug 22, 2025
f1ee83b
add index consumer
cpegeric Aug 22, 2025
9eb0c4e
remove unused files
cpegeric Aug 22, 2025
bc3ed22
Merge branch 'main' into cdc_fulltext_merge
cpegeric Aug 26, 2025
4b2cc9c
fix account id
cpegeric Aug 26, 2025
82fbd5c
fix data retriever mock
cpegeric Aug 26, 2025
40ccd63
merge fix
cpegeric Aug 26, 2025
9efa664
fix sca
cpegeric Aug 26, 2025
2e815bb
bug fix default with sys account and change to particular id by optio…
cpegeric Aug 27, 2025
55f769d
revert
cpegeric Aug 27, 2025
640008e
system account
cpegeric Aug 27, 2025
dfa6166
fix ivf index name
cpegeric Aug 27, 2025
3fd0782
support secondary index table
cpegeric Aug 28, 2025
4c6d1fb
support secondary index table
cpegeric Aug 28, 2025
8986c1f
Revert "support secondary index table"
cpegeric Aug 28, 2025
b34aa55
fix cast null value with type
cpegeric Aug 28, 2025
266d9bd
Merge branch 'main' into cdc_fulltext_merge
cpegeric Aug 28, 2025
1c08614
Merge branch 'main' into cdc_fulltext_merge
cpegeric Aug 29, 2025
45851c7
better checking with valid cdc async index
cpegeric Aug 29, 2025
bc1218f
bug fix alter table drop index
cpegeric Aug 29, 2025
6262a1e
update
cpegeric Aug 29, 2025
5e55a2d
Merge branch 'main' into cdc_fulltext_merge
cpegeric Aug 29, 2025
7c77985
Merge branch 'main' into cdc_fulltext_merge
cpegeric Sep 2, 2025
89baab0
drop database also remove iscp jobs
cpegeric Sep 2, 2025
bb06ed8
bug fix check tableIDs is empty
cpegeric Sep 2, 2025
2bd1f1b
check data is nil
cpegeric Sep 3, 2025
3ba370c
bug fix hnsw load index not free when error
cpegeric Sep 4, 2025
da6d569
limit max 2k values per insert into to avoid slow gc and OOM
cpegeric Sep 4, 2025
f23c60c
Merge branch 'main' into cdc_fulltext_merge
cpegeric Sep 4, 2025
ed631c7
add bvt tests
cpegeric Sep 4, 2025
48acc18
fix alter table add column and fulltext
cpegeric Sep 5, 2025
1f58a3d
bug fix check dropped
cpegeric Sep 5, 2025
1121aae
merge fix
cpegeric Sep 5, 2025
d407424
Merge branch 'main' into iscp_merge
LeftHandCold Sep 8, 2025
f089a44
Merge branch 'main' into iscp_merge
cpegeric Sep 8, 2025
74aea64
Merge branch 'main' into iscp_merge
cpegeric Sep 8, 2025
6fd9eb6
update
jiangxinmeng1 Sep 12, 2025
acc2026
Merge branch 'fix_iscp_init' into iscp_merge
jiangxinmeng1 Sep 12, 2025
cc29c71
update
jiangxinmeng1 Sep 12, 2025
7cd3c79
update
jiangxinmeng1 Sep 12, 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
3 changes: 3 additions & 0 deletions pkg/bootstrap/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ func init() {
}
initSQLs = append(initSQLs, sql)

sql = predefine.GenInitISCPTaskSQL()
initSQLs = append(initSQLs, sql)

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

initSQLs = append(initSQLs, shardservice.InitSQLs...)
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
36 changes: 36 additions & 0 deletions pkg/bootstrap/versions/v4_0_0/cluster_upgreade_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// 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/predefine"
"github.com/matrixorigin/matrixone/pkg/util/executor"
)

var clusterUpgEntries = []versions.UpgradeEntry{
upg_mo_iscp_task,
}
var upg_mo_iscp_task = versions.UpgradeEntry{
Schema: catalog.MOTaskDB,
TableName: catalog.MOSysDaemonTask,
UpgType: versions.CREATE_NEW_TABLE,
UpgSql: predefine.GenInitISCPTaskSQL(),
CheckFunc: func(txn executor.TxnExecutor, accountId uint32) (bool, error) {
ok, err := versions.CheckTableDataExist(txn, accountId, predefine.GenISCPTaskCheckSQL())
return ok, err
},
}
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()
}
19 changes: 19 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,19 @@
// 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 tenantUpgEntries = []versions.UpgradeEntry{}
125 changes: 125 additions & 0 deletions pkg/bootstrap/versions/v4_0_0/upgrade.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
// 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"
"github.com/matrixorigin/matrixone/pkg/logutil"
"time"

"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)
}
85 changes: 85 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,85 @@
// 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/stretchr/testify/assert"

"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"
)

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: "v3.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)
}
Loading
Loading