Checks that in-progress compactions are not visible. The test mimics in-progress compactions by opening a transaction and creating a new base directory. The new base directory is empty and must not have an effect on query results until the transaction is committed.
(self, unique_database)
| 284 | @SkipIfHive2.acid |
| 285 | @SkipIfFS.hive |
| 286 | def test_in_progress_compactions(self, unique_database): |
| 287 | """Checks that in-progress compactions are not visible. The test mimics |
| 288 | in-progress compactions by opening a transaction and creating a new base |
| 289 | directory. The new base directory is empty and must not have an effect |
| 290 | on query results until the transaction is committed.""" |
| 291 | tbl_name = "{}.{}".format(unique_database, "test_compaction") |
| 292 | self.execute_query("create table {} (i int) tblproperties" |
| 293 | "('transactional'='true'," |
| 294 | "'transactional_properties'='insert_only')".format(tbl_name)) |
| 295 | self.execute_query("insert into {} values (1)".format(tbl_name)) |
| 296 | |
| 297 | # Create new base directory with a valid write id. |
| 298 | txn_id = self._open_txn() |
| 299 | tbl_file = self.execute_query( |
| 300 | "show files in {}".format(tbl_name)).data[0].split("\t")[0] |
| 301 | tbl_dir = tbl_file[tbl_file.find("/test-warehouse"):tbl_file.rfind("delta_")] |
| 302 | new_base_dir_with_old_write_id = tbl_dir + "base_1_v" + str(txn_id) |
| 303 | check_call(['hdfs', 'dfs', '-mkdir', '-p', new_base_dir_with_old_write_id]) |
| 304 | |
| 305 | # Transaction is not committed so the new empty base directory must not have |
| 306 | # any effect on query results. |
| 307 | self.execute_query("refresh {}".format(tbl_name)) |
| 308 | assert len(self.execute_query("select * from {}".format(tbl_name)).data) != 0 |
| 309 | |
| 310 | # Transaction is committed, now the query should see the table as empty. Of course, |
| 311 | # real compactions don't remove data, but that verifies that the query reads the |
| 312 | # new directory. |
| 313 | self._commit_txn(txn_id) |
| 314 | self.execute_query("refresh {}".format(tbl_name)) |
| 315 | assert len(self.execute_query("select * from {}".format(tbl_name)).data) == 0 |
| 316 | |
| 317 | @SkipIfHive2.acid |
| 318 | @SkipIf.not_dfs |
nothing calls this directly
no test coverage detected