Skip to content

Commit 4ea3d12

Browse files
authored
impl(bigtable): update query plan refresh offset to 1s (#15683)
1 parent e612dba commit 4ea3d12

File tree

2 files changed

+2
-17
lines changed

2 files changed

+2
-17
lines changed

google/cloud/bigtable/internal/query_plan.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace cloud {
2222
namespace bigtable_internal {
2323
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
2424
namespace {
25-
auto constexpr kRefreshDeadlineOffset = 120;
25+
auto constexpr kRefreshDeadlineOffsetMs = 1000;
2626
} // namespace
2727

2828
std::shared_ptr<QueryPlan> QueryPlan::Create(
@@ -45,7 +45,7 @@ void QueryPlan::ScheduleRefresh(std::unique_lock<std::mutex> const&) {
4545
// We want to start the refresh process before the query plan expires.
4646
auto refresh_deadline =
4747
internal::ToChronoTimePoint(response_->valid_until()) -
48-
std::chrono::seconds(kRefreshDeadlineOffset);
48+
std::chrono::milliseconds(kRefreshDeadlineOffsetMs);
4949
std::weak_ptr<QueryPlan> plan = shared_from_this();
5050
refresh_timer_ =
5151
cq_.MakeDeadlineTimer(refresh_deadline)

google/cloud/bigtable/internal/query_plan_test.cc

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "google/cloud/testing_util/fake_clock.h"
1919
#include "google/cloud/testing_util/fake_completion_queue_impl.h"
2020
#include "google/cloud/testing_util/is_proto_equal.h"
21-
#include "google/cloud/testing_util/mock_completion_queue_impl.h"
2221
#include "google/cloud/testing_util/status_matchers.h"
2322
#include <google/bigtable/v2/data.pb.h>
2423
#include <google/protobuf/text_format.h>
@@ -32,12 +31,10 @@ namespace bigtable_internal {
3231
GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN
3332
namespace {
3433

35-
using ::google::cloud::internal::ToProtoTimestamp;
3634
using ::google::cloud::testing_util::FakeCompletionQueueImpl;
3735
using ::google::cloud::testing_util::FakeSystemClock;
3836
using ::google::cloud::testing_util::IsProtoEqual;
3937
using ::google::cloud::testing_util::StatusIs;
40-
using ::google::protobuf::util::TimeUtil;
4138

4239
TEST(QueryPlanTest, ResponseDataWithOriginalValidQueryPlan) {
4340
auto fake_cq_impl = std::make_shared<FakeCompletionQueueImpl>();
@@ -57,8 +54,6 @@ TEST(QueryPlanTest, ResponseDataWithOriginalValidQueryPlan) {
5754
ASSERT_TRUE(google::protobuf::TextFormat::ParseFromString(kResultMetadataText,
5855
&metadata));
5956
*response.mutable_metadata() = metadata;
60-
*response.mutable_valid_until() =
61-
TimeUtil::GetCurrentTime() + TimeUtil::SecondsToDuration(300);
6257

6358
auto plan = QueryPlan::Create(cq, response, [] {
6459
return make_ready_future(
@@ -88,8 +83,6 @@ TEST(QueryPlanTest, RefreshExpiredPlan) {
8883

8984
google::bigtable::v2::PrepareQueryResponse response;
9085
response.set_prepared_query("original-query-plan");
91-
*response.mutable_valid_until() =
92-
ToProtoTimestamp(now + std::chrono::seconds(600));
9386

9487
auto query_plan = QueryPlan::Create(CompletionQueue(fake_cq_impl), response,
9588
refresh_fn, fake_clock);
@@ -98,7 +91,6 @@ TEST(QueryPlanTest, RefreshExpiredPlan) {
9891
ASSERT_STATUS_OK(data);
9992
EXPECT_EQ(data->prepared_query(), "original-query-plan");
10093

101-
fake_clock->AdvanceTime(std::chrono::seconds(500));
10294
fake_cq_impl->SimulateCompletion(true);
10395

10496
data = query_plan->response();
@@ -123,8 +115,6 @@ TEST(QueryPlanTest, FailedRefreshExpiredPlan) {
123115

124116
google::bigtable::v2::PrepareQueryResponse response;
125117
response.set_prepared_query("original-query-plan");
126-
*response.mutable_valid_until() =
127-
ToProtoTimestamp(now + std::chrono::seconds(600));
128118

129119
auto query_plan = QueryPlan::Create(CompletionQueue(fake_cq_impl), response,
130120
refresh_fn, fake_clock);
@@ -133,7 +123,6 @@ TEST(QueryPlanTest, FailedRefreshExpiredPlan) {
133123
ASSERT_STATUS_OK(data);
134124
EXPECT_EQ(data->prepared_query(), "original-query-plan");
135125

136-
fake_clock->AdvanceTime(std::chrono::seconds(500));
137126
fake_cq_impl->SimulateCompletion(true);
138127

139128
data = query_plan->response();
@@ -157,8 +146,6 @@ TEST(QueryPlanTest, RefreshInvalidatedPlan) {
157146

158147
google::bigtable::v2::PrepareQueryResponse response;
159148
response.set_prepared_query("original-query-plan");
160-
*response.mutable_valid_until() =
161-
ToProtoTimestamp(now + std::chrono::seconds(600));
162149

163150
auto query_plan = QueryPlan::Create(CompletionQueue(fake_cq_impl), response,
164151
refresh_fn, fake_clock);
@@ -192,8 +179,6 @@ TEST(QueryPlanTest, FailedRefreshInvalidatedPlan) {
192179

193180
google::bigtable::v2::PrepareQueryResponse response;
194181
response.set_prepared_query("original-query-plan");
195-
*response.mutable_valid_until() =
196-
ToProtoTimestamp(now + std::chrono::seconds(600));
197182

198183
auto query_plan = QueryPlan::Create(CompletionQueue(fake_cq_impl), response,
199184
refresh_fn, fake_clock);

0 commit comments

Comments
 (0)