Skip to content

Commit

Permalink
ENG-4749: #887: Handle failure of delete at start of iteration in PgL…
Browse files Browse the repository at this point in the history
…ibPqTest.SerializableColoring test

Summary:
Sometimes transaction from previous operation did not fully applied.
And it conflicts with table cleanup, i.e. delete all records from table.

Added handling of this case.

Test Plan: ybd release --cxx-test pgwrapper_pg_libpq-test --gtest_filter PgLibPqTest.SerializableColoring -n 200

Reviewers: mikhail, robert, timur

Reviewed By: timur

Subscribers: ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D6301
  • Loading branch information
spolitov committed Mar 9, 2019
1 parent b6f2cba commit c7cfb84
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/yb/yql/pgwrapper/pg_libpq-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ TEST_F(PgLibPqTest, YB_DISABLE_TEST_IN_TSAN(Simple)) {
// The described prodecure is repeated multiple times to increase probability of catching bug,
// w/o running test multiple times.
TEST_F(PgLibPqTest, YB_DISABLE_TEST_IN_TSAN(SerializableColoring)) {
static const std::string kTryAgain = "Try again.";
constexpr auto kKeys = RegularBuildVsSanitizers(10, 20);
constexpr auto kColors = 2;
constexpr auto kIterations = 20;
Expand All @@ -126,7 +127,11 @@ TEST_F(PgLibPqTest, YB_DISABLE_TEST_IN_TSAN(SerializableColoring)) {
for (int iteration = 0; iterations_left > 0; ++iteration) {
SCOPED_TRACE(Format("Iteration: $0", iteration));

ASSERT_OK(Execute(conn.get(), "DELETE FROM t"));
auto status = Execute(conn.get(), "DELETE FROM t");
if (!status.ok()) {
ASSERT_STR_CONTAINS(status.ToString(), kTryAgain);
continue;
}
for (int k = 0; k != kKeys; ++k) {
int32_t color = RandomUniformInt(0, kColors - 1);
ASSERT_OK(Execute(conn.get(),
Expand All @@ -146,7 +151,7 @@ TEST_F(PgLibPqTest, YB_DISABLE_TEST_IN_TSAN(SerializableColoring)) {
auto res = Fetch(conn.get(), "SELECT * FROM t");
if (!res.ok()) {
auto msg = res.status().message().ToBuffer();
ASSERT_TRUE(msg.find("Try again.") != std::string::npos) << res.status();
ASSERT_STR_CONTAINS(res.status().ToString(), kTryAgain);
return;
}
auto columns = PQnfields(res->get());
Expand Down

0 comments on commit c7cfb84

Please sign in to comment.