Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:

jobs:
restart-dev-and-test-with-custom-base-port:
runs-on: ubicloud-standard-8
runs-on: ubicloud-standard-16
env:
NEXT_PUBLIC_STACK_PORT_PREFIX: "69"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/restart-dev-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:

jobs:
restart-dev-and-test:
runs-on: ubicloud-standard-8
runs-on: ubicloud-standard-16

steps:
- uses: actions/checkout@v6
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/setup-tests-with-custom-base-port.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:

jobs:
setup-tests-with-custom-base-port:
runs-on: ubicloud-standard-8
runs-on: ubicloud-standard-16
env:
NEXT_PUBLIC_STACK_PORT_PREFIX: "69"

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/setup-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:

jobs:
setup-tests:
runs-on: ubicloud-standard-8
runs-on: ubicloud-standard-16
steps:
- uses: actions/checkout@v6

Expand Down
62 changes: 38 additions & 24 deletions apps/backend/src/lib/clickhouse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,30 +48,44 @@ export const getQueryTimingStats = async (client: ClickHouseClient, queryId: str
password: clickhouseAdminPassword,
},
});
const profile = await client.query({
query: `
SELECT
ProfileEvents['CPUTimeMicroseconds'] / 1000 AS cpu_time_ms,
ProfileEvents['RealTimeMicroseconds'] / 1000 AS wall_clock_time_ms
FROM system.query_log
WHERE query_id = {query_id:String} AND type = 'QueryFinish'
ORDER BY event_time DESC
LIMIT 1
`,
query_params: { query_id: queryId },
auth: {
username: clickhouseAdminUser,
password: clickhouseAdminPassword,
},
format: "JSON",
});
const queryProfile = async () => {
const profile = await client.query({
query: `
SELECT
Comment thread
BilalG1 marked this conversation as resolved.
ProfileEvents['CPUTimeMicroseconds'] / 1000 AS cpu_time_ms,
ProfileEvents['RealTimeMicroseconds'] / 1000 AS wall_clock_time_ms
FROM system.query_log
WHERE query_id = {query_id:String} AND type = 'QueryFinish'
ORDER BY event_time DESC
LIMIT 1
`,
query_params: { query_id: queryId },
auth: {
username: clickhouseAdminUser,
password: clickhouseAdminPassword,
},
format: "JSON",
Comment thread
BilalG1 marked this conversation as resolved.
});

return await profile.json<{
cpu_time_ms: number,
wall_clock_time_ms: number,
}>();
};

const stats = await profile.json<{
cpu_time_ms: number,
wall_clock_time_ms: number,
}>();
if (stats.data.length !== 1) {
throw new StackAssertionError(`Unexpected number of query log results: ${stats.data.length}`, { data: stats.data });
const retryDelaysMs = [75, 150, 300, 600, 1200];
for (let attempt = 0; attempt <= retryDelaysMs.length; attempt += 1) {
const stats = await queryProfile();
if (stats.data.length === 1) {
return stats.data[0];
}
if (stats.data.length > 1) {
throw new StackAssertionError(`Unexpected number of query log results: ${stats.data.length}`, { data: stats.data });
}
if (attempt < retryDelaysMs.length) {
await new Promise((resolve) => setTimeout(resolve, retryDelaysMs[attempt]));
}
}
return stats.data[0];

throw new StackAssertionError("Unexpected number of query log results: 0", { data: [] });
};