Skip to content

Commit 8682cf6

Browse files
authored
Tinybird performance and quarantined rows improvements, backfill performance updates (#2942)
1 parent b986732 commit 8682cf6

File tree

44 files changed

+1093
-904
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1093
-904
lines changed

backend/src/database/migrations/U1742295164__addIndexesForSequinBackfills.sql

Whitespace-only changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
create index if not exists "ix_activityRelations_updatedAt_activityId" on public."activityRelations" ("updatedAt", "activityId");
2+
create index if not exists "ix_members_updatedAt_id" on public.members ("updatedAt", id);
3+
create index if not exists "ix_organizations_updatedAt_id" on public.organizations ("updatedAt", id);

scripts/cli

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,14 @@ function post_up_scaffold() {
727727
}
728728

729729
function down_scaffold() {
730-
$_DC --compatibility -p $PROJECT_NAME -f $CLI_HOME/scaffold.yaml down
730+
local profile=''
731+
if [[ -n "${WITH_NGINX}" ]]; then
732+
profile='--profile nginx'
733+
elif [[ -n "${WITH_INSIGHTS}" ]]; then
734+
profile='--profile insights'
735+
fi
736+
737+
$_DC --compatibility -p $PROJECT_NAME -f $CLI_HOME/scaffold.yaml ${profile} down
731738
}
732739

733740
function scaffold_destroy() {
@@ -790,8 +797,15 @@ function service_start() {
790797
}
791798

792799
function scaffold_destroy_confirmed() {
800+
local profile=''
801+
if [[ -n "${WITH_NGINX}" ]]; then
802+
profile='--profile nginx'
803+
elif [[ -n "${WITH_INSIGHTS}" ]]; then
804+
profile='--profile insights'
805+
fi
806+
793807
kill_all_containers
794-
$_DC --compatibility -p $PROJECT_NAME -f $CLI_HOME/scaffold.yaml down
808+
$_DC --compatibility -p $PROJECT_NAME -f $CLI_HOME/scaffold.yaml ${profile} down
795809

796810
# needed because if there are no volumes this might cause the script to exit
797811
set +eo pipefail

services/apps/script_executor_worker/src/activities/copy-activities-from-questdb-to-tinybird/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ export async function sendActivitiesToTinybird(activitiesRedisKey: string): Prom
7575
console.log(`Data sent to tinybird -> ${JSON.stringify(response)}`)
7676
} catch (err) {
7777
if (axios.isAxiosError(err)) {
78-
this.log.warn(
78+
svc.log.warn(
7979
`Axios error occurred while sending activities to tinybird. ${err.response?.status} - ${err.response?.statusText}`,
8080
)
8181
throw new Error(`Sending data to tinybird failed with status: ${err.response?.status}`)
8282
} else {
83-
this.log.error(`Unexpected error while sending data to tinybird: ${err}`)
83+
svc.log.error(`Unexpected error while sending data to tinybird: ${err}`)
8484
throw new Error('An unexpected error occurred')
8585
}
8686
}

services/apps/script_executor_worker/src/schedules/scheduleCopyActivitiesFromQuestdbToTinybird.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,9 @@ export const scheduleCopyActivitiesFromQuestdbToTinybird = async () => {
2525
},
2626
args: [
2727
{
28-
batchSizePerRun: 50000,
28+
batchSizePerRun: 5000,
2929
deleteIndexedEntities: false,
30-
segmentIds: [
31-
'7b7bf9ce-6051-4c97-85eb-35c790203a0c',
32-
'f809d51c-68fa-401a-8aea-eb67989285c1',
33-
'e2fa0373-7379-416f-a651-70b1fc1b89b9',
34-
'e2c3321f-0d85-4a16-b603-66fd9f882a06',
35-
'2cd61b6e-de33-4a51-bb17-fbe33cc0ac0c',
36-
],
30+
segmentIds: process.env['CROWD_COPY_ACTIVITIES_TO_TINYBIRD_SEGMENT_IDS'].split(','),
3731
},
3832
],
3933
},

services/apps/script_executor_worker/src/workflows/copyActivitiesFromQuestdbToTinybird.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,6 @@ export async function copyActivitiesFromQuestdbToTinybird(
4848
await continueAsNew<typeof copyActivitiesFromQuestdbToTinybird>({
4949
batchSizePerRun: args.batchSizePerRun,
5050
latestSyncedActivityTimestamp: lastTimestamp,
51+
segmentIds: args.segmentIds,
5152
})
5253
}

services/libs/tinybird/datasources/activities.datasource

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ SCHEMA >
1616
`channel` String `json:$.channel` DEFAULT '',
1717
`url` String `json:$.url` DEFAULT '',
1818
`sentimentLabel` String `json:$.sentimentLabel` DEFAULT '',
19-
`sentimentScore` Int8 `json:$.sentimentScore` DEFAULT -1,
20-
`sentimentScoreMixed` Int8 `json:$.sentimentScoreMixed` DEFAULT -1,
21-
`sentimentScoreNeutral` Int8 `json:$.sentimentScoreNeutral` DEFAULT -1,
22-
`sentimentScoreNegative` Int8 `json:$.sentimentScoreNegative` DEFAULT -1,
23-
`sentimentScorePositive` Int8 `json:$.sentimentScorePositive` DEFAULT -1,
19+
`sentimentScore` Float32 `json:$.sentimentScore` DEFAULT -1,
20+
`sentimentScoreMixed` Float32 `json:$.sentimentScoreMixed` DEFAULT -1,
21+
`sentimentScoreNeutral` Float32 `json:$.sentimentScoreNeutral` DEFAULT -1,
22+
`sentimentScoreNegative` Float32 `json:$.sentimentScoreNegative` DEFAULT -1,
23+
`sentimentScorePositive` Float32 `json:$.sentimentScorePositive` DEFAULT -1,
2424
`gitIsMainBranch` UInt8 `json:$.gitIsMainBranch` DEFAULT 0,
2525
`gitIsIndirectFork` UInt8 `json:$.gitIsIndirectFork` DEFAULT 0,
2626
`gitLines` Int32 `json:$.gitLines` DEFAULT 0,
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
SCHEMA >
3+
`id` String,
4+
`type` LowCardinality(String),
5+
`timestamp` DateTime,
6+
`platform` LowCardinality(String),
7+
`isContribution` UInt8,
8+
`score` Int8,
9+
`sourceId` String,
10+
`createdAt` DateTime64(3),
11+
`updatedAt` DateTime64(3),
12+
`sourceParentId` String,
13+
`attributes` String,
14+
`title` String,
15+
`body` String,
16+
`channel` String,
17+
`url` String,
18+
`sentimentLabel` String,
19+
`sentimentScore` Float32,
20+
`sentimentScoreMixed` Float32,
21+
`sentimentScoreNeutral` Float32,
22+
`sentimentScoreNegative` Float32,
23+
`sentimentScorePositive` Float32,
24+
`gitIsMainBranch` UInt8,
25+
`gitIsIndirectFork` UInt8,
26+
`gitLines` Int32,
27+
`gitInsertions` Int32,
28+
`gitDeletions` Int32,
29+
`gitIsMerge` UInt8
30+
31+
ENGINE "MergeTree"
32+
ENGINE_PARTITION_KEY "toYear(timestamp)"
33+
ENGINE_SORTING_KEY "timestamp, channel, platform, type, isContribution"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
SCHEMA >
3+
`id` String,
4+
`timestamp` DateTime,
5+
`platform` LowCardinality(String),
6+
`type` LowCardinality(String),
7+
`channel` String,
8+
`isContribution` UInt8,
9+
`updatedAt` DateTime64(3),
10+
`memberId` String,
11+
`organizationId` String,
12+
`segmentId` String
13+
14+
ENGINE "MergeTree"
15+
ENGINE_PARTITION_KEY "toYear(timestamp)"
16+
ENGINE_SORTING_KEY "segmentId, timestamp, type, platform, memberId, organizationId"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
SCHEMA >
3+
`activityId` String,
4+
`conversationId` String,
5+
`createdAt` DateTime64(3),
6+
`updatedAt` DateTime64(3),
7+
`memberId` String,
8+
`objectMemberId` String,
9+
`objectMemberUsername` String,
10+
`organizationId` String,
11+
`parentId` String,
12+
`platform` LowCardinality(String),
13+
`segmentId` String,
14+
`username` String
15+
16+
ENGINE "MergeTree"
17+
ENGINE_PARTITION_KEY "toYear(createdAt)"
18+
ENGINE_SORTING_KEY "segmentId, memberId, organizationId, activityId"

0 commit comments

Comments
 (0)