Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't delete response collectors in a transaction #369

Merged
merged 3 commits into from
Jan 27, 2022

Conversation

alexjpwalker
Copy link
Member

What is the goal of this PR?

We no longer delete response collectors in a transaction after receiving a response to a "single" request, or receiving a "DONE" message in a stream. This fixes a possible error when loading 50+ answers in one query and then performing a second query.

What are the changes implemented in this PR?

See typedb/typedb-driver-python#250, which this PR is a copy of.

@@ -47,7 +47,7 @@ private ErrorMessage(String codePrefix, int codeNumber, String messagePrefix, St
public static final Client MISSING_RESPONSE =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -518,6 +521,23 @@ public void testSimpleExplanation() {
}, READ, TypeDBOptions.core().infer(true).explain(true));
}

@Test
public void testStreaming() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With these options (the default in TypeDB at time of writing), the server may respond with: 50 answers -> CONTINUE -> 1 answer [compensating for latency] -> DONE. The client will respond to CONTINUE with STREAM to keep iterating, and the server responds to STREAM with a 2nd DONE message.

This is expected and should be handled correctly (ie: ignored) by the client.

@@ -60,7 +60,6 @@ private boolean fetchAndCheck() {
case STREAM_RES_PART:
switch (resPart.getStreamResPart().getState()) {
case DONE:
stream.iteratorDone(requestID);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need the bidirectional stream in this class at all?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm!!

@alexjpwalker alexjpwalker merged commit 7216628 into typedb:master Jan 27, 2022
@alexjpwalker alexjpwalker deleted the collector-fix branch January 27, 2022 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants