Skip to content

[New Issue]: Seeing Two collaborative sessions warning occasionally when creating a new file #245

@jzhang20133

Description

@jzhang20133

Description

We are occasionally observing an error dialog when opening up a new file that says there are two collaborative sessions are created for this file.
Screenshot 2024-02-26 at 11 42 20 AM (1)

Reproduce

We haven't found a way to reproduce this reliably. It feels a bit flaky, though I have some suspicion on where this is coming from, mentioned below. Here is are the series of logs we need:

[I 2024-02-26 11:40:01.627 ServerApp] Request for Y document 'TestRTCWithFolder/Untitled.ipynb' with room ID: 9bc89a74-323a-411f-96b4-bf47260a909f
[I 2024-02-26 11:40:01.765 YDocExtension] Creating FileLoader for: TestRTCWithFolder/Untitled.ipynb
[E 2024-02-26 11:40:01.766 ServerApp] Uncaught exception GET /api/collaboration/room/json:notebook:9bc89a74-323a-411f-96b4-bf47260a909f?sessionId=76415e06-5e42-460d-9356-402da6f62da3 (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/collaboration/room/json:notebook:9bc89a74-323a-411f-96b4-bf47260a909f?sessionId=76415e06-5e42-460d-9356-402da6f62da3', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1769, in _execute
        result = await result  # type: ignore
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_collaboration/handlers.py", line 105, in prepare
        await self._websocket_server.start_room(self.room)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/pycrdt_websocket/websocket_server.py", line 88, in start_room
        await self._task_group.start(room.start)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 800, in start
        task = self._spawn(func, args, name, future)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 752, in _spawn
        raise RuntimeError(
    RuntimeError: This task group is not active; no new tasks can be started.
[E 2024-02-26 11:40:01.772 ServerApp] Uncaught exception in write_error
    Traceback (most recent call last):
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1769, in _execute
        result = await result  # type: ignore
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_collaboration/handlers.py", line 105, in prepare
        await self._websocket_server.start_room(self.room)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/pycrdt_websocket/websocket_server.py", line 88, in start_room
        await self._task_group.start(room.start)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 800, in start
        task = self._spawn(func, args, name, future)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 752, in _spawn
        raise RuntimeError(
    RuntimeError: This task group is not active; no new tasks can be started.
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1298, in send_error
        self.write_error(status_code, **kwargs)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 718, in write_error
        html = self.render_template("%s.html" % status_code, **ns)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 644, in render_template
        ns.update(self.template_namespace)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 654, in template_namespace
        logged_in=self.logged_in,
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 196, in logged_in
        user = self.current_user
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1424, in current_user
        self._current_user = self.get_current_user()
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 175, in get_current_user
        raise RuntimeError(msg)
    RuntimeError: Calling `YDocWebSocketHandler.get_current_user()` directly is deprecated in jupyter-server 2.0. Use `self.current_user` instead (works in all versions).
[E 2024-02-26 11:40:01.775 ServerApp] {
      "Host": "localhost:8888",
      "Accept": "*/*",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15"
    }
[E 2024-02-26 11:40:01.775 ServerApp] 500 GET /api/collaboration/room/json:notebook:9bc89a74-323a-411f-96b4-bf47260a909f?sessionId=76415e06-5e42-460d-9356-402da6f62da3 (@127.0.0.1) 9.74ms referer=None
[I 2024-02-26 11:40:01.791 YDocExtension] Watching file: TestRTCWithFolder/Untitled.ipynb
[E 2024-02-26 11:40:02.076 ServerApp] Uncaught exception GET /api/collaboration/room/json:notebook:9bc89a74-323a-411f-96b4-bf47260a909f?sessionId=76415e06-5e42-460d-9356-402da6f62da3 (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/collaboration/room/json:notebook:9bc89a74-323a-411f-96b4-bf47260a909f?sessionId=76415e06-5e42-460d-9356-402da6f62da3', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1769, in _execute
        result = await result  # type: ignore
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_collaboration/handlers.py", line 105, in prepare
        await self._websocket_server.start_room(self.room)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/pycrdt_websocket/websocket_server.py", line 88, in start_room
        await self._task_group.start(room.start)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 800, in start
        task = self._spawn(func, args, name, future)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 752, in _spawn
        raise RuntimeError(
    RuntimeError: This task group is not active; no new tasks can be started.
[E 2024-02-26 11:40:02.077 ServerApp] Uncaught exception in write_error
    Traceback (most recent call last):
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1769, in _execute
        result = await result  # type: ignore
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_collaboration/handlers.py", line 105, in prepare
        await self._websocket_server.start_room(self.room)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/pycrdt_websocket/websocket_server.py", line 88, in start_room
        await self._task_group.start(room.start)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 800, in start
        task = self._spawn(func, args, name, future)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 752, in _spawn
        raise RuntimeError(
    RuntimeError: This task group is not active; no new tasks can be started.
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1298, in send_error
        self.write_error(status_code, **kwargs)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 718, in write_error
        html = self.render_template("%s.html" % status_code, **ns)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 644, in render_template
        ns.update(self.template_namespace)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 654, in template_namespace
        logged_in=self.logged_in,
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 196, in logged_in
        user = self.current_user
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1424, in current_user
        self._current_user = self.get_current_user()
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 175, in get_current_user
        raise RuntimeError(msg)
    RuntimeError: Calling `YDocWebSocketHandler.get_current_user()` directly is deprecated in jupyter-server 2.0. Use `self.current_user` instead (works in all versions).
[E 2024-02-26 11:40:02.077 ServerApp] {
      "Host": "localhost:8888",
      "Accept": "*/*",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15"
    }
[E 2024-02-26 11:40:02.077 ServerApp] 500 GET /api/collaboration/room/json:notebook:9bc89a74-323a-411f-96b4-bf47260a909f?sessionId=76415e06-5e42-460d-9356-402da6f62da3 (@127.0.0.1) 2.57ms referer=None
[I 2024-02-26 11:40:02.116 YDocExtension] Processed 18 Y patches in one minute
[I 2024-02-26 11:40:02.116 YDocExtension] Connected Y users: 2
[E 2024-02-26 11:40:02.570 ServerApp] Uncaught exception GET /api/collaboration/room/json:notebook:9bc89a74-323a-411f-96b4-bf47260a909f?sessionId=76415e06-5e42-460d-9356-402da6f62da3 (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/collaboration/room/json:notebook:9bc89a74-323a-411f-96b4-bf47260a909f?sessionId=76415e06-5e42-460d-9356-402da6f62da3', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1769, in _execute
        result = await result  # type: ignore
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_collaboration/handlers.py", line 105, in prepare
        await self._websocket_server.start_room(self.room)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/pycrdt_websocket/websocket_server.py", line 88, in start_room
        await self._task_group.start(room.start)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 800, in start
        task = self._spawn(func, args, name, future)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 752, in _spawn
        raise RuntimeError(
    RuntimeError: This task group is not active; no new tasks can be started.
[E 2024-02-26 11:40:02.571 ServerApp] Uncaught exception in write_error
    Traceback (most recent call last):
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1769, in _execute
        result = await result  # type: ignore
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_collaboration/handlers.py", line 105, in prepare
        await self._websocket_server.start_room(self.room)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/pycrdt_websocket/websocket_server.py", line 88, in start_room
        await self._task_group.start(room.start)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 800, in start
        task = self._spawn(func, args, name, future)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 752, in _spawn
        raise RuntimeError(
    RuntimeError: This task group is not active; no new tasks can be started.
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1298, in send_error
        self.write_error(status_code, **kwargs)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 718, in write_error
        html = self.render_template("%s.html" % status_code, **ns)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 644, in render_template
        ns.update(self.template_namespace)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 654, in template_namespace
        logged_in=self.logged_in,
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 196, in logged_in
        user = self.current_user
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1424, in current_user
        self._current_user = self.get_current_user()
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 175, in get_current_user
        raise RuntimeError(msg)
    RuntimeError: Calling `YDocWebSocketHandler.get_current_user()` directly is deprecated in jupyter-server 2.0. Use `self.current_user` instead (works in all versions).
[E 2024-02-26 11:40:02.572 ServerApp] {
      "Host": "localhost:8888",
      "Accept": "*/*",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15"
    }
[E 2024-02-26 11:40:02.572 ServerApp] 500 GET /api/collaboration/room/json:notebook:9bc89a74-323a-411f-96b4-bf47260a909f?sessionId=76415e06-5e42-460d-9356-402da6f62da3 (@127.0.0.1) 2.35ms referer=None
[I 2024-02-26 11:40:02.794 ServerApp] Out-of-band changes. Overwriting the content in room json:notebook:9bc89a74-323a-411f-96b4-bf47260a909f
[E 2024-02-26 11:40:03.411 ServerApp] Uncaught exception GET /api/collaboration/room/json:notebook:9bc89a74-323a-411f-96b4-bf47260a909f?sessionId=76415e06-5e42-460d-9356-402da6f62da3 (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/collaboration/room/json:notebook:9bc89a74-323a-411f-96b4-bf47260a909f?sessionId=76415e06-5e42-460d-9356-402da6f62da3', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1769, in _execute
        result = await result  # type: ignore
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_collaboration/handlers.py", line 105, in prepare
        await self._websocket_server.start_room(self.room)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/pycrdt_websocket/websocket_server.py", line 88, in start_room
        await self._task_group.start(room.start)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 800, in start
        task = self._spawn(func, args, name, future)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 752, in _spawn
        raise RuntimeError(
    RuntimeError: This task group is not active; no new tasks can be started.
[E 2024-02-26 11:40:03.412 ServerApp] Uncaught exception in write_error
    Traceback (most recent call last):
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1769, in _execute
        result = await result  # type: ignore
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_collaboration/handlers.py", line 105, in prepare
        await self._websocket_server.start_room(self.room)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/pycrdt_websocket/websocket_server.py", line 88, in start_room
        await self._task_group.start(room.start)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 800, in start
        task = self._spawn(func, args, name, future)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 752, in _spawn
        raise RuntimeError(
    RuntimeError: This task group is not active; no new tasks can be started.
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1298, in send_error
        self.write_error(status_code, **kwargs)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 718, in write_error
        html = self.render_template("%s.html" % status_code, **ns)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 644, in render_template
        ns.update(self.template_namespace)
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 654, in template_namespace
        logged_in=self.logged_in,
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 196, in logged_in
        user = self.current_user
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/tornado/web.py", line 1424, in current_user
        self._current_user = self.get_current_user()
      File "/Users/jialinzhang/miniconda3/envs/jlab4-fresh/lib/python3.10/site-packages/jupyter_server/base/handlers.py", line 175, in get_current_user
        raise RuntimeError(msg)
    RuntimeError: Calling `YDocWebSocketHandler.get_current_user()` directly is deprecated in jupyter-server 2.0. Use `self.current_user` instead (works in all versions).
[E 2024-02-26 11:40:03.413 ServerApp] {
      "Host": "localhost:8888",
      "Accept": "*/*",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.1 Safari/605.1.15"
    }
[E 2024-02-26 11:40:03.413 ServerApp] 500 GET /api/collaboration/room/json:notebook:9bc89a74-323a-411f-96b4-bf47260a909f?sessionId=76415e06-5e42-460d-9356-402da6f62da3 (@127.0.0.1) 2.80ms referer=None

Expected behavior

Dialog should not be popped up when one user is accessing.

Context

Suspects

FileLoaderMapper dict is not thread safe. When there are concurrent calls to create file loader, two file loaders could be created and one of the file loader will be referenced from dict in FileLoaderMapper. Both file loaders could have watcher tasks running and for file loader which is not saved in dict, the last_modified field is incorrect and it will report out-of-band changes all the time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions