Skip to content

Commit eede5fd

Browse files
committed
take into account batch size
1 parent bacac4e commit eede5fd

3 files changed

Lines changed: 16 additions & 16 deletions

File tree

spqr_monitor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ def get_task_groups(self) -> List[TaskGroup]:
147147
task_group_id=parts[0],
148148
destination_shard_id=parts[1],
149149
source_key_range_id=parts[2],
150-
state=parts[5],
151-
error=parts[6] if parts[6] else None,
150+
state=parts[6],
151+
error=parts[7] if len(parts) > 7 and parts[7] else None,
152152
)
153153
)
154154

test_integration.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ def test_full_iteration_with_errors(self):
3030
read_only_response = " is_read_only \n--------------\n false"
3131

3232
# Mock response: some task groups with retryable errors
33-
task_groups_response = """task_group_id | destination_shard_id | source_key_range_id | destination_key_range_id | move_task_id | state | error
34-
----+---+---+---+---+---+---
35-
tg1 | shard-001 | kr1 | dst_kr1 | move1 | ERROR | rpc error: code = Canceled desc = grpc: the client connection is closing
36-
tg2 | shard-002 | kr2 | dst_kr2 | move2 | RUNNING | """
33+
task_groups_response = """task_group_id | destination_shard_id | source_key_range_id | destination_key_range_id | batch_size | move_task_id | state | error
34+
----+---+---+---+---+---+---+---
35+
tg1 | shard-001 | kr1 | dst_kr1 | 300000 | move1 | ERROR | rpc error: code = Canceled desc = grpc: the client connection is closing
36+
tg2 | shard-002 | kr2 | dst_kr2 | 300000 | move2 | RUNNING | """
3737

3838
# Mock response: key ranges
3939
key_ranges_response = """key_range_id | shard_id | distribution_id | lower_bound | locked
@@ -68,10 +68,10 @@ def test_full_iteration_all_running(self):
6868

6969
# Mock response: some task groups are RUNNING (less than 8)
7070
# This will trigger key range redistribution
71-
task_groups_response = """task_group_id | destination_shard_id | source_key_range_id | state | error
72-
----+---+---+---+---
73-
tg1 | shard-001 | kr1 | RUNNING |
74-
tg2 | shard-001 | kr2 | RUNNING |"""
71+
task_groups_response = """task_group_id | destination_shard_id | source_key_range_id | destination_key_range_id | batch_size | move_task_id | state | error
72+
----+---+---+---+---+---+---+---
73+
tg1 | shard-001 | kr1 | dst_kr1 | 300000 | move1 | RUNNING |
74+
tg2 | shard-001 | kr2 | dst_kr2 | 300000 | move2 | RUNNING |"""
7575

7676
key_ranges_response = """key_range_id | shard_id | distribution_id | lower_bound | locked
7777
----+---+---+---+---

test_spqr_monitor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def test_execute_show(self, mock_run):
5555

5656
def test_parse_task_groups_success(self):
5757
"""Test parsing task groups from psql output."""
58-
psql_output = """ task_group_id | destination_shard_id | source_key_range_id | destination_key_range_id | move_task_id | state | error
59-
--------------------------------------+----------------------+----------------------------------------------------+--------------------------------------+--------------------------------------+---------+------------------------------------------------------------------------------------------------
60-
07f8dd64-b60a-452d-8c8c-36053b266d60 | shard-005 | ds_user_id_kr_8895479c_634d_4bff_bd0b_6c31f2bd6da5 | f366d2af-1107-42b3-9e68-314aa2cdea0f | fee0b99d-c6af-420d-b415-f25afdf47352 | ERROR | rpc error: code = Canceled desc = grpc: the client connection is closing
61-
69cc1380-1a41-44a4-b100-7c340ad450c4 | shard-001 | ds_user_id_kr_19bd3e99_d339_48ff_88de_6072b852d0ee | 00045f2f-aee9-48c3-9248-d0acfac839d3 | cde66b67-0a68-4526-a91e-a202d66a2f00 | ERROR | rpc error: code = Canceled desc = grpc: the client connection is closing
62-
5f6d8069-3794-4442-8750-fa0cdfe3b721 | shard-001 | ds_user_id_kr_0584766d_9c2c_438a_8c0c_28678d8954af | b4674c92-1a01-4a8e-8764-b4961a98e352 | 00cf8b2d-6b57-48cd-81b8-76cbc798ad90 | RUNNING |"""
58+
psql_output = """ task_group_id | destination_shard_id | source_key_range_id | destination_key_range_id | batch_size | move_task_id | state | error
59+
--------------------------------------+----------------------+----------------------------------------------------+--------------------------------------+------------+--------------------------------------+---------+------------------------------------------------------------------------------------------------
60+
07f8dd64-b60a-452d-8c8c-36053b266d60 | shard-005 | ds_user_id_kr_8895479c_634d_4bff_bd0b_6c31f2bd6da5 | f366d2af-1107-42b3-9e68-314aa2cdea0f | 300000 | fee0b99d-c6af-420d-b415-f25afdf47352 | ERROR | rpc error: code = Canceled desc = grpc: the client connection is closing
61+
69cc1380-1a41-44a4-b100-7c340ad450c4 | shard-001 | ds_user_id_kr_19bd3e99_d339_48ff_88de_6072b852d0ee | 00045f2f-aee9-48c3-9248-d0acfac839d3 | 300000 | cde66b67-0a68-4526-a91e-a202d66a2f00 | ERROR | rpc error: code = Canceled desc = grpc: the client connection is closing
62+
5f6d8069-3794-4442-8750-fa0cdfe3b721 | shard-001 | ds_user_id_kr_0584766d_9c2c_438a_8c0c_28678d8954af | b4674c92-1a01-4a8e-8764-b4961a98e352 | 300000 | 00cf8b2d-6b57-48cd-81b8-76cbc798ad90 | RUNNING |"""
6363

6464
with patch.object(
6565
self.monitor, "execute_show", return_value=(psql_output, "", 0)
@@ -73,7 +73,7 @@ def test_parse_task_groups_success(self):
7373

7474
def test_parse_task_groups_empty(self):
7575
"""Test parsing empty task groups."""
76-
psql_output = """task_group_id | destination_shard_id | source_key_range_id | destination_key_range_id | move_task_id | state | error
76+
psql_output = """task_group_id | destination_shard_id | source_key_range_id | destination_key_range_id | batch_size | move_task_id | state | error
7777
(0 rows)"""
7878

7979
with patch.object(

0 commit comments

Comments
 (0)