Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 39 additions & 0 deletions src/Soil-Core-Tests/SoilIndexedDictionaryTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,45 @@ SoilIndexedDictionaryTest >> testRecoverAddedKeys [

]

{ #category : #'tests - concurrent' }
SoilIndexedDictionaryTest >> testRecoverAddedKeysTwoLists [
| dict2 tx tx2 blockedTx |
"We test that restore does not confuse indexes"

dict2 := (SoilIndexedDictionary newWithBackend: backend)
keySize: 10;
maxLevel: 8; "ignored for BTree"
yourself.

tx := soil newTransaction.
tx root: dict.
dict
at: #secondDict put: dict2.

dict2
at: #testkey1 put: 'one'.

dict
at: #testkey1 put: 1.

tx commit.

"we opem a blocked transaction that will be used to trigger restore"
blockedTx := soil newTransaction.

"open a second transaction, here we set the same key to the same values in both lists
this will add two entries to the transaction log with the same key->value but different oldValue"
tx2 := soil newTransaction.
(tx2 root at: #secondDict) at: #testkey1 put: 'changed'.
tx2 root
at: #testkey1 put: 'changed'.
tx2 commit.
"Now we read #testKey1 in the blockedtransaction, triggereing the restore,
if restore would not take the index id into account we would get the wrong value"
self assert: ((blockedTx root at: #secondDict) at: #testkey1) equals: 'one'.
self assert: (blockedTx root at: #testkey1) yourself equals: 1.
]

{ #category : #tests }
SoilIndexedDictionaryTest >> testRecoverMulitpleDuplicateKeys [
| tx tx2 blockedTx values tx3 |
Expand Down
3 changes: 2 additions & 1 deletion src/Soil-Core/SoilAddKeyEntry.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ SoilAddKeyEntry >> context [
]

{ #category : #testing }
SoilAddKeyEntry >> isForItem: anItem [
SoilAddKeyEntry >> isForItem: anItem index: indexId [
id = indexId ifFalse: [ ^false ].
^ key = anItem key and: [value = anItem value]
]

Expand Down
1 change: 1 addition & 0 deletions src/Soil-Core/SoilBasicBTree.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ SoilBasicBTree class >> isAbstract [
SoilBasicBTree >> asCopyOnWrite [
^ SoilCopyOnWriteBTree new
wrapped: self;
id: id;
yourself
]

Expand Down
2 changes: 2 additions & 0 deletions src/Soil-Core/SoilIndexedDictionary.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ SoilIndexedDictionary >> createIndexWith: anIndexClass [
index := anIndexClass new
initializeHeaderPage;
valueSize: 8;
id: id;
yourself
]

Expand Down Expand Up @@ -310,6 +311,7 @@ SoilIndexedDictionary >> soilMaterialized: aMaterializer [
transaction := aMaterializer transaction.
segment := aMaterializer segment.
index := (aMaterializer indexAt: id) asCopyOnWrite.
index id: id.
dirty := false
]

Expand Down
5 changes: 3 additions & 2 deletions src/Soil-Core/SoilRemoveKeyEntry.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ SoilRemoveKeyEntry >> context [
]

{ #category : #testing }
SoilRemoveKeyEntry >> isForItem: anItem [
"for multiple keys, we store the oldValue in the removedID"
SoilRemoveKeyEntry >> isForItem: anItem index: indexId [
id = indexId ifFalse: [ ^false ].

^ key = anItem key and: [
anItem value isRemoved and: [
anItem value isRestorable and: [
Expand Down
2 changes: 1 addition & 1 deletion src/Soil-Core/SoilRestoringIndexIterator.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ SoilRestoringIndexIterator >> lastJournalEntriesFor: item startingAt: anInteger
[ transactionId > readVersion ] whileTrue: [
(journal transactionJournalAt: transactionId) entries do: [ :each |
((each class == SoilAddKeyEntry) | (each class = SoilRemoveKeyEntry)) ifTrue: [
(each isForItem: item) ifTrue: [
(each isForItem: item index: index id) ifTrue: [
lastEntry := each] ] ].
transactionId := transactionId - 1.
].
Expand Down
1 change: 1 addition & 0 deletions src/Soil-Core/SoilSkipList.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ SoilSkipList >> acceptSoil: aSoilVisitor [
SoilSkipList >> asCopyOnWrite [
^ SoilCopyOnWriteSkipList new
wrapped: self;
id: id;
yourself
]

Expand Down
Loading