Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.Vector;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
Expand All @@ -74,6 +75,8 @@ public class ITTransactionTest {
@ClassRule public static IntegrationTestEnv env = new IntegrationTestEnv();
private static Database db;
private static DatabaseClient client;
private static Database largeMessageDb;
private static DatabaseClient largeMessageClient;

/** Sequence for assigning unique keys to test cases. */
private static int seq;
Expand All @@ -88,11 +91,31 @@ public static void setUpDatabase() {
+ " V INT64,"
+ ") PRIMARY KEY (K)");
client = env.getTestHelper().getDatabaseClient(db);

largeMessageDb =
env.getTestHelper()
.createTestDatabase(
"CREATE TABLE T ("
+ " K STRING(MAX) NOT NULL,"
+ " col0 BYTES(MAX),"
+ " col1 BYTES(MAX),"
+ " col2 BYTES(MAX),"
+ " col3 BYTES(MAX),"
+ " col4 BYTES(MAX),"
+ " col5 BYTES(MAX),"
+ " col6 BYTES(MAX),"
+ " col7 BYTES(MAX),"
+ " col8 BYTES(MAX),"
+ " col9 BYTES(MAX),"
+ ") PRIMARY KEY (K)");
largeMessageClient = env.getTestHelper().getDatabaseClient(largeMessageDb);
}

@Before
public void removeTestData() {
client.writeAtLeastOnce(Collections.singletonList(Mutation.delete("T", KeySet.all())));
largeMessageClient.writeAtLeastOnce(
Collections.singletonList(Mutation.delete("T", KeySet.all())));
}

private static String uniqueKey() {
Expand Down Expand Up @@ -561,6 +584,25 @@ public void testTxWithUncaughtError() {
}
}

@Test
public void testTxWithLargeMessageSize() {
int bytesPerColumn = 10000000; // 10MB
String key = uniqueKey();
Random random = new Random();
List<Mutation> mutations = new ArrayList();
Mutation.WriteBuilder builder = Mutation.newInsertOrUpdateBuilder("T").set("K").to(key);
for (int j = 0; j < 7; j++) {
byte[] data = new byte[bytesPerColumn];
random.nextBytes(data);
builder
.set("col" + j)
.to(com.google.cloud.spanner.Value.bytes(com.google.cloud.ByteArray.copyFrom(data)));
}
mutations.add(builder.build());
// This large message is under the 100MB limit.
largeMessageClient.write(mutations);
}

@Test
public void testTxWithUncaughtErrorAfterSuccessfulBegin() {
try {
Expand Down
Loading