From 91f34ac76c200a2ef86ab63ece23a61ab50f1fdb Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:01:41 +0200 Subject: [PATCH 1/4] Reduce notifications polling frequency --- client/src/stores/notificationsStore.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/stores/notificationsStore.ts b/client/src/stores/notificationsStore.ts index 6a7837e67928..7ed09f21174a 100644 --- a/client/src/stores/notificationsStore.ts +++ b/client/src/stores/notificationsStore.ts @@ -12,8 +12,8 @@ import { mergeObjectListsById } from "@/utils/utils"; import { useBroadcastsStore } from "./broadcastsStore"; -const ACTIVE_POLLING_INTERVAL = 5000; -const INACTIVE_POLLING_INTERVAL = 30000; +const ACTIVE_POLLING_INTERVAL = 60000; // 1 minute +const INACTIVE_POLLING_INTERVAL = ACTIVE_POLLING_INTERVAL * 10; // 10 minutes export const useNotificationsStore = defineStore("notificationsStore", () => { const { startWatchingResource: startWatchingNotifications } = useResourceWatcher(getNotificationStatus, { From af2c2ed314265b8ff8c03bd1d202c45c74ec7b34 Mon Sep 17 00:00:00 2001 From: davelopez <46503462+davelopez@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:19:13 +0200 Subject: [PATCH 2/4] Set active check for notifications every 30 seconds --- client/src/stores/notificationsStore.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/src/stores/notificationsStore.ts b/client/src/stores/notificationsStore.ts index 7ed09f21174a..0396d48b256f 100644 --- a/client/src/stores/notificationsStore.ts +++ b/client/src/stores/notificationsStore.ts @@ -12,8 +12,8 @@ import { mergeObjectListsById } from "@/utils/utils"; import { useBroadcastsStore } from "./broadcastsStore"; -const ACTIVE_POLLING_INTERVAL = 60000; // 1 minute -const INACTIVE_POLLING_INTERVAL = ACTIVE_POLLING_INTERVAL * 10; // 10 minutes +const ACTIVE_POLLING_INTERVAL = 30000; // 30 seconds +const INACTIVE_POLLING_INTERVAL = ACTIVE_POLLING_INTERVAL * 20; // 10 minutes export const useNotificationsStore = defineStore("notificationsStore", () => { const { startWatchingResource: startWatchingNotifications } = useResourceWatcher(getNotificationStatus, { From 5ce49867520edf99a2d66d4876aac488e9acb167 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 17 Apr 2024 16:39:54 +0200 Subject: [PATCH 3/4] Avoid exception when opening apply rules tool and no collection in history Fixes https://sentry.galaxyproject.org/share/issue/97b5b9cfcef14ca0b59b851684170698/ ``` AttributeError: 'NoneType' object has no attribute 'id' File "galaxy/tools/__init__.py", line 2601, in populate_model tool_dict = input.to_dict(request_context, other_values=other_values) File "galaxy/tools/parameters/basic.py", line 2648, in to_dict "id": trans.app.security.encode_id(target.id), ``` Which is in a try/except anyway, so fairly inconsequential, but results in cleaner logs / one less sentry error. --- lib/galaxy/tools/parameters/basic.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/galaxy/tools/parameters/basic.py b/lib/galaxy/tools/parameters/basic.py index e24904731aec..62b29613d1fe 100644 --- a/lib/galaxy/tools/parameters/basic.py +++ b/lib/galaxy/tools/parameters/basic.py @@ -2646,8 +2646,7 @@ def __init__(self, tool, input_source, context=None): def to_dict(self, trans, other_values=None): other_values = other_values or {} d = ToolParameter.to_dict(self, trans) - if (target_name := self.data_ref) in other_values: - target = other_values[target_name] + if target := other_values.get(self.data_ref): if not is_runtime_value(target): d["target"] = { "src": "hdca" if hasattr(target, "collection") else "hda", From 37bc454067e3cdbbb3ce9c6de6bd0bd5309f8255 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Wed, 17 Apr 2024 19:18:21 +0200 Subject: [PATCH 4/4] Don't commit without having seta hid hid-less items in a history are bad, and this is potentially one way to produce them. We've got a bunch of them in the history and this has been showing up in as https://sentry.galaxyproject.org/share/issue/3cc69eedc9f841b6ae8ac02e3f88e8fe/: ``` ValidationError: 210 validation errors for HistoryContentsWithStatsResult contents.0.HDACustom.type Input should be 'file' [type=literal_error, input_value='collection', input_type=str] For further information visit https://errors.pydantic.dev/2.5/v/literal_error contents.0.HDACustom.history_content_type Input should be 'dataset' [type=literal_error, input_value='dataset_collection', input_type=str] For further information visit https://errors.pydantic.dev/2.5/v/literal_error contents.0.HDADetailed.hid Input should be a valid integer [type=int_type, input_value=None, input_type=NoneType] For further information visit https://errors.pydantic.dev/2.5/v/int_type contents.0.HDADetailed.type Input should be 'file' [type=literal_error, input_value='collection', input_type=str] For further information visit https://errors.pydantic.dev/2.5/v/literal_error contents.0.HDADetailed.history_content_type Input should be 'dataset' [type=literal_error, input_value='dataset_collection', input_type=str] For fur... File "starlette/applications.py", line 123, in __call__ await self.middleware_stack(scope, receive, send) File "starlette/middleware/errors.py", line 186, in __call__ raise exc File "starlette/middleware/errors.py", line 164, in __call__ await self.app(scope, receive, _send) File "starlette_context/middleware/raw_middleware.py", line 92, in __call__ await self.app(scope, receive, send_wrapper) File "starlette/middleware/base.py", line 189, in __call__ with collapse_excgroups(): File "contextlib.py", line 155, in __exit__ self.gen.throw(typ, value, traceback) File "starlette/_utils.py", line 93, in collapse_excgroups raise exc File "starlette/middleware/base.py", line 191, in __call__ response = await self.dispatch_func(request, call_next) File "galaxy/webapps/galaxy/fast_app.py", line 108, in add_x_frame_options response = await call_next(request) File "starlette/middleware/base.py", line 165, in call_next raise app_exc File "starlette/middleware/base.py", line 151, in coro await self.app(scope, receive_or_disconnect, send_no_error) File "starlette/middleware/exceptions.py", line 62, in __call__ await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send) File "starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "starlette/routing.py", line 758, in __call__ await self.middleware_stack(scope, receive, send) File "starlette/routing.py", line 778, in app await route.handle(scope, receive, send) File "starlette/routing.py", line 299, in handle await self.app(scope, receive, send) File "starlette/routing.py", line 79, in app await wrap_app_handling_exceptions(app, request)(scope, receive, send) File "starlette/_exception_handler.py", line 64, in wrapped_app raise exc File "starlette/_exception_handler.py", line 53, in wrapped_app await app(scope, receive, sender) File "starlette/routing.py", line 74, in app response = await func(request) File "fastapi/routing.py", line 278, in app raw_response = await run_endpoint_function( File "fastapi/routing.py", line 193, in run_endpoint_function return await run_in_threadpool(dependant.call, **values) File "starlette/concurrency.py", line 42, in run_in_threadpool return await anyio.to_thread.run_sync(func, *args) File "anyio/to_thread.py", line 56, in run_sync return await get_async_backend().run_sync_in_worker_thread( File "anyio/_backends/_asyncio.py", line 2144, in run_sync_in_worker_thread return await future File "anyio/_backends/_asyncio.py", line 851, in run result = context.run(func, *args) File "galaxy/webapps/galaxy/api/history_contents.py", line 465, in index items = self.service.index( File "galaxy/webapps/galaxy/services/history_contents.py", line 312, in index return self.__index_v2(trans, history_id, params, serialization_params, filter_query_params, accept) File "galaxy/webapps/galaxy/services/history_contents.py", line 1006, in __index_v2 return HistoryContentsWithStatsResult(contents=items, stats={"total_matches": total_matches}) ``` I'm hesitatant to relax the validation here, these are really pretty bad bugs. We do appear to have test coverage here via https://app.codecov.io/gh/galaxyproject/galaxy/commit/4a4ead2b5ee913b61a97b84b60e77f28415d5ad9/blob/lib/galaxy/tools/actions/upload_common.py#L144 --- lib/galaxy/tools/actions/upload_common.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/galaxy/tools/actions/upload_common.py b/lib/galaxy/tools/actions/upload_common.py index a5460c08efa0..b0fb794a409b 100644 --- a/lib/galaxy/tools/actions/upload_common.py +++ b/lib/galaxy/tools/actions/upload_common.py @@ -140,8 +140,6 @@ def __new_history_upload(trans, uploaded_dataset, history=None, state=None): hda.state = state else: hda.state = hda.states.QUEUED - with transaction(trans.sa_session): - trans.sa_session.commit() history.add_dataset(hda, genome_build=uploaded_dataset.dbkey, quota=False) permissions = trans.app.security_agent.history_get_default_permissions(history) trans.app.security_agent.set_all_dataset_permissions(hda.dataset, permissions, new=True, flush=False)