| 135 | }; |
| 136 | |
| 137 | void CopyTest::BMExceptionRecoveryTest(BMExceptionRecoveryTestConfig cfg) { |
| 138 | if (inMemMode) { |
| 139 | failureFrequency = UINT64_MAX; |
| 140 | resetDBFlaky(cfg.canFailDuringExecute, cfg.canFailDuringCheckpoint, |
| 141 | cfg.canFailDuringCommit); |
| 142 | } else { |
| 143 | createDBAndConn(); |
| 144 | } |
| 145 | |
| 146 | cfg.initFunc(conn.get()); |
| 147 | |
| 148 | if (!inMemMode) { |
| 149 | resetDBFlaky(cfg.canFailDuringExecute, cfg.canFailDuringCheckpoint, |
| 150 | cfg.canFailDuringCommit); |
| 151 | } |
| 152 | |
| 153 | for (int i = 0;; i++) { |
| 154 | ASSERT_LT(i, 20); |
| 155 | auto result = cfg.executeFunc(conn.get(), i); |
| 156 | if (!result->isSuccess()) { |
| 157 | if (cfg.earlyExitOnFailureFunc(result.get())) { |
| 158 | break; |
| 159 | } |
| 160 | ASSERT_EQ(result->getErrorMessage(), "Buffer manager exception: Unable to allocate " |
| 161 | "memory! The buffer pool is full and no " |
| 162 | "memory could be freed!"); |
| 163 | } else { |
| 164 | break; |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | if (inMemMode) { |
| 169 | failureFrequency = UINT64_MAX; |
| 170 | } else { |
| 171 | // Reopen the DB so no spurious errors occur during the query |
| 172 | resetDB(TestHelper::DEFAULT_BUFFER_POOL_SIZE_FOR_TESTING); |
| 173 | } |
| 174 | { |
| 175 | // Test that the table copied as expected after the query |
| 176 | auto result = cfg.checkFunc(conn.get()); |
| 177 | ASSERT_TRUE(result->isSuccess()) << result->getErrorMessage(); |
| 178 | ASSERT_TRUE(result->hasNext()); |
| 179 | ASSERT_EQ(cfg.checkResult, result->getNext()->getValue(0)->getValue<int64_t>()); |
| 180 | } |
| 181 | |
| 182 | // TODO(Royi) prevent leaking of allocated pages during checkpoint rollback |
| 183 | if (!inMemMode && !cfg.canFailDuringCheckpoint) { |
| 184 | FSMLeakChecker::checkForLeakedPages(conn.get()); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | TEST_F(CopyTest, NodeCopyWithoutDefaultHashIndexSorted) { |
| 189 | createDBAndConn(); |