Skip to content

Commit 68f38e1

Browse files
authored
Revert "Revert "Revert "Cloud Spanner DML & PartitionedDML support (#3703)" (#3741)" (#3755)" (#3761)
This reverts commit 65ca2f3.
1 parent f741fc0 commit 68f38e1

File tree

10 files changed

+64
-552
lines changed

10 files changed

+64
-552
lines changed

google-cloud-clients/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseClient.java

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public interface DatabaseClient {
135135
ReadOnlyTransaction singleUseReadOnlyTransaction();
136136

137137
/**
138-
* Returns a read-only transaction context in which a single read or query can be performed at
138+
  * Returns a read-only transaction context in which a single read or query can be performed at the
139139
* given timestamp bound. This method differs from {@link #singleUse(TimestampBound)} in that the
140140
* read timestamp used may be inspected after the read has returned data or finished successfully.
141141
*
@@ -269,51 +269,4 @@ public interface DatabaseClient {
269269
*
270270
*/
271271
TransactionManager transactionManager();
272-
273-
/**
274-
* Returns the lower bound of rows modified by this DML statement.
275-
*
276-
* <p>The method will block until the update is complete. Running a DML statement with this method
277-
* does not offer exactly once semantics, and therfore the DML statement should be idempotent. The
278-
* DML statement must be fully-partitionable. Specifically, the statement must be expressible as
279-
* the union of many statements which each access only a single row of the table. This is a
280-
* Partitioned DML transaction in which a single Partitioned DML statement is executed.
281-
* Partitioned DML partitions the key space and runs the DML statement over each partition in
282-
* parallel using separate, internal transactions that commit independently. Partitioned DML
283-
* transactions do not need to be committed.
284-
*
285-
* <p>Partitioned DML updates are used to execute a single DML statement with a different
286-
* execution strategy that provides different, and often better, scalability properties for large,
287-
* table-wide operations than DML in a {@link #readWriteTransaction()} transaction. Smaller scoped
288-
* statements, such as an OLTP workload, should prefer using {@link
289-
* TransactionContext#executeUpdate(Statement)} with {@link #readWriteTransaction()}.
290-
*
291-
* <ul>
292-
* That said, Partitioned DML is not a drop-in replacement for standard DML used in {@link
293-
* #readWriteTransaction()}.
294-
* <li>The DML statement must be fully-partitionable. Specifically, the statement must be
295-
* expressible as the union of many statements which each access only a single row of the
296-
* table.
297-
* <li>The statement is not applied atomically to all rows of the table. Rather, the statement
298-
* is applied atomically to partitions of the table, in independent internal transactions.
299-
* Secondary index rows are updated atomically with the base table rows.
300-
* <li>Partitioned DML does not guarantee exactly-once execution semantics against a partition.
301-
* The statement will be applied at least once to each partition. It is strongly recommended
302-
* that the DML statement should be idempotent to avoid unexpected results. For instance, it
303-
* is potentially dangerous to run a statement such as `UPDATE table SET column = column +
304-
* 1` as it could be run multiple times against some rows.
305-
* <li>The partitions are committed automatically - there is no support for Commit or Rollback.
306-
* If the call returns an error, or if the client issuing the DML statement dies, it is
307-
* possible that some rows had the statement executed on them successfully. It is also
308-
* possible that statement was never executed against other rows.
309-
* <li>If any error is encountered during the execution of the partitioned DML operation (for
310-
* instance, a UNIQUE INDEX violation, division by zero, or a value that cannot be stored
311-
* due to schema constraints), then the operation is stopped at that point and an error is
312-
* returned. It is possible that at this point, some partitions have been committed (or even
313-
* committed multiple times), and other partitions have not been run at all.
314-
*
315-
* <p>Given the above, Partitioned DML is good fit for large, database-wide, operations that are
316-
* idempotent, such as deleting old rows from a very large table.
317-
*/
318-
long executePartitionedUpdate(Statement stmt);
319272
}

google-cloud-clients/google-cloud-spanner/src/main/java/com/google/cloud/spanner/DatabaseClientImpl.java

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@
2828
class DatabaseClientImpl implements DatabaseClient {
2929
private static final String READ_WRITE_TRANSACTION = "CloudSpanner.ReadWriteTransaction";
3030
private static final String READ_ONLY_TRANSACTION = "CloudSpanner.ReadOnlyTransaction";
31-
private static final String PARTITION_DML_TRANSACTION = "CloudSpanner.PartitionDMLTransaction";
3231
private static final Tracer tracer = Tracing.getTracer();
3332

3433
static {
35-
TraceUtil.exportSpans(READ_WRITE_TRANSACTION, READ_ONLY_TRANSACTION, PARTITION_DML_TRANSACTION);
34+
TraceUtil.exportSpans(READ_WRITE_TRANSACTION, READ_ONLY_TRANSACTION);
3635
}
3736

3837
private final SessionPool pool;
@@ -156,17 +155,6 @@ public TransactionManager transactionManager() {
156155
}
157156
}
158157

159-
@Override
160-
public long executePartitionedUpdate(Statement stmt) {
161-
Span span = tracer.spanBuilder(PARTITION_DML_TRANSACTION).startSpan();
162-
try (Scope s = tracer.withSpan(span)) {
163-
return pool.getReadWriteSession().executePartitionedUpdate(stmt);
164-
} catch (RuntimeException e) {
165-
TraceUtil.endSpanWithFailure(span, e);
166-
throw e;
167-
}
168-
}
169-
170158
ListenableFuture<Void> closeAsync() {
171159
return pool.closeAsync();
172160
}

google-cloud-clients/google-cloud-spanner/src/main/java/com/google/cloud/spanner/ResultSet.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package com.google.cloud.spanner;
1818

1919
import com.google.spanner.v1.ResultSetStats;
20-
import javax.annotation.Nullable;
2120

2221
/**
2322
* Provides access to the data returned by a Cloud Spanner read or query. {@code ResultSet} allows a
@@ -60,17 +59,13 @@ public interface ResultSet extends AutoCloseable, StructReader {
6059
@Override
6160
void close();
6261

63-
6462
/**
6563
* Returns the {@link ResultSetStats} for the query only if the query was executed in either the
6664
* {@code PLAN} or the {@code PROFILE} mode via the {@link ReadContext#analyzeQuery(Statement,
67-
* com.google.cloud.spanner.ReadContext.QueryAnalyzeMode)} method or for DML statements in
68-
* {@link ReadContext#executeQuery(Statement, QueryOption)}. Attempts to call this method on
69-
* a {@code ResultSet} not obtained from {@code analyzeQuery} or {@code executeQuery} will return
70-
* a {@code null} {@code ResultSetStats}. This method must be called after {@link #next()} has
71-
* returned @{code false}. Calling it before that will result in {@code null}
72-
* {@code ResultSetStats} too.
65+
* com.google.cloud.spanner.ReadContext.QueryAnalyzeMode)} method. Attempts to call this method on
66+
* a {@code ResultSet} not obtained from {@code analyzeQuery} result in an {@code
67+
* UnsupportedOperationException}. This method must be called after {@link #next()} has
68+
* returned @{code false}. Calling it before that will result in an {@code IllegalStateException}.
7369
*/
74-
@Nullable
7570
ResultSetStats getStats();
7671
}

google-cloud-clients/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -312,18 +312,6 @@ public Timestamp write(Iterable<Mutation> mutations) throws SpannerException {
312312
}
313313
}
314314

315-
@Override
316-
public long executePartitionedUpdate(Statement stmt) throws SpannerException {
317-
try {
318-
markUsed();
319-
return delegate.executePartitionedUpdate(stmt);
320-
} catch (SpannerException e) {
321-
throw lastException = e;
322-
} finally {
323-
close();
324-
}
325-
}
326-
327315
@Override
328316
public Timestamp writeAtLeastOnce(Iterable<Mutation> mutations) throws SpannerException {
329317
try {

0 commit comments

Comments
 (0)