Insert events into MSSQL in deterministic order #20
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.
I believe this closes #19
The change is based on a simple idea:
SELECT
queries do not have any guarantees of ordering unless you specify anORDER BY
. When any insert is being made, it is being done from adbo.NewStreamEvents
Table Value type parameter. This data is in an order, but that doesn't mean that it will be read in that order, which means it will not be inserted in that order. By simply specifying theORDER BY StreamVersion;
we can ensure that inserts will be in the order we expected.I have added the test provided in #19, and was able to have it fail fairly consistently without the
ORDER BY
clauses. I have run the tests a dozen times since adding theORDER BY
clause and have not seen a failure.Note this did NOT fix the other two failing tests.