|
17 | 17 |
|
18 | 18 | from __future__ import absolute_import, division, print_function |
19 | 19 | from builtins import range |
| 20 | +import time |
20 | 21 | import pytest |
21 | 22 | from tests.common.custom_cluster_test_suite import CustomClusterTestSuite |
22 | 23 | from tests.common.skip import SkipIfBuildType |
| 24 | +from tests.util.cancel_util import cancel_query_and_validate_state |
23 | 25 |
|
24 | 26 |
|
25 | 27 | @SkipIfBuildType.not_dev_build |
26 | 28 | class TestExchangeDeferredBatches(CustomClusterTestSuite): |
27 | 29 |
|
28 | | - @classmethod |
29 | | - def setup_class(cls): |
30 | | - if cls.exploration_strategy() != 'exhaustive': |
31 | | - pytest.skip('runs only in exhaustive') |
32 | | - super(TestExchangeDeferredBatches, cls).setup_class() |
| 30 | + @classmethod |
| 31 | + def setup_class(cls): |
| 32 | + if cls.exploration_strategy() != 'exhaustive': |
| 33 | + pytest.skip('runs only in exhaustive') |
| 34 | + super(TestExchangeDeferredBatches, cls).setup_class() |
33 | 35 |
|
34 | | - @pytest.mark.execute_serially |
35 | | - @CustomClusterTestSuite.with_args( |
36 | | - "--stress_datastream_recvr_delay_ms=3000" |
37 | | - + " --exchg_node_buffer_size_bytes=1024" |
38 | | - + " --datastream_service_num_deserialization_threads=1" |
39 | | - + " --impala_slow_rpc_threshold_ms=500") |
40 | | - def test_exchange_small_buffer(self, vector): |
41 | | - """Exercise the code which handles deferred row batches. In particular, |
42 | | - the exchange buffer is set to a small value to cause incoming row batches |
43 | | - to be deferred at the receiver. Also, use a single deserialization thread |
44 | | - to limit the speed in which the deferred row batches are dequeued. These |
45 | | - settings help expose the race in IMPALA-8239 when there is any error |
46 | | - deserializing deferred row batches.""" |
| 36 | + @pytest.mark.execute_serially |
| 37 | + @CustomClusterTestSuite.with_args( |
| 38 | + "--stress_datastream_recvr_delay_ms=3000" |
| 39 | + + " --exchg_node_buffer_size_bytes=1024" |
| 40 | + + " --datastream_service_num_deserialization_threads=1" |
| 41 | + + " --impala_slow_rpc_threshold_ms=500") |
| 42 | + def test_exchange_small_buffer(self, vector): |
| 43 | + """Exercise the code which handles deferred row batches. In particular, |
| 44 | + the exchange buffer is set to a small value to cause incoming row batches |
| 45 | + to be deferred at the receiver. Also, use a single deserialization thread |
| 46 | + to limit the speed in which the deferred row batches are dequeued. These |
| 47 | + settings help expose the race in IMPALA-8239 when there is any error |
| 48 | + deserializing deferred row batches.""" |
47 | 49 |
|
48 | | - TEST_QUERY = "select count(*) from tpch.lineitem t1, tpch.lineitem t2 " +\ |
49 | | - "where t1.l_orderkey = t2.l_orderkey" |
50 | | - EXPECTED_RESULT = ['30012985'] |
| 50 | + TEST_QUERY = "select count(*) from tpch.lineitem t1, tpch.lineitem t2 " +\ |
| 51 | + "where t1.l_orderkey = t2.l_orderkey" |
| 52 | + EXPECTED_RESULT = ['30012985'] |
51 | 53 |
|
52 | | - for i in range(10): |
53 | | - # Simulate row batch insertion failure. This triggers IMPALA-8239. |
54 | | - debug_action = 'RECVR_ADD_BATCH:FAIL@0.8' |
55 | | - self.execute_query_expect_failure(self.client, TEST_QUERY, |
56 | | - query_options={'debug_action': debug_action}) |
| 54 | + for i in range(10): |
| 55 | + # Simulate row batch insertion failure. This triggers IMPALA-8239. |
| 56 | + debug_action = 'RECVR_ADD_BATCH:FAIL@0.8' |
| 57 | + self.execute_query_expect_failure(self.client, TEST_QUERY, |
| 58 | + query_options={'debug_action': debug_action}) |
57 | 59 |
|
58 | | - for i in range(10): |
59 | | - # Simulate row batch insertion failure. This triggers IMPALA-8239. |
60 | | - debug_action = 'RECVR_UNPACK_PAYLOAD:FAIL@0.8' |
61 | | - self.execute_query_expect_failure(self.client, TEST_QUERY, |
62 | | - query_options={'debug_action': debug_action}) |
| 60 | + for i in range(10): |
| 61 | + # Simulate row batch insertion failure. This triggers IMPALA-8239. |
| 62 | + debug_action = 'RECVR_UNPACK_PAYLOAD:FAIL@0.8' |
| 63 | + self.execute_query_expect_failure(self.client, TEST_QUERY, |
| 64 | + query_options={'debug_action': debug_action}) |
63 | 65 |
|
64 | | - # Do a run with no debug action to make sure things are sane. |
65 | | - result = self.execute_query(TEST_QUERY, vector.get_value('exec_option')) |
66 | | - assert result.data == EXPECTED_RESULT |
| 66 | + # Do a run with no debug action to make sure things are sane. |
| 67 | + result = self.execute_query(TEST_QUERY, vector.get_value('exec_option')) |
| 68 | + assert result.data == EXPECTED_RESULT |
| 69 | + |
| 70 | + @pytest.mark.execute_serially |
| 71 | + @CustomClusterTestSuite.with_args( |
| 72 | + " --exchg_node_buffer_size_bytes=32768" |
| 73 | + + " --datastream_service_num_deserialization_threads=16") |
| 74 | + def test_parallel_deserialization_buffer_limit(self, vector): |
| 75 | + """The test reproduces the scenario in IMPALA-13475 - delay is added to |
| 76 | + the receiver to cause most TransmitData RPCs to be deferred and buffer |
| 77 | + size is set to a small enough value where the queue can only hold 2 RowBatches |
| 78 | + which is not enough for a row batch from all 3 senders. This means that the |
| 79 | + receiver must limit the number of parallel deserialization tasks started to |
| 80 | + ensure that the queue has enough memory for the result of all started tasks.""" |
| 81 | + |
| 82 | + TEST_QUERY = "select count(*) from tpch.lineitem t1, tpch.lineitem t2 " +\ |
| 83 | + "where t1.l_orderkey = t2.l_orderkey" |
| 84 | + EXPECTED_RESULT = ['30012985'] |
| 85 | + |
| 86 | + # There are ~1100 row batches per exchange node under the join, with 1ms |
| 87 | + # sleep they combine to guaranteed >2s run time. |
| 88 | + query_options = {'debug_action': 'RECVR_ADD_BATCH:SLEEP@1'} |
| 89 | + start = time.time() |
| 90 | + result = self.execute_query(TEST_QUERY, query_options=query_options) |
| 91 | + elapsed = time.time() - start |
| 92 | + assert result.data == EXPECTED_RESULT |
| 93 | + assert elapsed > 2, \ |
| 94 | + "Query should take >2s due to RECVR_ADD_BATCH:SLEEP@1, got %.2fs" % elapsed |
| 95 | + |
| 96 | + # Test that the query can be cancelled at several points. The query takes around |
| 97 | + # 3sec due to the debug_action. |
| 98 | + for cancel_delay in [0.5, 1.0, 1.5, 2.0, 2.5]: |
| 99 | + cancel_query_and_validate_state(TEST_QUERY, |
| 100 | + query_options, vector.get_value('table_format'), cancel_delay) |
0 commit comments