FHIR Chat · 5.1 Validation Detected circular dependency - StackOverflow · hapi

Stream: hapi

Topic: 5.1 Validation Detected circular dependency - StackOverflow


view this post on Zulip Kevin Mayfield (Aug 14 2020 at 10:04):

Just updated to 5.1 and getting this error.

Caused by: java.lang.StackOverflowError

I'm investigating at the moment but seems to get stuck on UK Profiles. Extract from the loop

2020-08-14 10:51:55.124 WARN 25744 --- [o-auto-1-exec-7] .v.s.SnapshotGeneratingValidationSupport : Detected circular dependency, already generating snapshot for: https://fhir.nhs.uk/R4/StructureDefinition/UKCore-CarePlan
2020-08-14 10:51:55.133 INFO 25744 --- [o-auto-1-exec-7] .v.v.VersionSpecificWorkerContextWrapper : Generating snapshot for StructureDefinition: https://fhir.nhs.uk/R4/StructureDefinition/UKCore-ServiceRequest
2020-08-14 10:51:55.137 INFO 25744 --- [o-auto-1-exec-7] .v.v.VersionSpecificWorkerContextWrapper : Generating snapshot for StructureDefinition: https://fhir.nhs.uk/R4/StructureDefinition/UKCore-ServiceRequest
2020-08-14 10:51:55.137 WARN 25744 --- [o-auto-1-exec-7] .v.s.SnapshotGeneratingValidationSupport : Detected circular dependency, already generating snapshot for: https://fhir.nhs.uk/R4/StructureDefinition/UKCore-ServiceRequest
2020-08-14 10:51:55.138 INFO 25744 --- [o-auto-1-exec-7] .v.v.VersionSpecificWorkerContextWrapper : Generating snapshot for StructureDefinition: https://fhir.nhs.uk/R4/StructureDefinition/UKCore-CarePlan
2020-08-14 10:51:55.141 INFO 25744 --- [o-auto-1-exec-7] .v.v.VersionSpecificWorkerContextWrapper : Generating snapshot for StructureDefinition: https://fhir.nhs.uk/R4/StructureDefinition/UKCore-CarePlan

Is this known about?

view this post on Zulip Kevin Mayfield (Aug 14 2020 at 14:47):

Seems to be a bug around.

SnapshotGeneratingValidationSupport

UK-CarePlan mentions UK-ServiceRequest twice.
Similarly UK-Service mentions UK-CarePlan twice.

So what I believe happens.

Line 10: generateSnapshot is called on UK-CarePlan,
this calls generateSnapeshot on UK-ServiceRequest
which then calls generateSnapshot on UK-CarePlan, this is stopped because it is already doing UK-CarePlan
but it removes the semaphore on this line
https://github.com/jamesagnew/hapi-fhir/blob/6a8e09addf30ed03c84263faff35a7ad4fe23517/hapi-fhir-validation/src/main/java/org/hl7/fhir/common/hapi/validation/support/SnapshotGeneratingValidationSupport.java#L137
so when it is called again for the second mention of UK-CarePlan it tries to genearate the snapShot and GOTO 10

@Grahame Grieve @James Agnew ?? Does this sound correct?? Thanks

view this post on Zulip James Agnew (Aug 14 2020 at 15:10):

What does "mentions" mean in this context?

I thought the snapshot generator would only recurse into the base definition (though I could be wrong), which would mean that these two profiles have each other as the base?

view this post on Zulip Kevin Mayfield (Aug 17 2020 at 08:30):

I mean the derived profile has a constraint on a reference which goes to another derived profile.

image.png

view this post on Zulip Kevin Mayfield (Aug 17 2020 at 08:32):

It looks like I can get it working by stopping the semaphore removal https://github.com/NHSDigital/fhir-validation-service/blob/master/src/main/java/uk/mayfieldis/hapifhir/support/SnapshotGeneratingValidationSupport.java#L113

view this post on Zulip Kevin Mayfield (Aug 17 2020 at 08:32):

Still investigating though.

view this post on Zulip Kevin Mayfield (Aug 17 2020 at 08:49):

Ignore solution, now gets into a loop.

view this post on Zulip James Agnew (Aug 17 2020 at 12:45):

I'm not a profiling expert by any means so there may be something basic I'm missing.. but it feels pretty fraught with peril to have 2 profiles depending on each other like that.

view this post on Zulip Patrick Werner (Aug 17 2020 at 14:53):

it is still not 100% clear how the profiles are depending on each other, but if i am right these profiles aren't deriving from each other, but referencing each other via targetProfile

view this post on Zulip Patrick Werner (Aug 17 2020 at 14:56):

The SnapshotGenerator starts snapshotting the first profile, finding the targetResourcereferenced second profile, starting the snapshot generation on the 2nd one, which includes the first profile via targetProfilewhich sending the process into a loop.

view this post on Zulip Grahame Grieve (Aug 17 2020 at 19:15):

Does this happen with the standalone validator?

view this post on Zulip Kevin Mayfield (Aug 18 2020 at 07:23):

@Grahame Grieve no, tested with fresh standalone with no problems.

@Patrick Werner my wording was slightly misleading. The circular targetProfiles are base UK profiles (the project I'm working on uses derivations of these, these are seem to be fine).
So I believe it's legitimate that Profile A has sibling profile B as targets and B has A as targets.

view this post on Zulip Kevin Mayfield (Sep 01 2020 at 12:46):

Update: Still get the issue but have worked around it by using (base) profiles which include snapshots.
The derived profiles (no snapshot) then work correctly.


Last updated: Apr 12 2022 at 19:14 UTC