Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_coordinator_queue_management fails on Python 3.12 #18740

Closed
avikivity opened this issue May 19, 2024 · 3 comments
Closed

test_coordinator_queue_management fails on Python 3.12 #18740

avikivity opened this issue May 19, 2024 · 3 comments
Assignees
Labels
Backport candidate backport/none Backport is not required
Milestone

Comments

@avikivity
Copy link
Member

On Fedora 40:

./test.py --mode dev test_coordinator_queue_management

______________________ test_coordinator_queue_management _______________________

manager = <test.pylib.manager_client.ManagerClient object at 0x7f01400cd850>

    @pytest.mark.asyncio
    @skip_mode('release', 'error injections are not supported in release mode')
    async def test_coordinator_queue_management(manager: ManagerClient):
        """This test creates a 5 node cluster with 2 down nodes (A and B). After that it
           creates a queue of 3 topology operation: bootstrap, removenode A and removenode B
           with ignore_nodes=A. Check that all operation manage to complete.
           Then it downs one node and creates a queue with two requests:
           bootstrap and decommission. Since none can proceed both should be canceled.
        """
        await manager.server_add()
        await manager.server_add()
        servers = await manager.running_servers()
        logs = [await manager.server_open_log(srv.server_id) for srv in servers]
        marks = [await log.mark() for log in logs]
        await manager.server_stop_gracefully(servers[3].server_id)
        await manager.server_stop_gracefully(servers[4].server_id)
        await manager.server_not_sees_other_server(servers[0].ip_addr, servers[3].ip_addr)
        await manager.server_not_sees_other_server(servers[0].ip_addr, servers[4].ip_addr)
    
        inj = 'topology_coordinator_pause_before_processing_backlog'
        [await manager.api.enable_injection(s.ip_addr, inj, one_shot=True) for s in servers[:3]]
    
        s3_id = await manager.get_host_id(servers[3].server_id)
        tasks = [asyncio.create_task(manager.server_add()),
                 asyncio.create_task(manager.remove_node(servers[0].server_id, servers[3].server_id)),
                 asyncio.create_task(manager.remove_node(servers[0].server_id, servers[4].server_id, [s3_id]))]
    
>       search = [asyncio.create_task(l.wait_for("received request to join from host_id", m) for l, m in zip(logs[:3], marks[:3]))]

test/topology/test_coordinator_queue_management.py:41: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib64/python3.12/asyncio/tasks.py:420: in create_task
    task = loop.create_task(coro)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <_UnixSelectorEventLoop running=False closed=False debug=False>
coro = <generator object test_coordinator_queue_management.<locals>.<genexpr> at 0x7f013f518ba0>

    def create_task(self, coro, *, name=None, context=None):
        """Schedule a coroutine object.
    
        Return a task object.
        """
        self._check_closed()
        if self._task_factory is None:
>           task = tasks.Task(coro, loop=self, name=name, context=context)
E           TypeError: a coroutine was expected, got <generator object test_coordinator_queue_management.<locals>.<genexpr> at 0x7f013f518ba0>

@avikivity
Copy link
Member Author

/cc @temichus

@avikivity
Copy link
Member Author

Looks like a bug in Python. It was supposed to execute the generator and feed the result to create task, but didn't.

@temichus
Copy link
Contributor

I see some bug python/typeshed#10116

It's about having regular functions with yield as CORO

Can't find where is the problem from the first look, additional debug is need.

@xtrey or @enaydanov could you please take a look if you have time? I bele e that code change should be small. If not will handle it after my VAC.

@temichus temichus self-assigned this May 19, 2024
avikivity added a commit to avikivity/scylladb that referenced this issue May 19, 2024
…ensions of coroutines

Python 3.12 complains when a list comprehension's element type is a coroutine. As far
as I can tell this is a bug. Work around it be perfoming the iteration explicitly.

Fixes scylladb#18740
@mykaul mykaul added the backport/none Backport is not required label May 20, 2024
@mykaul mykaul added this to the 6.0 milestone May 20, 2024
michoecho added a commit to michoecho/scylla that referenced this issue May 20, 2024
The modified lines of code intend to await the first appearance of a log
on one of the nodes.

But due to misplaced parentheses, instead of creating a list of log-awaiting
tasks with a list comprehension, they pass a generator expression to
asyncio.create_task().

This is nonsense, and it fails immediately with a type error.
But since they don't actually check the result of the await,
the test just assumes that the search completed successfully.

This was uncovered by an upgrade to Python 3.12, because its typing is stronger
and asyncio.create_task() screams when it's passed a regular generator.

This patch fixes the bad list comprehension, and also adds an error check
on the completed awaitables (by calling `await` on them).

Fixes scylladb#18740
michoecho added a commit to michoecho/scylla that referenced this issue May 20, 2024
The modified lines of code intend to await the first appearance of a log
on one of the nodes.

But due to misplaced parentheses, instead of creating a list of log-awaiting
tasks with a list comprehension, they pass a generator expression to
asyncio.create_task().

This is nonsense, and it fails immediately with a type error.
But since they don't actually check the result of the await,
the test just assumes that the search completed successfully.

This was uncovered by an upgrade to Python 3.12, because its typing is stronger
and asyncio.create_task() screams when it's passed a regular generator.

This patch fixes the bad list comprehension, and also adds an error check
on the completed awaitables (by calling `await` on them).

Fixes scylladb#18740
michoecho added a commit to michoecho/scylla that referenced this issue May 20, 2024
The modified lines of code intend to await the first appearance of a log
on one of the nodes.

But due to misplaced parentheses, instead of creating a list of log-awaiting
tasks with a list comprehension, they pass a generator expression to
asyncio.create_task().

This is nonsense, and it fails immediately with a type error.
But since they don't actually check the result of the await,
the test just assumes that the search completed successfully.

This was uncovered by an upgrade to Python 3.12, because its typing is stronger
and asyncio.create_task() screams when it's passed a regular generator.

This patch fixes the bad list comprehension, and also adds an error check
on the completed awaitables (by calling `await` on them).

Fixes scylladb#18740
michoecho added a commit to michoecho/scylla that referenced this issue May 20, 2024
The modified lines of code intend to await the first appearance of a log
on one of the nodes.

But due to misplaced parentheses, instead of creating a list of log-awaiting
tasks with a list comprehension, they pass a generator expression to
asyncio.create_task().

This is nonsense, and it fails immediately with a type error.
But since they don't actually check the result of the await,
the test just assumes that the search completed successfully.

This was uncovered by an upgrade to Python 3.12, because its typing is stronger
and asyncio.create_task() screams when it's passed a regular generator.

This patch fixes the bad list comprehension, and also adds an error check
on the completed awaitables (by calling `await` on them).

Fixes scylladb#18740
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment