Skip to content

Commit

Permalink
Merge branch 'release_24.1' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdbeek committed Nov 6, 2024
2 parents e5635dc + 6004c81 commit ec6831e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 18 deletions.
33 changes: 25 additions & 8 deletions client/src/components/JobInformation/JobInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { JobDetailsProvider } from "components/providers/JobProvider";
import UtcDate from "components/UtcDate";
import { NON_TERMINAL_STATES } from "components/WorkflowInvocationState/util";
import { formatDuration, intervalToDuration } from "date-fns";
import { computed, ref } from "vue";
import { computed, ref, watch } from "vue";
import { GalaxyApi } from "@/api";
import { rethrowSimple } from "@/utils/simple-error";
Expand All @@ -14,7 +14,7 @@ import DecodedId from "../DecodedId.vue";
import CodeRow from "./CodeRow.vue";
const job = ref(null);
const invocationId = ref(null);
const invocationId = ref(undefined);
const props = defineProps({
job_id: {
Expand Down Expand Up @@ -42,9 +42,6 @@ const metadataDetail = ref({
function updateJob(newJob) {
job.value = newJob;
if (newJob) {
fetchInvocation(newJob.id);
}
}
function filterMetadata(jobMessages) {
Expand All @@ -58,9 +55,9 @@ function filterMetadata(jobMessages) {
});
}
async function fetchInvocation(jobId) {
async function fetchInvocationForJob(jobId) {
if (jobId) {
const { data: invocation, error } = await GalaxyApi().GET("/api/invocations", {
const { data: invocations, error } = await GalaxyApi().GET("/api/invocations", {
params: {
query: { job_id: jobId },
},
Expand All @@ -70,9 +67,29 @@ async function fetchInvocation(jobId) {
rethrowSimple(error);
}
invocationId.value = invocation.id;
if (invocations.length) {
return invocations[0];
}
return null;
}
}
// Fetches the invocation for the given job id to get the associated invocation id
watch(
() => props.job_id,
async (newId, oldId) => {
if (newId && (invocationId.value === undefined || newId !== oldId)) {
const invocation = await fetchInvocationForJob({ jobId: newId });
if (invocation) {
invocationId.value = invocation.id;
} else {
invocationId.value = null;
}
}
},
{ immediate: true }
);
</script>

<template>
Expand Down
28 changes: 18 additions & 10 deletions lib/galaxy/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@
update,
VARCHAR,
)
from sqlalchemy.exc import OperationalError
from sqlalchemy.exc import (
CompileError,
OperationalError,
)
from sqlalchemy.ext import hybrid
from sqlalchemy.ext.associationproxy import (
association_proxy,
Expand Down Expand Up @@ -3308,16 +3311,21 @@ def _next_hid(self, n=1):
table = self.__table__
history_id = cached_id(self)
update_stmt = update(table).where(table.c.id == history_id).values(hid_counter=table.c.hid_counter + n)
update_returning_stmnt = update_stmt.returning(table.c.hid_counter)

with engine.begin() as conn:
if engine.name in ["postgres", "postgresql"]:
stmt = update_stmt.returning(table.c.hid_counter)
updated_hid = conn.execute(stmt).scalar()
hid = updated_hid - n
else:
select_stmt = select(table.c.hid_counter).where(table.c.id == history_id).with_for_update()
hid = conn.execute(select_stmt).scalar()
conn.execute(update_stmt)
if engine.name != "sqlite":
with engine.begin() as conn:
hid = conn.execute(update_returning_stmnt).scalar() - n
else:
try:
hid = session.execute(update_returning_stmnt).scalar() - n
except (CompileError, OperationalError):
# The RETURNING clause was added to SQLite in version 3.35.0.
# Not using FOR UPDATE either, since that was added in 3.45.0,
# and anyway does a whole-table lock
select_stmt = select(table.c.hid_counter).where(table.c.id == history_id)
hid = session.execute(select_stmt).scalar()
session.execute(update_stmt)

session.expire(self, ["hid_counter"])
return hid
Expand Down

0 comments on commit ec6831e

Please sign in to comment.