Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(recordings): don't DLQ on PostgreSQL errors #14438

Merged
merged 1 commit into from
Feb 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,24 +160,24 @@ export const eachBatch =

let team: Team | null = null

try {
if (messagePayload.team_id != null) {
team = await teamManager.fetchTeam(messagePayload.team_id)
} else if (messagePayload.token) {
team = await teamManager.getTeamByToken(messagePayload.token)
}
if (messagePayload.team_id != null) {
team = await teamManager.fetchTeam(messagePayload.team_id)
} else if (messagePayload.token) {
team = await teamManager.getTeamByToken(messagePayload.token)
}

if (team == null) {
status.warn('⚠️', 'invalid_message', {
reason: 'team_not_found',
partition: batch.partition,
offset: message.offset,
})
await producer.queueMessage({ topic: KAFKA_SESSION_RECORDING_EVENTS_DLQ, messages: [message] })
continue
}
if (team == null) {
status.warn('⚠️', 'invalid_message', {
reason: 'team_not_found',
partition: batch.partition,
offset: message.offset,
})
await producer.queueMessage({ topic: KAFKA_SESSION_RECORDING_EVENTS_DLQ, messages: [message] })
continue
}

if (team.session_recording_opt_in) {
if (team.session_recording_opt_in) {
try {
if (event.event === '$snapshot') {
await createSessionRecordingEvent(
messagePayload.uuid,
Expand All @@ -199,31 +199,31 @@ export const eachBatch =
producer
)
}
}
} catch (error) {
status.error('⚠️', 'processing_error', {
eventId: event.uuid,
error: error,
})
} catch (error) {
status.error('⚠️', 'processing_error', {
eventId: event.uuid,
error: error,
})

if (error instanceof DependencyUnavailableError) {
// If it's an error that is transient, we want to
// initiate the KafkaJS retry logic, which kicks in when
// we throw.
throw error
}
if (error instanceof DependencyUnavailableError) {
// If it's an error that is transient, we want to
// initiate the KafkaJS retry logic, which kicks in when
// we throw.
throw error
}

// On non-retriable errors, e.g. perhaps the produced message
// was too large, push the original message to the DLQ. This
// message should be as the original so we _should_ be able to
// produce it successfully.
// TODO: it is not guaranteed that only this message is the one
// that failed to be produced. We will already be in the
// situation with the existing implementation so I will leave as
// is for now. An improvement would be to keep track of the
// messages that we failed to produce and send them all to the
// DLQ.
await producer.queueMessage({ topic: KAFKA_SESSION_RECORDING_EVENTS_DLQ, messages: [message] })
// On non-retriable errors, e.g. perhaps the produced message
// was too large, push the original message to the DLQ. This
// message should be as the original so we _should_ be able to
// produce it successfully.
// TODO: it is not guaranteed that only this message is the one
// that failed to be produced. We will already be in the
// situation with the existing implementation so I will leave as
// is for now. An improvement would be to keep track of the
// messages that we failed to produce and send them all to the
// DLQ.
await producer.queueMessage({ topic: KAFKA_SESSION_RECORDING_EVENTS_DLQ, messages: [message] })
}
}

// After processing each message, we need to heartbeat to ensure
Expand Down