Skip to content

Commit 54bc2a9

Browse files
authored
feat(spanner): rollback CommitStats prior to Feb release (#5787)
This reverts #5745.
1 parent d126f50 commit 54bc2a9

14 files changed

+22
-241
lines changed
-2.31 KB
Binary file not shown.

google/cloud/spanner/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ add_library(
4444
client.cc
4545
client.h
4646
client_options.h
47-
commit_options.h
4847
commit_result.h
4948
connection.h
5049
connection_options.cc
@@ -251,7 +250,6 @@ function (spanner_client_define_tests)
251250
bytes_test.cc
252251
client_options_test.cc
253252
client_test.cc
254-
commit_options_test.cc
255253
connection_options_test.cc
256254
create_instance_request_builder_test.cc
257255
database_admin_client_test.cc

google/cloud/spanner/client.cc

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ StatusOr<BatchDmlResult> Client::ExecuteBatchDml(
188188
StatusOr<CommitResult> Client::Commit(
189189
std::function<StatusOr<Mutations>(Transaction)> const& mutator,
190190
std::unique_ptr<TransactionRerunPolicy> rerun_policy,
191-
std::unique_ptr<BackoffPolicy> backoff_policy,
192-
CommitOptions const& options) {
191+
std::unique_ptr<BackoffPolicy> backoff_policy) {
193192
// The status-code discriminator of TransactionRerunPolicy.
194193
using RerunnablePolicy = spanner_internal::SafeTransactionRerun;
195194

@@ -219,7 +218,7 @@ StatusOr<CommitResult> Client::Commit(
219218
#endif
220219
auto status = mutations.status();
221220
if (RerunnablePolicy::IsOk(status)) {
222-
auto result = Commit(txn, *mutations, options);
221+
auto result = Commit(txn, *mutations);
223222
status = result.status();
224223
if (!RerunnablePolicy::IsTransientFailure(status)) {
225224
return result;
@@ -258,8 +257,7 @@ StatusOr<CommitResult> Client::Commit(
258257
}
259258

260259
StatusOr<CommitResult> Client::Commit(
261-
std::function<StatusOr<Mutations>(Transaction)> const& mutator,
262-
CommitOptions const& options) {
260+
std::function<StatusOr<Mutations>(Transaction)> const& mutator) {
263261
auto const rerun_maximum_duration = std::chrono::minutes(10);
264262
auto default_commit_rerun_policy =
265263
LimitedTimeTransactionRerunPolicy(rerun_maximum_duration).clone();
@@ -273,19 +271,16 @@ StatusOr<CommitResult> Client::Commit(
273271
.clone();
274272

275273
return Commit(mutator, std::move(default_commit_rerun_policy),
276-
std::move(default_commit_backoff_policy), options);
274+
std::move(default_commit_backoff_policy));
277275
}
278276

279-
StatusOr<CommitResult> Client::Commit(Mutations mutations,
280-
CommitOptions const& options) {
281-
return Commit([&mutations](Transaction const&) { return mutations; },
282-
options);
277+
StatusOr<CommitResult> Client::Commit(Mutations mutations) {
278+
return Commit([&mutations](Transaction const&) { return mutations; });
283279
}
284280

285281
StatusOr<CommitResult> Client::Commit(Transaction transaction,
286-
Mutations mutations,
287-
CommitOptions const& options) {
288-
return conn_->Commit({std::move(transaction), std::move(mutations), options});
282+
Mutations mutations) {
283+
return conn_->Commit({std::move(transaction), std::move(mutations)});
289284
}
290285

291286
Status Client::Rollback(Transaction transaction) {

google/cloud/spanner/client.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "google/cloud/spanner/batch_dml_result.h"
1919
#include "google/cloud/spanner/client_options.h"
20-
#include "google/cloud/spanner/commit_options.h"
2120
#include "google/cloud/spanner/commit_result.h"
2221
#include "google/cloud/spanner/connection.h"
2322
#include "google/cloud/spanner/connection_options.h"
@@ -523,7 +522,6 @@ class Client {
523522
* @param rerun_policy controls for how long (or how many times) the mutator
524523
* will be rerun after the transaction aborts.
525524
* @param backoff_policy controls how long `Commit` waits between reruns.
526-
* @param options to apply to the commit.
527525
*
528526
* @throw Rethrows any exception thrown by @p `mutator` (after rolling back
529527
* the transaction). However, a `RuntimeStatusError` exception is
@@ -536,35 +534,31 @@ class Client {
536534
StatusOr<CommitResult> Commit(
537535
std::function<StatusOr<Mutations>(Transaction)> const& mutator,
538536
std::unique_ptr<TransactionRerunPolicy> rerun_policy,
539-
std::unique_ptr<BackoffPolicy> backoff_policy,
540-
CommitOptions const& options = {});
537+
std::unique_ptr<BackoffPolicy> backoff_policy);
541538

542539
/**
543540
* Commits a read-write transaction.
544541
*
545542
* Same as above, but uses the default rerun and backoff policies.
546543
*
547544
* @param mutator the function called to create mutations
548-
* @param options to apply to the commit.
549545
*
550546
* @par Example
551547
* @snippet samples.cc commit-with-mutator
552548
*/
553549
StatusOr<CommitResult> Commit(
554-
std::function<StatusOr<Mutations>(Transaction)> const& mutator,
555-
CommitOptions const& options = {});
550+
std::function<StatusOr<Mutations>(Transaction)> const& mutator);
556551

557552
/**
558-
* Commits the @p mutations, using the @p options, atomically in order.
553+
* Commits the given @p mutations atomically in order.
559554
*
560555
* This function uses the re-run loop described above with the default
561556
* policies.
562557
*
563558
* @par Example
564559
* @snippet samples.cc commit-with-mutations
565560
*/
566-
StatusOr<CommitResult> Commit(Mutations mutations,
567-
CommitOptions const& options = {});
561+
StatusOr<CommitResult> Commit(Mutations mutations);
568562

569563
/**
570564
* Commits a read-write transaction.
@@ -586,13 +580,11 @@ class Client {
586580
* @param mutations The mutations to be executed when this transaction
587581
* commits. All mutations are applied atomically, in the order they appear
588582
* in this list.
589-
* @param options to apply to the commit.
590583
*
591584
* @return A `StatusOr` containing the result of the commit or error status
592585
* on failure.
593586
*/
594-
StatusOr<CommitResult> Commit(Transaction transaction, Mutations mutations,
595-
CommitOptions const& options = {});
587+
StatusOr<CommitResult> Commit(Transaction transaction, Mutations mutations);
596588

597589
/**
598590
* Rolls back a read-write transaction, releasing any locks it holds.

google/cloud/spanner/client_test.cc

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ TEST(ClientTest, CommitMutatorSuccess) {
401401
auto conn = std::make_shared<MockConnection>();
402402
Transaction txn = MakeReadWriteTransaction(); // dummy
403403
Connection::ReadParams actual_read_params{txn, {}, {}, {}, {}, {}};
404-
Connection::CommitParams actual_commit_params{txn, {}, {}};
404+
Connection::CommitParams actual_commit_params{txn, {}};
405405

406406
auto source = absl::make_unique<MockResultSetSource>();
407407
auto constexpr kText = R"pb(
@@ -424,7 +424,7 @@ TEST(ClientTest, CommitMutatorSuccess) {
424424
Return(ByMove(RowStream(std::move(source))))));
425425
EXPECT_CALL(*conn, Commit(_))
426426
.WillOnce(DoAll(SaveArg<0>(&actual_commit_params),
427-
Return(CommitResult{*timestamp, absl::nullopt})));
427+
Return(CommitResult{*timestamp})));
428428

429429
Client client(conn);
430430
auto mutation = MakeDeleteMutation("table", KeySet::All());
@@ -609,7 +609,7 @@ TEST(ClientTest, CommitMutatorRerunTransientFailures) {
609609
return Status(StatusCode::kAborted, "Aborted transaction");
610610
})
611611
.WillOnce([&timestamp](Connection::CommitParams const&) {
612-
return CommitResult{*timestamp, absl::nullopt};
612+
return CommitResult{*timestamp};
613613
});
614614

615615
auto mutator = [](Transaction const&) -> StatusOr<Mutations> {
@@ -681,7 +681,7 @@ TEST(ClientTest, CommitMutations) {
681681
EXPECT_CALL(*conn, Commit(_))
682682
.WillOnce([&mutation, &timestamp](Connection::CommitParams const& cp) {
683683
EXPECT_EQ(cp.mutations, Mutations{mutation});
684-
return CommitResult{*timestamp, absl::nullopt};
684+
return CommitResult{*timestamp};
685685
});
686686

687687
Client client(conn);
@@ -782,7 +782,7 @@ TEST(ClientTest, CommitMutatorSessionAffinity) {
782782
EXPECT_THAT(cp.transaction, HasSession(session_name));
783783
EXPECT_THAT(cp.transaction, HasBegin());
784784
SetTransactionId(cp.transaction, "last-transaction-id");
785-
return CommitResult{*timestamp, absl::nullopt};
785+
return CommitResult{*timestamp};
786786
});
787787
// But only after some aborts, the first of which sets the session.
788788
EXPECT_CALL(*conn, Commit(_))
@@ -821,7 +821,7 @@ TEST(ClientTest, CommitMutatorSessionNotFound) {
821821
EXPECT_CALL(*conn, Commit(_))
822822
.WillOnce([&timestamp](Connection::CommitParams const& cp) {
823823
EXPECT_THAT(cp.transaction, HasSession("session-3"));
824-
return CommitResult{*timestamp, absl::nullopt};
824+
return CommitResult{*timestamp};
825825
});
826826

827827
int n = 0;
@@ -851,7 +851,7 @@ TEST(ClientTest, CommitSessionNotFound) {
851851
})
852852
.WillOnce([&timestamp](Connection::CommitParams const& cp) {
853853
EXPECT_THAT(cp.transaction, HasSession("session-2"));
854-
return CommitResult{*timestamp, absl::nullopt};
854+
return CommitResult{*timestamp};
855855
});
856856

857857
int n = 0;
@@ -867,28 +867,6 @@ TEST(ClientTest, CommitSessionNotFound) {
867867
EXPECT_EQ(*timestamp, result->commit_timestamp);
868868
}
869869

870-
TEST(ClientTest, CommitStats) {
871-
auto timestamp =
872-
spanner_internal::TimestampFromRFC3339("2020-10-20T02:20:09.123Z");
873-
ASSERT_STATUS_OK(timestamp);
874-
CommitStats stats{42};
875-
876-
auto conn = std::make_shared<MockConnection>();
877-
EXPECT_CALL(*conn, Commit(_))
878-
.WillOnce([&timestamp, &stats](Connection::CommitParams const& cp) {
879-
EXPECT_TRUE(cp.options.return_stats());
880-
return CommitResult{*timestamp, stats};
881-
});
882-
883-
Client client(conn);
884-
auto result =
885-
client.Commit(Mutations{}, CommitOptions{}.set_return_stats(true));
886-
ASSERT_STATUS_OK(result);
887-
EXPECT_EQ(*timestamp, result->commit_timestamp);
888-
ASSERT_TRUE(result->commit_stats.has_value());
889-
EXPECT_EQ(42, result->commit_stats->mutation_count);
890-
}
891-
892870
TEST(ClientTest, ProfileQuerySuccess) {
893871
auto conn = std::make_shared<MockConnection>();
894872
Client client(conn);

google/cloud/spanner/commit_options.h

Lines changed: 0 additions & 54 deletions
This file was deleted.

google/cloud/spanner/commit_options_test.cc

Lines changed: 0 additions & 40 deletions
This file was deleted.

google/cloud/spanner/commit_result.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,18 @@
1717

1818
#include "google/cloud/spanner/timestamp.h"
1919
#include "google/cloud/spanner/version.h"
20-
#include "absl/types/optional.h"
21-
#include <cstdint>
2220

2321
namespace google {
2422
namespace cloud {
2523
namespace spanner {
2624
inline namespace SPANNER_CLIENT_NS {
2725

28-
/**
29-
* Statistics returned for a committed Transaction.
30-
*/
31-
struct CommitStats {
32-
std::int64_t mutation_count; // total number of mutations
33-
};
34-
3526
/**
3627
* The result of committing a Transaction.
3728
*/
3829
struct CommitResult {
3930
/// The Cloud Spanner timestamp at which the transaction committed.
4031
Timestamp commit_timestamp;
41-
42-
/// Additional statistics about the committed transaction.
43-
absl::optional<CommitStats> commit_stats;
4432
};
4533

4634
} // namespace SPANNER_CLIENT_NS

google/cloud/spanner/connection.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_CONNECTION_H
1717

1818
#include "google/cloud/spanner/batch_dml_result.h"
19-
#include "google/cloud/spanner/commit_options.h"
2019
#include "google/cloud/spanner/commit_result.h"
2120
#include "google/cloud/spanner/connection_options.h"
2221
#include "google/cloud/spanner/keys.h"
@@ -117,7 +116,6 @@ class Connection {
117116
struct CommitParams {
118117
Transaction transaction;
119118
Mutations mutations;
120-
CommitOptions options;
121119
};
122120

123121
/// Wrap the arguments to `Rollback()`.

google/cloud/spanner/google_cloud_cpp_spanner.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ google_cloud_cpp_spanner_hdrs = [
2323
"bytes.h",
2424
"client.h",
2525
"client_options.h",
26-
"commit_options.h",
2726
"commit_result.h",
2827
"connection.h",
2928
"connection_options.h",

0 commit comments

Comments
 (0)