Skip to content

chore: upload embedded dt response difference samples to s3 #5792

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

itsmihir
Copy link
Contributor

Description

Upload the embedded DT and rudder-transformation DT response difference log files to S3 instead of writing them to disk.

Linear Ticket

< PIPE-2047 >

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Copy link

codecov bot commented Apr 29, 2025

Codecov Report

Attention: Patch coverage is 47.36842% with 30 lines in your changes missing coverage. Please review.

Project coverage is 76.89%. Comparing base (fbc4abe) to head (083c853).

Files with missing lines Patch % Lines
...rnal/transformer/destination_transformer/logger.go 0.00% 19 Missing ⚠️
...destination_transformer/destination_transformer.go 72.22% 8 Missing and 2 partials ⚠️
processor/processor.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5792      +/-   ##
==========================================
- Coverage   76.90%   76.89%   -0.01%     
==========================================
  Files         491      491              
  Lines       67183    67206      +23     
==========================================
+ Hits        51667    51681      +14     
- Misses      12692    12703      +11     
+ Partials     2824     2822       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

embeddedResponse, legacyResponse types.Response,
) {
if c.samplingFileManager == nil { // Cannot upload, we should just report the issue with no diff
c.log.Errorn("DestinationTransformer sanity check failed")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we decrease this into a warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any specific reason for this? We are logging a similar entry as an error for UT mirroring here

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a suggestion, I think in hindsight we might end up having a huge amount of these and since they are not critical we might want an easy way to differentiate from the critical ones. In fact even the one I did for UT mirroring can be demoted to a warning.

c.log.Errorn("DestinationTransformer sanity check failed")
return
}

c.loggedEventsMu.Lock()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't hold a mutex for long operations. Uploads can take a while and in destination_transformer.go you're just firing go routines like go CompareAndLog(...) and then hold a mutex here. This is a bad practice in my opinion we can do better. Is this mutex just to protect c.loggedEvents?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's to make sure we don't exceed the maxLoggedEvents limit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove the mutex, are we okay with not considering maxLoggedEvents as a hard limit?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering the use case, we should be good if are close enough to maxLoggedEvents, doesn't have to be precise at 100%, right? So an atomic would do the job quite well: #5806

What do you think of that approach?

Copy link
Collaborator

@fracasula fracasula May 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gist of it is to find a way to avoid this scenario:

  1. DT is somehow broken, we process a lot of messages and each one of them is different, ergo we end up with tons of diffs to upload
  2. uploads take a very long time
  3. we fire a lot of go routines continuously like go c.CompareAndLog(...) but none of them can take the lock (because of the slow upload) but we keep processing thus we keep firing go routines without control

I think the above might lead to memory issues and slow GC. At some point even in Golang there is a limit on how many go routines is too many go routines 😅

So we either use an atomic and end up logging a bit more or you come up with some other way to avoid the uncontrolled creation of go routines waiting on locks that might be locked for long periods. I'm sure there are different ways of doing this, just pointing out the potential problem but we don't have to use atomics, it was just an idea.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed to the mentioned problems. Why can't we just do a leaky logger approach?

Copy link
Contributor Author

@itsmihir itsmihir May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can't we just do a leaky logger approach?

Are you referring to a leaky upload, or do we not even compare the payload in the first place?

Copy link
Contributor Author

@itsmihir itsmihir May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ktgowtham I tried implementing a leaky logger, but using the main context to start the leaky logger added complexity. Initially, I tried using the context passed to Transform(), but I realised that a new context is created each time.
To fix this properly, we’d need to pass the main context down to transformer.NewClients, which would require significant changes. I’m not sure if that effort is justified at this point.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with minor suggestion around the atomic approach. Personally I think that would be enough, without needing the leaky logger.

#5792 (comment)

@itsmihir itsmihir requested a review from fracasula May 5, 2025 14:17
logger.NewStringField("location", file.Location),
logger.NewStringField("objectName", file.ObjectName),
)
c.loggedEvents.Add(int64(len(differingResponse)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably coming from my own branch but on a second look I think this should be updated so that we bump loggedEvents as soon as we know how many events we got. Basically something like this:

	differingResponse, sampleDiff := c.differingEvents(embeddedResponse, legacyResponse)
	if len(differingResponse) == 0 && sampleDiff == "" {
		return
	}

	c.loggedEvents.Add(int64(len(differingResponse)))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The most precise I can think of is this: https://github.com/rudderlabs/rudder-server/pull/5816/files
Not overly complicated, also I don't think at this point we need a leaky logger either. The atomic approach seems safe and precise enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants