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

Fixed upsert logic for Log__c so it doesn't assume that there is only 1 transaction ID involved #118

Merged
merged 4 commits into from
Mar 24, 2021

Conversation

jongpie
Copy link
Owner

@jongpie jongpie commented Mar 24, 2021

It's hard to reproduce the scenario consistently, but it seems like in practice, 1 transaction of AFTER_INSERT on LogEntryEvent__e can sometimes have records with different transaction IDs. This seems to happen with some logging in batch jobs, but the existing code has an incorrect assumption that all of the LogEntryEvent__e records are tied to the same transaction ID.

I've updated the logic in LogEntryEventHandler to upsert a List<Log__c> (1 record per transaction ID) instead of just a single Log__c record.

… 1 transaction ID involved

It's hard to reproduce the scenario consistently, but it seems like in practice, 1 transaction of AFTER_INSERT on LogEntryEvent__e can sometimes have records with different transaction IDs. This seems to happen with some logging in batch jobs, so better to bulkify the upsert
@jongpie jongpie temporarily deployed to Test March 24, 2021 05:00 Inactive
@jongpie jongpie added the Type: Bug Something isn't working label Mar 24, 2021
@jongpie jongpie added this to the Version 4.3.0 milestone Mar 24, 2021
Since all branches currently run on push, the PR push causes duplicate validations
@jongpie jongpie temporarily deployed to Test March 24, 2021 05:06 Inactive
TRANSACTION_ID_TO_LOG holds all logs that have been upserted in the current transaction, logsToUpsert holds just the logs that need to be upserted
@jongpie jongpie temporarily deployed to Test March 24, 2021 05:16 Inactive
@jongpie jongpie temporarily deployed to Test March 24, 2021 05:32 Inactive
@jongpie jongpie merged commit b41fdf6 into master Mar 24, 2021
@jongpie jongpie deleted the bugfix/fixed-log-upsert-logic branch March 24, 2021 06:01
@jongpie jongpie added Layer: Log Management Items related to the custom objects & Logger Console app Salesforce Feature: Platform Events Items related to how platform events are leveraged by Nebula Logger labels May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Layer: Log Management Items related to the custom objects & Logger Console app Salesforce Feature: Platform Events Items related to how platform events are leveraged by Nebula Logger Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant