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

LogHandler not linking child logs correctly #585

Closed
ctcforce opened this issue Dec 1, 2023 · 2 comments · Fixed by #605
Closed

LogHandler not linking child logs correctly #585

ctcforce opened this issue Dec 1, 2023 · 2 comments · Fixed by #605
Assignees
Labels
Layer: Log Management Items related to the custom objects & Logger Console app Type: Bug Something isn't working

Comments

@ctcforce
Copy link

ctcforce commented Dec 1, 2023

Package Edition of Nebula Logger

Managed Package

Package Version of Nebula Logger

4.11

New Bug Summary

I'm experimenting with linking together logs with Nebula Logger, so I ran the BatchableLoggerExample example from the github readme.

I noticed that the manner of relating child logs has varying behavior.

Log-4 is the parent log and you can see it only shows one of the child logs, Log-6 in related

Log-5 has a string literal in it's parent log field

whereas Log-6 has a lookup in it's parent log field

Is this varying behavior between the child logs a bug or am I misunderstanding something about how this feature works?
log6
log5
log4

@ctcforce ctcforce added the Type: Bug Something isn't working label Dec 1, 2023
@jongpie
Copy link
Owner

jongpie commented Jan 20, 2024

Hey @ctcforce - I think this is definitely an issue with Nebula Logger (not anything you're doing). The problem seems to be due to the timing of how quickly parts of the batchable job finish, combined with how Salesforce handles publishing platform events (LogEntryEvent__e in particular). The result is what you're seeing, where sometimes the parent Log__c record hasn't been created yet when some of the child Log__c records are saved, resulting in the link missing. I have a few ideas on how to improve this to try to ensure that all of the child records are properly linked - I'll try to work on this in the next month or so.

@jongpie jongpie added the Feature: Log Retention Items related to LogBatchPurger or LogBatchPurgeScheduler label Jan 20, 2024
jongpie added a commit that referenced this issue Jan 20, 2024
jongpie added a commit that referenced this issue Jan 21, 2024
@jongpie jongpie removed the Feature: Log Retention Items related to LogBatchPurger or LogBatchPurgeScheduler label Jan 21, 2024
@jongpie jongpie self-assigned this Jan 21, 2024
@jongpie jongpie changed the title BatchableLoggerExample not linking child logs correctly LogHandler not linking child logs correctly Jan 21, 2024
@jongpie jongpie added the Layer: Log Management Items related to the custom objects & Logger Console app label Jan 21, 2024
@jongpie
Copy link
Owner

jongpie commented Jan 21, 2024

@ctcforce I've just released a bugfix for this in v4.12.4 (PR #605) 🥳 The fix ended up being simpler than I thought it would be, and it should handle 2 previously-unhandled scenarios that would have resulted in ParentLog__c being null:

  • The parent and child Log__c are created in the same transaction - this can sometimes happen due to how platform events are published.
  • The parent Log__c is created after the child Log__c record - I'm not sure if this scenario would actually happen, but if it does, it should be handled now.

One note - this will not fix any existing data in your org. I've included an anonymous Apex script in the release notes that you can use in your org to fix existing data (if you want to fix it).

Whenever you have a chance to test this out, please let me know if you run into any more issues!

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 Type: Bug Something isn't working
Projects
None yet
2 participants