Skip to content

Commit

Permalink
debugging BTree Index: SERIAL, assert comment-outed, no duplication t…
Browse files Browse the repository at this point in the history
…est -> last record count is not match and etc.
  • Loading branch information
ryogrid committed Aug 31, 2024
1 parent af7df62 commit 21fa824
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,10 @@ func InnerTestParallelTxnsQueryingIndexUsedColumns[T int32 | float32 | string](t
}
common.ShPrintf(common.DEBUGGING, "ii=%d\n", ii)

// get 0-7
opType := rand.Intn(8)
//// get 0-7
//get 0-6
//opType := rand.Intn(8)
opType := rand.Intn(7)

switch opType {
case 0: // Update two account balance (move money)
Expand Down Expand Up @@ -645,6 +647,9 @@ func InnerTestParallelTxnsQueryingIndexUsedColumns[T int32 | float32 | string](t
// goto retry
// //panic("balance check failed(1).")
//}
if results1 == nil || len(results1) != 1 {
fmt.Println("results1 is nil or len is not 1")
}
balance1 := results1[0].GetValue(tableMetadata.Schema(), 1).ToInteger()

//retry2:
Expand Down Expand Up @@ -760,15 +765,18 @@ func InnerTestParallelTxnsQueryingIndexUsedColumns[T int32 | float32 | string](t
common.ShPrintf(common.DEBUGGING, fmt.Sprintf("Insert op start. txnId:%v ii:%d jj:%d\n", txn_.GetTransactionId(), ii, jj))
insPlan := createSpecifiedValInsertPlanNode(insKeyVal, insBalanceVal, c, tableMetadata, keyType)

// insert two same record
executePlan(c, shi.GetBufferPoolManager(), txn_, insPlan)
if txn_.GetState() == access.ABORTED {
break
if jj == 22 {
fmt.Println("insKeyVal: 779212422?")
}
//// insert two same record
executePlan(c, shi.GetBufferPoolManager(), txn_, insPlan)
if txn_.GetState() == access.ABORTED {
break
}
//executePlan(c, shi.GetBufferPoolManager(), txn_, insPlan)
//if txn_.GetState() == access.ABORTED {
// break
//}
//fmt.Printf("sl.Insert at insertRandom: jj=%d, insKeyValBase=%d len(*insVals)=%d\n", jj, insKeyValBase, len(insVals))
}

Expand Down Expand Up @@ -850,14 +858,24 @@ func InnerTestParallelTxnsQueryingIndexUsedColumns[T int32 | float32 | string](t
common.ShPrintf(common.DEBUGGING, "Delete(success) op start %v.\n", delKeyVal)

delPlan := createSpecifiedValDeletePlanNode(delKeyVal, c, tableMetadata, keyType, indexKind)
if jj == 21 {
fmt.Println("delKeyVal: watch")
}
if jj == 22 {
fmt.Println("delKeyVal: 779212422")
}
results := executePlan(c, shi.GetBufferPoolManager(), txn_, delPlan)
//executePlan(c, shi.GetBufferPoolManager(), txn_, delPlan)

if txn_.GetState() == access.ABORTED {
break
}

common.SH_Assert(results != nil && len(results) == 2, "Delete(success) failed!")
if results == nil || len(results) != 1 {
fmt.Println("results is nil or len(results) != 1")
}
//common.SH_Assert(results != nil && len(results) == 2, "Delete(success) failed!")
//common.SH_Assert(results != nil && len(results) == 1, "Delete(success) failed!")
}

finalizeRandomDeleteExistingTxn(txn_, delKeyValBase)
Expand Down Expand Up @@ -918,21 +936,23 @@ func InnerTestParallelTxnsQueryingIndexUsedColumns[T int32 | float32 | string](t
break
}

//if results1 == nil || len(results1) != 2 {
// fmt.Println("results1 is nil or len(results1) != 2")
//}
common.SH_Assert(results1 != nil && len(results1) == 2, "Update failed!")
if results1 == nil || len(results1) != 2 {
fmt.Println("results1 is nil or len(results1) != 2")
}
//common.SH_Assert(results1 != nil && len(results1) == 2, "Update failed!")
//common.SH_Assert(results1 != nil && len(results1) == 1, "Update failed!")

updatePlan2 := createBalanceUpdatePlanNode(updateNewKeyVal, newBalanceVal, c, tableMetadata, keyType, indexKind)

results2 := executePlan(c, shi.GetBufferPoolManager(), txn_, updatePlan2)
//executePlan(c, shi.GetBufferPoolManager(), txn_, updatePlan2)
//results2 := executePlan(c, shi.GetBufferPoolManager(), txn_, updatePlan2)
executePlan(c, shi.GetBufferPoolManager(), txn_, updatePlan2)

if txn_.GetState() == access.ABORTED {
break
}

common.SH_Assert(results2 != nil && len(results2) == 2, "Update failed!")
//common.SH_Assert(results2 != nil && len(results2) == 2, "Update failed!")
//common.SH_Assert(results2 != nil && len(results2) == 1, "Update failed!")
}

finalizeRandomUpdateTxn(txn_, updateKeyValBase, updateNewKeyValBase)
Expand Down Expand Up @@ -1016,10 +1036,11 @@ func InnerTestParallelTxnsQueryingIndexUsedColumns[T int32 | float32 | string](t
if results == nil || len(results) != 2 {
fmt.Println("results is nil or len(results) != 2")
}
common.SH_Assert(results != nil && len(results) == 2, "Select(success) should not be fail!")
collectVal := types.NewInteger(getInt32ValCorrespondToPassVal(getKeyVal))
gotVal := results[0].GetValue(tableMetadata.Schema(), 1)
common.SH_Assert(gotVal.CompareEquals(collectVal), "value should be "+fmt.Sprintf("%d not %d", collectVal.ToInteger(), gotVal.ToInteger()))
//common.SH_Assert(results != nil && len(results) == 2, "Select(success) should not be fail!")
//common.SH_Assert(results != nil && len(results) == 1, "Select(success) should not be fail!")
//collectVal := types.NewInteger(getInt32ValCorrespondToPassVal(getKeyVal))
//gotVal := results[0].GetValue(tableMetadata.Schema(), 1)
//common.SH_Assert(gotVal.CompareEquals(collectVal), "value should be "+fmt.Sprintf("%d not %d", collectVal.ToInteger(), gotVal.ToInteger()))
}

finalizeSelectExistingTxn(txn_, getKeyValBase)
Expand Down Expand Up @@ -1138,7 +1159,8 @@ func InnerTestParallelTxnsQueryingIndexUsedColumns[T int32 | float32 | string](t
txn_.MakeNotAbortable()

// check record num (index of col1 is used)
collectNum := stride*(int32(len(insVals)*2)+initialEntryNum) + ACCOUNT_NUM
//collectNum := stride*(int32(len(insVals)*2)+initialEntryNum) + ACCOUNT_NUM
collectNum := stride*int32(len(insVals)) + initialEntryNum + ACCOUNT_NUM

rangeScanPlan1 := createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, nil, nil, indexKind)
results1 := executePlan(c, shi.GetBufferPoolManager(), txn_, rangeScanPlan1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1303,6 +1303,12 @@ func testParallelTxnsQueryingUniqSkipListIndexUsedColumns[T int32 | float32 | st
common.ShPrintf(common.DEBUGGING, "Delete(success) op start %v.\n", delKeyVal)

delPlan := createSpecifiedValDeletePlanNode(delKeyVal, c, tableMetadata, keyType, indexKind)
if jj == 21 {
fmt.Println("watch")
}
if jj == 22 {
fmt.Println("delete 779212422")
}
results := executePlan(c, shi.GetBufferPoolManager(), txn_, delPlan)

if txn_.GetState() == access.ABORTED {
Expand Down
4 changes: 3 additions & 1 deletion lib/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ go 1.21

toolchain go1.21.2

replace github.com/ryogrid/bltree-go-for-embedding => ../../bltree-go-for-embedding

require (
github.com/deckarep/golang-set/v2 v2.3.0
github.com/devlights/gomy v0.4.0
Expand All @@ -12,7 +14,7 @@ require (
github.com/notEpsilon/go-pair v0.0.0-20221220200415-e91ef28c6c0b
github.com/pingcap/parser v0.0.0-20200623164729-3a18f1e5dceb
github.com/pingcap/tidb v1.1.0-beta.0.20200630082100-328b6d0a955c
github.com/ryogrid/bltree-go-for-embedding v1.0.4
github.com/ryogrid/bltree-go-for-embedding v0.0.0-00010101000000-000000000000
github.com/spaolacci/murmur3 v1.1.0
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
)
Expand Down
2 changes: 0 additions & 2 deletions lib/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,6 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryogrid/bltree-go-for-embedding v1.0.4 h1:LAvotdhSovWV3T2m8X9LtcKt7E+NrndEcLgUCunHwLg=
github.com/ryogrid/bltree-go-for-embedding v1.0.4/go.mod h1:IjwQznZH7W6JZiFGk4vwDbNgLbgPODUzjlRgKQgCIFE=
github.com/sasha-s/go-deadlock v0.2.0/go.mod h1:StQn567HiB1fF2yJ44N9au7wOhrPS3iZqiDbRupzT10=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sergi/go-diff v1.0.1-0.20180205163309-da645544ed44/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
Expand Down

0 comments on commit 21fa824

Please sign in to comment.