| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 60354fb commit dad8a9b
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -270,6 +270,8 @@ function (spanner_client_define_tests) | |||
| 270 | 270 | testing/cleanup_stale_instances.h | |
| 271 | 271 | testing/database_integration_test.cc | |
| 272 | 272 | testing/database_integration_test.h | |
| 273 | + testing/debug_log.cc | ||
| 274 | + testing/debug_log.h | ||
| 273 | 275 | testing/fake_clock.h | |
| 274 | 276 | testing/instance_location.cc | |
| 275 | 277 | testing/instance_location.h | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,6 +18,7 @@ | |||
| 18 | 18 | #include "google/cloud/spanner/database.h" | |
| 19 | 19 | #include "google/cloud/spanner/instance.h" | |
| 20 | 20 | #include "google/cloud/spanner/numeric.h" | |
| 21 | + #include "google/cloud/spanner/testing/debug_log.h" // TODO(#4758): remove | ||
| 21 | 22 | #include "google/cloud/spanner/testing/pick_random_instance.h" | |
| 22 | 23 | #include "google/cloud/spanner/testing/random_database_name.h" | |
| 23 | 24 | #include "google/cloud/internal/getenv.h" | |
@@ -72,6 +73,8 @@ void AddColumn(google::cloud::spanner_admin::DatabaseAdminClient client, | |||
| 72 | 73 | }; | |
| 73 | 74 | auto metadata = | |
| 74 | 75 | client.UpdateDatabaseDdl(database.FullName(), statements).get(); | |
| 76 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 77 | + client, database, metadata.status()); //! TODO(#4758) | ||
| 75 | 78 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 76 | 79 | std::cout << "Column added.\nNew DDL:\n" << metadata->DebugString(); | |
| 77 | 80 | } | |
@@ -249,6 +252,8 @@ void CaseSensitivity( | |||
| 249 | 252 | }; | |
| 250 | 253 | auto metadata = | |
| 251 | 254 | admin_client.UpdateDatabaseDdl(database.FullName(), statements).get(); | |
| 255 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 256 | + admin_client, database, metadata.status()); //! TODO(#4758) | ||
| 252 | 257 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 253 | 258 | std::cout << "Tables created.\nNew DDL:\n" << metadata->DebugString(); | |
| 254 | 259 | ||
@@ -486,6 +491,8 @@ void InterleavedTable(google::cloud::spanner_admin::DatabaseAdminClient client, | |||
| 486 | 491 | }; | |
| 487 | 492 | auto metadata = | |
| 488 | 493 | client.UpdateDatabaseDdl(database.FullName(), statements).get(); | |
| 494 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 495 | + client, database, metadata.status()); //! TODO(#4758) | ||
| 489 | 496 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 490 | 497 | std::cout << "Tables created.\nNew DDL:\n" << metadata->DebugString(); | |
| 491 | 498 | } | |
@@ -504,6 +511,8 @@ void CreateStoringIndex( | |||
| 504 | 511 | }; | |
| 505 | 512 | auto metadata = | |
| 506 | 513 | client.UpdateDatabaseDdl(database.FullName(), statements).get(); | |
| 514 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 515 | + client, database, metadata.status()); //! TODO(#4758) | ||
| 507 | 516 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 508 | 517 | std::cout << "Index added.\nNew DDL:\n" << metadata->DebugString(); | |
| 509 | 518 | } | |
@@ -526,6 +535,8 @@ void InformationSchema( | |||
| 526 | 535 | }; | |
| 527 | 536 | auto metadata = | |
| 528 | 537 | admin_client.UpdateDatabaseDdl(database.FullName(), statements).get(); | |
| 538 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 539 | + admin_client, database, metadata.status()); //! TODO(#4758) | ||
| 529 | 540 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 530 | 541 | std::cout << "Table created.\nNew DDL:\n" << metadata->DebugString(); | |
| 531 | 542 | ||
@@ -724,6 +735,8 @@ void CreateTables(google::cloud::spanner_admin::DatabaseAdminClient client, | |||
| 724 | 735 | }; | |
| 725 | 736 | auto metadata = | |
| 726 | 737 | client.UpdateDatabaseDdl(database.FullName(), statements).get(); | |
| 738 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 739 | + client, database, metadata.status()); //! TODO(#4758) | ||
| 727 | 740 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 728 | 741 | std::cout << "Tables created.\nNew DDL:\n" << metadata->DebugString(); | |
| 729 | 742 | } | |
@@ -740,6 +753,8 @@ void DropTables(google::cloud::spanner_admin::DatabaseAdminClient client, | |||
| 740 | 753 | }; | |
| 741 | 754 | auto metadata = | |
| 742 | 755 | client.UpdateDatabaseDdl(database.FullName(), statements).get(); | |
| 756 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 757 | + client, database, metadata.status()); //! TODO(#4758) | ||
| 743 | 758 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 744 | 759 | std::cout << "Tables dropped.\nNew DDL:\n" << metadata->DebugString(); | |
| 745 | 760 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -24,6 +24,7 @@ | |||
| 24 | 24 | #include "google/cloud/spanner/connection_options.h" | |
| 25 | 25 | #include "google/cloud/spanner/create_instance_request_builder.h" | |
| 26 | 26 | #include "google/cloud/spanner/row.h" | |
| 27 | + #include "google/cloud/spanner/testing/debug_log.h" // TODO(#4758): remove | ||
| 27 | 28 | #include "google/cloud/spanner/testing/instance_location.h" | |
| 28 | 29 | #include "google/cloud/spanner/testing/pick_instance_config.h" | |
| 29 | 30 | #include "google/cloud/spanner/testing/pick_random_instance.h" | |
@@ -556,6 +557,8 @@ void UpdateDatabaseWithDefaultLeader( | |||
| 556 | 557 | auto metadata = | |
| 557 | 558 | client.UpdateDatabaseDdl(database.FullName(), std::move(statements)) | |
| 558 | 559 | .get(); | |
| 560 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 561 | + client, database, metadata.status()); //! TODO(#4758) | ||
| 559 | 562 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 560 | 563 | std::cout << "`default_leader` altered, new DDL metadata:\n" | |
| 561 | 564 | << metadata->DebugString(); | |
@@ -584,6 +587,8 @@ void CreateTableWithDatatypes( | |||
| 584 | 587 | (allow_commit_timestamp=true) | |
| 585 | 588 | ) PRIMARY KEY (VenueId))"""}) | |
| 586 | 589 | .get(); | |
| 590 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 591 | + client, database, metadata.status()); //! TODO(#4758) | ||
| 587 | 592 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 588 | 593 | std::cout << "`Venues` table created, new DDL:\n" << metadata->DebugString(); | |
| 589 | 594 | } | |
@@ -608,6 +613,8 @@ void CreateTableWithTimestamp( | |||
| 608 | 613 | ) PRIMARY KEY (SingerId, VenueId, EventDate), | |
| 609 | 614 | INTERLEAVE IN PARENT Singers ON DELETE CASCADE)"""}) | |
| 610 | 615 | .get(); | |
| 616 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 617 | + client, database, metadata.status()); //! TODO(#4758) | ||
| 611 | 618 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 612 | 619 | std::cout << "`Performances` table created, new DDL:\n" | |
| 613 | 620 | << metadata->DebugString(); | |
@@ -626,6 +633,8 @@ void AddIndex(google::cloud::spanner_admin::DatabaseAdminClient client, | |||
| 626 | 633 | database.FullName(), | |
| 627 | 634 | {"CREATE INDEX AlbumsByAlbumTitle ON Albums(AlbumTitle)"}) | |
| 628 | 635 | .get(); | |
| 636 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 637 | + client, database, metadata.status()); //! TODO(#4758) | ||
| 629 | 638 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 630 | 639 | std::cout << "`AlbumsByAlbumTitle` Index successfully added, new DDL:\n" | |
| 631 | 640 | << metadata->DebugString(); | |
@@ -669,6 +678,8 @@ void AddColumn(google::cloud::spanner_admin::DatabaseAdminClient client, | |||
| 669 | 678 | database.FullName(), | |
| 670 | 679 | {"ALTER TABLE Albums ADD COLUMN MarketingBudget INT64"}) | |
| 671 | 680 | .get(); | |
| 681 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 682 | + client, database, metadata.status()); //! TODO(#4758) | ||
| 672 | 683 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 673 | 684 | std::cout << "Added MarketingBudget column\n"; | |
| 674 | 685 | } | |
@@ -688,6 +699,8 @@ void AddTimestampColumn( | |||
| 688 | 699 | {"ALTER TABLE Albums ADD COLUMN LastUpdateTime TIMESTAMP " | |
| 689 | 700 | "OPTIONS (allow_commit_timestamp=true)"}) | |
| 690 | 701 | .get(); | |
| 702 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 703 | + client, database, metadata.status()); //! TODO(#4758) | ||
| 691 | 704 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 692 | 705 | std::cout << "Added LastUpdateTime column\n"; | |
| 693 | 706 | } | |
@@ -705,6 +718,8 @@ void AddStoringIndex(google::cloud::spanner_admin::DatabaseAdminClient client, | |||
| 705 | 718 | CREATE INDEX AlbumsByAlbumTitle2 ON Albums(AlbumTitle) | |
| 706 | 719 | STORING (MarketingBudget))"""}) | |
| 707 | 720 | .get(); | |
| 721 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 722 | + client, database, metadata.status()); //! TODO(#4758) | ||
| 708 | 723 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 709 | 724 | std::cout << "`AlbumsByAlbumTitle2` Index successfully added, new DDL:\n" | |
| 710 | 725 | << metadata->DebugString(); | |
@@ -1981,6 +1996,8 @@ void AddJsonColumn(google::cloud::spanner_admin::DatabaseAdminClient client, | |||
| 1981 | 1996 | .UpdateDatabaseDdl(database.FullName(), {R"""( | |
| 1982 | 1997 | ALTER TABLE Venues ADD COLUMN VenueDetails JSON)"""}) | |
| 1983 | 1998 | .get(); | |
| 1999 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 2000 | + client, database, metadata.status()); //! TODO(#4758) | ||
| 1984 | 2001 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 1985 | 2002 | std::cout << "`Venues` table altered, new DDL:\n" << metadata->DebugString(); | |
| 1986 | 2003 | } | |
@@ -2058,6 +2075,8 @@ void AddNumericColumn(google::cloud::spanner_admin::DatabaseAdminClient client, | |||
| 2058 | 2075 | .UpdateDatabaseDdl(database.FullName(), {R"""( | |
| 2059 | 2076 | ALTER TABLE Venues ADD COLUMN Revenue NUMERIC)"""}) | |
| 2060 | 2077 | .get(); | |
| 2078 | + google::cloud::spanner_testing::LogUpdateDatabaseDdl( //! TODO(#4758) | ||
| 2079 | + client, database, metadata.status()); //! TODO(#4758) | ||
| 2061 | 2080 | if (!metadata) throw std::runtime_error(metadata.status().message()); | |
| 2062 | 2081 | std::cout << "`Venues` table altered, new DDL:\n" << metadata->DebugString(); | |
| 2063 | 2082 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,6 +20,7 @@ spanner_client_testing_hdrs = [ | |||
| 20 | 20 | "testing/cleanup_stale_databases.h", | |
| 21 | 21 | "testing/cleanup_stale_instances.h", | |
| 22 | 22 | "testing/database_integration_test.h", | |
| 23 | + "testing/debug_log.h", | ||
| 23 | 24 | "testing/fake_clock.h", | |
| 24 | 25 | "testing/instance_location.h", | |
| 25 | 26 | "testing/matchers.h", | |
@@ -39,6 +40,7 @@ spanner_client_testing_srcs = [ | |||
| 39 | 40 | "testing/cleanup_stale_databases.cc", | |
| 40 | 41 | "testing/cleanup_stale_instances.cc", | |
| 41 | 42 | "testing/database_integration_test.cc", | |
| 43 | + "testing/debug_log.cc", | ||
| 42 | 44 | "testing/instance_location.cc", | |
| 43 | 45 | "testing/pick_instance_config.cc", | |
| 44 | 46 | "testing/pick_random_instance.cc", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,53 @@ | |||
| 1 | + // Copyright 2022 Google LLC | ||
| 2 | + // | ||
| 3 | + // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + // you may not use this file except in compliance with the License. | ||
| 5 | + // You may obtain a copy of the License at | ||
| 6 | + // | ||
| 7 | + // https://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + // | ||
| 9 | + // Unless required by applicable law or agreed to in writing, software | ||
| 10 | + // distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + // See the License for the specific language governing permissions and | ||
| 13 | + // limitations under the License. | ||
| 14 | + | ||
| 15 | + #include "google/cloud/spanner/testing/debug_log.h" | ||
| 16 | + #include "google/cloud/log.h" | ||
| 17 | + | ||
| 18 | + namespace google { | ||
| 19 | + namespace cloud { | ||
| 20 | + namespace spanner_testing { | ||
| 21 | + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN | ||
| 22 | + | ||
| 23 | + void LogUpdateDatabaseDdl( | ||
| 24 | + google::cloud::spanner_admin::DatabaseAdminClient client, | ||
| 25 | + google::cloud::spanner::Database const& database, | ||
| 26 | + google::cloud::Status const& status) { | ||
| 27 | + if (status.ok()) return; | ||
| 28 | + | ||
| 29 | + GCP_LOG(DEBUG) << std::string(26, '=') << " UpdateDatabaseDdl() " | ||
| 30 | + << std::string(26, '='); | ||
| 31 | + | ||
| 32 | + // Call GetDatabaseDdl() and ListDatabaseOperations() so that their | ||
| 33 | + // RPC traces can give us information about the state of the database. | ||
| 34 | + auto ddl = client.GetDatabaseDdl(database.FullName()); | ||
| 35 | + google::spanner::admin::database::v1::ListDatabaseOperationsRequest request; | ||
| 36 | + request.set_parent(database.instance().FullName()); | ||
| 37 | + request.set_filter("name:" + database.FullName() + "/"); | ||
| 38 | + for (auto const& operation : client.ListDatabaseOperations(request)) { | ||
| 39 | + static_cast<void>(operation); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + GCP_LOG(DEBUG) << std::string(73, '='); | ||
| 43 | + | ||
| 44 | + // Terminate the process abruptly (after flushing the client log), without | ||
| 45 | + // dropping the database. This means we'll have a chance to examine it and | ||
| 46 | + // its server-side logs until they are garbage-collected. | ||
| 47 | + GCP_LOG(FATAL) << "Terminating after UpdateDatabaseDdl() failure"; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END | ||
| 51 | + } // namespace spanner_testing | ||
| 52 | + } // namespace cloud | ||
| 53 | + } // namespace google | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,42 @@ | |||
| 1 | + // Copyright 2022 Google LLC | ||
| 2 | + // | ||
| 3 | + // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + // you may not use this file except in compliance with the License. | ||
| 5 | + // You may obtain a copy of the License at | ||
| 6 | + // | ||
| 7 | + // https://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + // | ||
| 9 | + // Unless required by applicable law or agreed to in writing, software | ||
| 10 | + // distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + // See the License for the specific language governing permissions and | ||
| 13 | + // limitations under the License. | ||
| 14 | + | ||
| 15 | + #ifndef GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_TESTING_DEBUG_LOG_H | ||
| 16 | + #define GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_TESTING_DEBUG_LOG_H | ||
| 17 | + | ||
| 18 | + #include "google/cloud/spanner/admin/database_admin_client.h" | ||
| 19 | + #include "google/cloud/spanner/database.h" | ||
| 20 | + #include "google/cloud/spanner/version.h" | ||
| 21 | + #include "google/cloud/status.h" | ||
| 22 | + | ||
| 23 | + namespace google { | ||
| 24 | + namespace cloud { | ||
| 25 | + namespace spanner_testing { | ||
| 26 | + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * Log everything we can after an UpdateDatabaseDdl() failure so that | ||
| 30 | + * we might have a chance to debug the apparent replays behind #4758. | ||
| 31 | + */ | ||
| 32 | + void LogUpdateDatabaseDdl( | ||
| 33 | + google::cloud::spanner_admin::DatabaseAdminClient client, | ||
| 34 | + google::cloud::spanner::Database const& database, | ||
| 35 | + google::cloud::Status const& status); | ||
| 36 | + | ||
| 37 | + GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END | ||
| 38 | + } // namespace spanner_testing | ||
| 39 | + } // namespace cloud | ||
| 40 | + } // namespace google | ||
| 41 | + | ||
| 42 | + #endif // GOOGLE_CLOUD_CPP_GOOGLE_CLOUD_SPANNER_TESTING_DEBUG_LOG_H | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments