This repository has been archived by the owner on Oct 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't delete response collectors in a transaction (#203)
## 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.
- Loading branch information
1 parent
b0c26fe
commit 04fbea5
Showing
7 changed files
with
83 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.6.1 | ||
2.6.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2021 Vaticle | ||
* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
const { TypeDB, SessionType, TransactionType, TypeDBOptions } = require("../../dist"); | ||
const TYPEDB = "typedb"; | ||
|
||
async function run() { | ||
const client = TypeDB.coreClient(); | ||
let session, tx; | ||
try { | ||
const typedb = (await client.databases.all()).find(x => x.name === TYPEDB); | ||
if (typedb) await typedb.delete(); | ||
await client.databases.create(TYPEDB); | ||
|
||
session = await client.session(TYPEDB, SessionType.SCHEMA); | ||
tx = await session.transaction(TransactionType.WRITE); | ||
|
||
for (let i = 0; i < 51; i++) { | ||
await tx.query.define(`define person sub entity, owns name${i}; name${i} sub attribute, value string;`); | ||
} | ||
await tx.commit(); | ||
await session.close(); | ||
|
||
const txOptions = TypeDBOptions.core({ prefetch: true, prefetchSize: 50 }); | ||
for (let i = 0; i < 50; i++) { | ||
session = await client.session(TYPEDB, SessionType.DATA); | ||
tx = await session.transaction(TransactionType.READ, txOptions); | ||
const personType = (await tx.concepts.getEntityType("person")).asRemote(tx); | ||
await personType.getOwns(false).collect(); | ||
await tx.query.match("match $x sub thing; limit 1;").first(); | ||
} | ||
console.log("SUCCESS - completed 50 test runs"); | ||
} catch (err) { | ||
console.error(`ERROR: ${err.stack || err}`); | ||
process.exit(1); | ||
} finally { | ||
await client.close(); | ||
} | ||
} | ||
|
||
run(); |