[Discovery] Error in CreateModuleDefinitionsForExtensions2 in Modules_Reload
Forge component by Francisco Menezes
Application Type

Good morning everyone,

I'm having a problem and I don't know how to solve it, the only thing I can say is that the same day that it stopped failing, we changed the URL of the environment so that it is called something else, I don't know if I should reinstall Discovery or I need to change something in the part of Discovery or if that has nothing to do with it.

Attached capture with the error to see if you can help me.

Thank you,

Best Regards,


Hi Julio,

Just throwing a few suggestions since I haven't seen this bug before:

- the error seems to be occurring in a timer under DiscoveryProbe module when running action SnapShot_Create;

- this is a database error due to foreign key constraints so more likely related to the previous data in your Discovery app than the change of URL environment you mentioned;

- this could be quickly resolved by deleting all snapshot data (if you don't mind losing previous data);

- worse case scenario you might need to troubleshoot/debug that query to understand what is causing that database constraint error;

- another thing you could try doing is to check if you have the latest version of Discovery installed (the current one available from Forge is 5.1.2 and mentions a list of bug fixes (including an error executing query taking a snapshot).

Hope the above helps, good luck!


Thank you very much for answering and giving me an idea.

Desistale the version you had, and install the version that you told me and now it works.

Thank you.

i removed all snapshots and saved the newest snapshot.  I then tried to import snapshot and its getting the same exact error.  5.1.2 seems to be very unstable for my company.

I am debugging discoveryprobe directly. The lowest module layer was zero. Probably need some checks if not null identifier before using the result of aggregate.  No results in ModuleLayer as the1st screenshot indicates. 

Hello Ewin,

Let me try to understand what's your use case:

1) You deleted all snapshots

2) Create a new snapshot successfully

3) Try to import an existing snapshot, but in what version, and why do you need to import? You already have a recent snapshot (by executing point nr. 2) 

Please let me know if all steps are correct and clarify the use case.

Best regards,


I just want discovery to work again.  

Discovery hasnt done a snapshot since end of July.  I deleted every existing snapshot to get Discovery back to a state where it could start over.  But deleting the snapshots did nothing to change the fact its throws the error discussed in this issue.  

I downloaded the last snapshot just to recover prior state of data until discovery is working again. 

I want #2 to succeed by itself with the current configurations in discovery.  I attempted debugging it but that didnt change anything.  Kind of high priority.  snapshot version 2.3.  will provide snapshot file in a outsystems support ticket

We currently have the same issue, since a week, snapshots do not get generated anymore. This error is in Service Center:

Error executing query. Error in advanced query CreateModuleDefinitionsForExtensions2 in Modules_Reload in DiscoveryProbe (INSERT INTO {ModuleDef}(Name, Description, SS_Key, Kind, ApplicationDefId, ESpaceId, ExtensionId, Layer, IsSelected, IsDeleted)  SELECT    E.[Name],   EV.[Description],   E.[SS_Key],   'xif' as Kind,   AD.[Id] as ApplicationDefId,   NULL as ESpaceId,   E.[Id] as ExtensionId,   @LibModuleLayerId as Layer,  1 as IsSelected,  0 as IsDeleted  FROM (((({Extension_Version} EV      Inner JOIN {Extension} E ON (E.[VERSION_ID] = EV.[ID]))       Inner JOIN ({Module} M      Inner JOIN {App_Definition_Module} ADM ON (ADM.[MODULE_ID] = M.[ID])) ON (M.[EXTENSION_ID] = E.[ID]))       Inner JOIN {ApplicationDef} AD ON (ADM.[APPLICATION_ID] = AD.[APPLICATIONID]))       Left JOIN {ModuleDef} MD ON (MD.[EXTENSIONID] = E.[ID]))   WHERE (E.[IS_ACTIVE] = 1) AND (AD.[ISDELETED] <> 1) AND (MD.[ID] IS NULL)): The INSERT statement conflicted with the FOREIGN KEY constraint "OSFRK_OSUSR_MRN_MODULEDEF_OSUSR_MRN_MODULELAYER_LAYER". The conflict occurred in database "platformDB", table "dbo.OSUSR_MRN_MODULELAYER", column 'ID'.

The statement has been terminated.

I was able to solve this by deleting the most recent snapshot and then generating a new one.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.