Add two failing test cases, fix one. #38
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The test suite
examples/errors/Exceptions
contains two different kinds of exceptions:fail
(orerror
) but can still be serialized (failEvent
,errorEvent
)stateError
).This pull request introduced two further classes of errors, and fixes one of them:
stateNestedError1
). This is the class of error which this pull request does not fix (see below).stateNestedError2
with anerror
value as argument).For the latter error,
scheduleLocalUpdate
callspushEntry
on the encoding of the transaction to write the transaction to the log, but this encoding happens lazily. This means that the exception will happen in the file writer thread spawned byopenFileLog
; in particular, it will happen infileWriter
on the call towriteToDisk
, which means the subsequent call tosequence_ action
never happens. This means that the call toputMVar
inscheduleLocalUpdate
never happens and hence the call totakeMVar
inupdate
will be forever blocked.We can fix this by reenabling the call to
evaluate
that was commented out inscheduleLocalUpdate
, which is what this pull request does. This will ensure that the exception happen in this thread, and the problem is avoided.The third problem mentioned above (exemplified by test
stateNestedError1
), however, is trickier to avoid. In this case any update will go through fine, but we will have a similar problem when we try to write a checkpoint (createLocalCheckpoint
as well ascreateCheckpointAndClose
). In this case, the state contains a nested error, so when the file writer thread attempts to write out the entire state as part of theCheckpoint
it will again throw an exception, and again theputMVar
never happens. A similar fix to the one forscheduleLocalUpdate
would be possible, of course, simply by calling evaluate on the encoded state. However, unlike individual transactions, insisting that the full bytestring for the entire database state is loaded into memory before it is written to disk might be a bad idea.Instead, it is probably necessary to adapt
fileWriter
to catch exceptions. This probably means it needs to get two lists of actions to execute: one on successful writing, one for exception cases. However, this is a bigger change so I didn't want to make it without discussion. (Once such a change is made, the call toevaluate
inscheduleLocalUpdate
will be obsolete).(As an aside, the call to
pushEntry
inscheduleLocalColdUpdate
may be suspect, too.)