diff --git a/lib/execution/executors/executor_test/btree_index_executor_test.go b/lib/execution/executors/executor_test/btree_index_executor_test.go index 4c4521c4..68a29b73 100644 --- a/lib/execution/executors/executor_test/btree_index_executor_test.go +++ b/lib/execution/executors/executor_test/btree_index_executor_test.go @@ -140,6 +140,7 @@ func testBTreeParallelTxnStrideRoot[T int32 | float32 | string](t *testing.T, ke //InnerTestParallelTxnsQueryingIndexUsedColumns[T](t, keyType, 800, 3000, 17, 0, bpoolSize, index_constants.INDEX_KIND_BTREE, SERIAL_EXEC, 1) InnerTestParallelTxnsQueryingIndexUsedColumns[T](t, keyType, 800, 30000, 17, 0, bpoolSize, index_constants.INDEX_KIND_BTREE, PARALLEL_EXEC, 20) + //InnerTestParallelTxnsQueryingIndexUsedColumns[T](t, keyType, 800, 30000, 17, 0, bpoolSize, index_constants.INDEX_KIND_BTREE, SERIAL_EXEC, 1) default: panic("not implemented!") } diff --git a/lib/execution/executors/executor_test/skiplist_index_executor_test.go b/lib/execution/executors/executor_test/skiplist_index_executor_test.go index 18a1ce1c..e7cf2e87 100644 --- a/lib/execution/executors/executor_test/skiplist_index_executor_test.go +++ b/lib/execution/executors/executor_test/skiplist_index_executor_test.go @@ -1071,7 +1071,7 @@ func InnerTestParallelTxnsQueryingIndexUsedColumns[T int32 | float32 | string](t return } common.ShPrintf(common.DEBUGGING, "Select(success) op start.\n") - //diffToMakeNoExist := int32(10) + diffToMakeNoExist := int32(10) rangeSelectRetry: var rangeStartKey = samehada_util.ChoiceKeyFromMap(insVals) var rangeEndKey = samehada_util.ChoiceKeyFromMap(insVals) @@ -1079,10 +1079,8 @@ func InnerTestParallelTxnsQueryingIndexUsedColumns[T int32 | float32 | string](t goto rangeSelectRetry } insValsMutex.RUnlock() - //// get 0-8 value - //tmpRand := rand.Intn(9) - // get 0-3 value - tmpRand := rand.Intn(4) + // get 0-8 value + tmpRand := rand.Intn(9) var rangeScanPlan plans.Plan switch tmpRand { case 0: // start only @@ -1093,22 +1091,22 @@ func InnerTestParallelTxnsQueryingIndexUsedColumns[T int32 | float32 | string](t rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &rangeStartKey, &rangeEndKey, indexKind) case 3: // not specified both rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, nil, nil, indexKind) - //case 4: // start only (not exisiting val) - // tmpStartKey := samehada_util.StrideAdd(rangeStartKey, diffToMakeNoExist).(T) - // rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &tmpStartKey, nil, indexKind) - //case 5: // end only (not existing val) - // tmpEndKey := samehada_util.StrideAdd(rangeEndKey, diffToMakeNoExist).(T) - // rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, nil, &tmpEndKey, indexKind) - //case 6: // start and end (start val is not existing one) - // tmpStartKey := samehada_util.StrideAdd(rangeStartKey, diffToMakeNoExist).(T) - // rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &tmpStartKey, &rangeEndKey, indexKind) - //case 7: // start and end (start val is not existing one) - // tmpEndKey := samehada_util.StrideAdd(rangeEndKey, diffToMakeNoExist).(T) - // rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &rangeStartKey, &tmpEndKey, indexKind) - //case 8: // start and end (end val is not existing one) - // tmpStartKey := samehada_util.StrideAdd(rangeStartKey, diffToMakeNoExist).(T) - // tmpEndKey := samehada_util.StrideAdd(rangeEndKey, diffToMakeNoExist).(T) - // rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &tmpStartKey, &tmpEndKey, indexKind) + case 4: // start only (not exisiting val) + tmpStartKey := samehada_util.StrideAdd(rangeStartKey, diffToMakeNoExist).(T) + rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &tmpStartKey, nil, indexKind) + case 5: // end only (not existing val) + tmpEndKey := samehada_util.StrideAdd(rangeEndKey, diffToMakeNoExist).(T) + rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, nil, &tmpEndKey, indexKind) + case 6: // start and end (start val is not existing one) + tmpStartKey := samehada_util.StrideAdd(rangeStartKey, diffToMakeNoExist).(T) + rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &tmpStartKey, &rangeEndKey, indexKind) + case 7: // start and end (start val is not existing one) + tmpEndKey := samehada_util.StrideAdd(rangeEndKey, diffToMakeNoExist).(T) + rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &rangeStartKey, &tmpEndKey, indexKind) + case 8: // start and end (end val is not existing one) + tmpStartKey := samehada_util.StrideAdd(rangeStartKey, diffToMakeNoExist).(T) + tmpEndKey := samehada_util.StrideAdd(rangeEndKey, diffToMakeNoExist).(T) + rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &tmpStartKey, &tmpEndKey, indexKind) } txn_ := txnMgr.Begin(nil) diff --git a/lib/storage/index/btree_index.go b/lib/storage/index/btree_index.go index 3603746a..ec41f7b9 100644 --- a/lib/storage/index/btree_index.go +++ b/lib/storage/index/btree_index.go @@ -100,8 +100,13 @@ func (btidx *BTreeIndex) insertEntryInner(key *tuple.Tuple, rid page.RID, txn in convedKeyVal := samehada_util.EncodeValueAndRIDToDicOrderComparableVarchar(&orgKeyVal, &rid) if isNoLock == false { - btidx.rwMtx.RLock() - defer btidx.rwMtx.RUnlock() + if orgKeyVal.ValueType() == types.Varchar { + btidx.rwMtx.Lock() + defer btidx.rwMtx.Unlock() + } else { + btidx.rwMtx.RLock() + defer btidx.rwMtx.RUnlock() + } } ridBytes := samehada_util.PackRIDto8bytes(&rid) @@ -124,8 +129,13 @@ func (btidx *BTreeIndex) deleteEntryInner(key *tuple.Tuple, rid page.RID, txn in convedKeyVal := samehada_util.EncodeValueAndRIDToDicOrderComparableVarchar(&orgKeyVal, &rid) if isNoLock == false { - btidx.rwMtx.RLock() - defer btidx.rwMtx.RUnlock() + if orgKeyVal.ValueType() == types.Varchar { + btidx.rwMtx.Lock() + defer btidx.rwMtx.Unlock() + } else { + btidx.rwMtx.RLock() + defer btidx.rwMtx.RUnlock() + } } btidx.container.DeleteKey(convedKeyVal.SerializeOnlyVal(), 0) }