Skip to content

Commit 4921ecc

Browse files
committed
bugfix allowImplicit in streaming transactions
1 parent d6e7a5b commit 4921ecc

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

ChangeLog.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66

77
## [Unreleased]
88

9+
- bugfix `allowImplicit` parameter in stream transactions
10+
- added `peakMemoryUsage` to aql statistics
11+
912
## [6.6.1] - 2020-03-18
1013

1114
- GraalVM Native Image support

src/main/java/com/arangodb/model/StreamTransactionOptions.java

+7-6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class StreamTransactionOptions {
3232
private Integer lockTimeout;
3333
private Boolean waitForSync;
3434
private Long maxTransactionSize;
35+
private Boolean allowImplicit;
3536

3637
public StreamTransactionOptions() {
3738
super();
@@ -94,16 +95,16 @@ public StreamTransactionOptions exclusiveCollections(final String... exclusive)
9495
return this;
9596
}
9697

98+
public Boolean getAllowImplicit() {
99+
return allowImplicit;
100+
}
101+
97102
/**
98-
* @param allowImplicit Collections that will be written to in the transaction must be declared with the write attribute or it
99-
* will fail, whereas non-declared collections from which is solely read will be added lazily. The
100-
* optional attribute allowImplicit can be set to false to let transactions fail in case of undeclared
101-
* collections for reading. Collections for reading should be fully declared if possible, to avoid
102-
* deadlocks.
103+
* @param allowImplicit Allow reading from undeclared collections.
103104
* @return options
104105
*/
105106
public StreamTransactionOptions allowImplicit(final Boolean allowImplicit) {
106-
collections.allowImplicit(allowImplicit);
107+
this.allowImplicit = allowImplicit;
107108
return this;
108109
}
109110

src/test/java/com/arangodb/StreamTransactionTest.java

+27-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import static org.hamcrest.CoreMatchers.notNullValue;
3535
import static org.hamcrest.MatcherAssert.assertThat;
3636
import static org.hamcrest.Matchers.*;
37-
37+
import static org.junit.Assert.fail;
3838
import static org.junit.Assume.assumeTrue;
3939

4040
/**
@@ -717,4 +717,30 @@ public void getStreamTransactions() {
717717
db.abortStreamTransaction(tx2.getId());
718718
}
719719

720+
@Test
721+
public void transactionAllowImplicitFalse() {
722+
assumeTrue(isSingleServer());
723+
assumeTrue(isAtLeastVersion(3, 5));
724+
assumeTrue(isStorageEngine(ArangoDBEngine.StorageEngineName.rocksdb));
725+
726+
StreamTransactionEntity tx = db
727+
.beginStreamTransaction(new StreamTransactionOptions().allowImplicit(false));
728+
729+
// insert a document from outside the tx
730+
DocumentCreateEntity<BaseDocument> externalDoc = collection
731+
.insertDocument(new BaseDocument(), null);
732+
733+
// assert that we cannot read from collection
734+
try {
735+
collection.getDocument(externalDoc.getKey(), BaseDocument.class,
736+
new DocumentReadOptions().streamTransactionId(tx.getId()));
737+
fail();
738+
} catch (ArangoDBException e) {
739+
assertThat(e.getResponseCode(), is(400));
740+
assertThat(e.getErrorNum(), is(1652));
741+
assertThat(e.getMessage(), containsString("unregistered collection used in transaction"));
742+
}
743+
744+
db.abortStreamTransaction(tx.getId());
745+
}
720746
}

0 commit comments

Comments
 (0)