AmpersandTarski / RAP

RAP is a tool that lets you analyse Ampersand models, generate functional specifications and make prototypes of information systems. It is the primary tool for students of the Open University of the Netherlands in the course Rule Based Design.
5 stars 3 forks source link

RAP4 / OU: code 504 Gateway Time-out #385

Open EricaRietveld opened 1 month ago

EricaRietveld commented 1 month ago

De situatie

Ik probeerde de volgende versie van een script te compilen, en kreeg !504. Diverse malen geprobeerd, op twee data en verschillende locaties. Ook de vorige versie teruggezet, die eerder foutloos complieerde. Zelfde probleem. Het script van het tutorials erin geplakt, die deed het wel.

Wat er gebeurde er en wat had je verwacht?

Verwachting: compile. Relisatie: landurig loaden, en dan de foutmelding.

Stappen om dit te reproduceren

  1. ??

Screenshot / Video

image

Context / Source van ampersand script

Het script heeft bijna 200 regels, is dat een probleem? Bijgaand:

CONTEXT PreapprovalProcedure IN ENGLISH
PURPOSE CONTEXT PreapprovalProcedure 
{+"Before the Board or Council will decide on a proposal, all departments that are involved or affected must have preapproved the proposal."+}

CONCEPT Person "Any person relevant for the preapproval procedure."
PURPOSE CONCEPT Person
{+"We need to know the persons who initiate prapproval procedures, or represent their departments to support or refuse proposals."}

CONCEPT Department "A unit of control within a larger organization."
PURPOSE CONCEPT Department
{+"We need to know the departments that are involved in or affected by a proposal."+}

CONCEPT Proposal "An idea to do something that the organization has to take a decision about."
PURPOSE CONCEPT Proposal
{+"We need to know the proposals that are the object of the preapproval procedure."+}

-- Relaton 1
RELATION hasInitiated [Person*Proposal] [INJ, SUR]
MEANING {+"A person has initiated the preapproval procedure for a proposal."+}
PURPOSE RELATION hasInitiated
{+"We need to know who initiated a proposal, because they do not need to add an opinion."+}

-- Relation 2
RELATION shouldEvaluate [Person*Proposal] [SUR]
MEANING {+"A person should evaluate a proposal."+}
PURPOSE RELATION shouldEvaluate
{+"We need to know which proposals a person should evaluate."+}

-- Relation 3
RELATION hasSupported [Person*Proposal]
MEANING {+"A person has expressed support for a proposal."+}
PURPOSE RELATION hasSupported 
{+"We need to know who has supported a proposal, to decide the result of the procedure."+} 

-- Relation 4
RELATION hasRefused [Person*Proposal]
MEANING {+"A person has refused support for a proposal."+}
PURPOSE RELATION hasRefused 
{+"We need to know whether somebody has refused to support a proposal, to decide the result of the procedure."+} 

-- Relation 5
RELATION hasEvaluated [Person*Proposal] 
MEANING {+"A person has evaluated a proposal."+}
PURPOSE RELATION hasEvaluated 
{+"We need this relation to define the conditions for a completed evaluation, see rule 3."+} 

--Relation 6 
RELATION hasRepresented [Person*Department] [TOT, UNI, INJ, SUR]
MEANING {+"A person represents a department."+}
PURPOSE RELATION hasRepresented 
{+"We need to know who represents a department to handle preapproval requests."+}

-- Relation 7
RELATION isInvolvedIn [Department*Proposal] [SUR]
MEANING {+"A department is involved in a proposal."+}
PURPOSE RELATION isInvolvedIn 
{+"We need to know which departments are involved in or affected by a proposal, to select signatories."+}

-- Relation 8
RELATION isPreapproved [Proposal*Proposal] [PROP]
MEANING {+"A proposal is preapproved."+}
PURPOSE RELATION isPreapproved
{+"We need to know whether a proposal is preapproved."+} 

-- Relation 9
RELATION isRejected [Proposal*Proposal] [PROP]
MEANING {+"A proposal is rejected."+}
PURPOSE RELATION isRejected
{+"We need to know whether a proposal is rejected."+} 

-- Relation 10
RELATION isReady [Proposal*Proposal] [PROP] 
MEANING {+"The preapproval procedure for a proposal has ended."+}
PURPOSE RELATION isReady
{+"We need to know whether a procedure has ended to stop evaluation tasks."+} 

--Initial population, see report 9, table 10

POPULATION hasRepresented CONTAINS
[ ("RecreationHoD", "Recreation")
; ("TaxHoD", "Tax")
; ("HighwayHoD", "Highway")
; ("AnimalControlHoD", "AnimalControl")
; ("ITHoD", "IT")
; ("FireHoD", "Fire")
; ("ZoningHoD", "Zoning")
; ("JusticeHoD", "Justice")
; ("EngineeringHoD", "Engineering")
; ("PersonnelHoD", "Personnel")
]

-- Rule 1
RULE TaskList : shouldEvaluate |- (hasRepresented; isInvolvedIn) - (hasInitiated \/ hasEvaluated \/(hasRepresented; isInvolvedIn; isReady))
MEANING 
"A person only needs to evaluate a proposal when they represent a departments that is involved in that proposal, when they did not initiate that proposal, and when that proposal is not yet preapproved or rejected."
MESSAGE "There are tasks waiting: evaluate a proposal."
VIOLATION (SRC I, TXT " needs to evaluate a proposal.") 
PURPOSE RULE TaskList {+"To remind users that they have proposals wating to be evaluated."+} 

--Rule 2
RULE PropSupport : hasSupported |- shouldEvaluate
MEANING "A person can only support a proposal when selected to evaluate that proposal."
MESSAGE "Attempt to formally agree with the proposal by a person who does not represent a department that is involved." 
VIOLATION (SRC I, TXT " does not represent a department that is involved in the proposal.")
PURPOSE RULE PropSupport 
{+"To remind users that they can only formally support a proposal, when the department that they represent is involved in that proposal."+} 

-- Rule 3
RULE PropRefusal : hasRefused |- shouldEvaluate
MEANING "A person can only refuse a proposal when selected to evaluate that proposal."
MESSAGE "Attempt to formally refuse support for the proposal by a person who does not represent a department that is involved." 
VIOLATION (SRC I, TXT " does not represent a department that is involved in the proposal.")
PURPOSE RULE PropRefusal
{+"To remind users that that they can only formally refuse support a proposal, when the department that they represent is involved in that proposal."+} 

-- Rule 4
RULE PropEvaluated : hasEvaluated |- (hasSupported \/ hasRefused) - (hasSupported /\ hasRefused)
MEANING "When a person has evaluated a proposal this implies that the person has either supported or refused the proposal, but not both(XOR)."
MESSAGE "Attempt to express support AND refusal; the signatory has to choose."
VIOLATION (SRC I, TXT " has expressed both support and refusal of proposal ", SRC I[Person] ; hasEvaluated)
PURPOSE RULE PropEvaluated 
{+"To check that a user has not expressed support and refusal for the same proposal."+}

-- Rule 5
RULE PropRejection : isRejected~ |- hasRefused~; hasRepresented; isInvolvedIn
MEANING "A proposal is rejected when it is refused by a person who represents a department that is involved in the proposal."
PURPOSE RULE PropRejection
{+"To check whether a person who represents an involved department has refused to support the proposal."+}

-- Rule 6
RULE PropPreapproval : isPreapproved |- shouldEvaluate~; hasSupported
MEANING "A proposal is preapproved when all persons who should evaluate the proposal expressed support."
PURPOSE RULE PropPreapproval
{+"To check whether representatives of all involved departments have suported the proposal."+} 

-- Rule 7
RULE ProcedureEnded : isReady |- isPreapproved \/ isRejected
MEANING "A preapproval procedure has ended when the proposal is either preapproved or rejected."
PURPOSE RULE ProcedureEnded
{+"To check that a preapproval procedure has ended for a proposal."+} 

INTERFACE PreapprovalProcedure FOR HeadsOfDepartment : "_SESSION" cRud  
BOX <TABS>
[StartProcedure : V[SESSION*Person]                             cRud
  BOX <FORM>                             
  [ "Initiator of the preapproval procedure" : I[Person]        cRud
  , "Name of the proposal" : hasInitiated                       CRUD
  ]
, Distribution : V[SESSION*Proposal]
  BOX<FORM>
  [ "Proposal" : I[Proposal]                                    cRud
  , "Departments involved": isInvolvedIn~                       cRUd
  ]
, GiveOpinion : V[SESSION*Person]                               cRud           
  BOX <FORM>
  [ "Signatory": I[Person]                                      cRud
  , "Department": hasRepresented                                cRud
  , "I support this proposal" : shouldEvaluate \ hasSupported   CRUD
  , "I refuse this proposal": shouldEvaluate \ hasRefused       CRUD
  ]
, Results : V[SESSION*Proposal]                                 cRud
  BOX<TABLE>
  [ "Proposal name": I[Proposal]                                cRud
  , "Preapproved": isPreapproved                                cRud
  , "Rejected": isRejected                                      cRud
  ]
, OverviewProposal : V[SESSION*Proposal]                        cRud
  BOX <FORM> 
  [ "Proposal" : I[Proposal]                                    cRud
  , "Initiator of the preapproval procedure" : hasInitiated~    cRud
  , "Selection of signatories" : shouldEvaluate~                cRud
  , "Supporters of the proposal" : hasSupported~                cRud
  , "Opponents of the proposal" : hasRefused~                   cRud
  , "Evaluated by" : hasEvaluated~                              cRud
  , "Departments involved" : isInvolvedIn~                      cRud
  , "Preapproved" : isPreapproved                               cRud
  , "Rejected" : isRejected                                     cRud
  ]
, OverviewHoDs : V[SESSION*Person]                              cRud
  BOX <FORM>
  [ "Head of Department" :I[Person]                             cRud
  , "Department represented" : hasRepresented                   cRud
  , "Procedures initiated" : hasInitiated                       cRud
  , "Proposals to evaluate" : shouldEvaluate                    cRud
  , "Proposal supported": hasSupported                          cRud
  , "Proposal refused": hasRefused                              cRud
  , "Proposals evaluated": hasEvaluated                         cRud
  ]
]

ENDCONTEXT
hanjoosten commented 1 month ago

@EricaRietveld, Een 504 error code vertelt je dat de server er te lang over doet. Ik kan dit op dit moment niet reproduceren, omdat ik op een nieuwere (development) versie van ampersand werk. Mijn eerste vermoeden is dat er een regel bestaat in je script, die een hele ingewikkelde SQL-querie (= database bevraging) nodig heeft. Puur op intuïtie zou regel 1 wel eens de veroorzaker kunnen zijn.

Je zou kunnen proberen om het script eerst te compileren zonder de regels. Dan steeds een of meerdere regels toe te voegen en kijken of je er zo achter kan komen welke regel (of regels?) erg lang duren. Vaak kan je zo'n regel op een andere manier opschrijven, die simpeler is en hetzelfde resultaat heeft.

Hopelijk heb je hier al wat aan.

EricaRietveld commented 1 month ago

Dankjewel, ik ga het proberen! Erica

Op ma 21 okt 2024 om 16:29 schreef Han Joosten @.***>:

@EricaRietveld https://github.com/EricaRietveld, Een 504 error code https://www.checkupdown.com/http-status-error-504/ vertelt je dat de server er te lang over doet. Ik kan dit op dit moment niet reproduceren, omdat ik op een nieuwere (development) versie van ampersand werk. Mijn eerste vermoeden is dat er een regel bestaat in je script, die een hele ingewikkelde SQL-querie (= database bevraging) nodig heeft. Puur op intuïtie zou regel 1 wel eens de veroorzaker kunnen zijn.

Je zou kunnen proberen om het script eerst te compileren zonder de regels. Dan steeds een of meerdere regels toe te voegen en kijken of je er zo achter kan komen welke regel (of regels?) erg lang duren. Vaak kan je zo'n regel op een andere manier opschrijven, die simpeler is en hetzelfde resultaat heeft.

Hopelijk heb je hier al wat aan.

— Reply to this email directly, view it on GitHub https://github.com/AmpersandTarski/RAP/issues/385#issuecomment-2426852189, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOQRL4EOHXP4OXCTQ3OBZUDZ4UFU3AVCNFSM6AAAAABQKH2BFCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRWHA2TEMJYHE . You are receiving this because you were mentioned.Message ID: @.***>

hanjoosten commented 1 month ago

Weet je zeker dat bovenstaand script exact is waar het mis ging? Ik krijg namelijk fouten:

/workspaces/4ampersand/Issue_RAP385.adl:155:3 error:
  Type error in BOX
    Cannot match:
    - concept Proposal , SRC of: shouldEvaluate [Person*Proposal]\hasSupported [Person*Proposal]
    if you think there is no type error, add an order between the mismatched concepts.
    You can do so by using a CLASSIFY statement.
/workspaces/4ampersand/Issue_RAP385.adl:155:3 error:
  Type error in BOX
    Cannot match:
    - concept Proposal , SRC of: shouldEvaluate [Person*Proposal]\hasRefused [Person*Proposal]
    if you think there is no type error, add an order between the mismatched concepts.
    You can do so by using a CLASSIFY statement.
EricaRietveld commented 1 month ago

Beste Han, dank voor het checken. Blijkbaar heb ik je een oudere versie gestuurd (uit Notes), deze fout had ik er al uitgehaald. Ik ga morgen systematisch alle regels nog eens nalopen, en dan testen zoals je hebt voorgesteld. Dankjewel, fijne avond! Groet, Erica

Op ma 21 okt 2024 om 16:58 schreef Han Joosten @.***>:

Weet je zeker dat bovenstaand script exact is waar het mis ging? Ik krijg namelijk fouten:

/workspaces/4ampersand/Issue_RAP385.adl:155:3 error: Type error in BOX Cannot match:

  • concept Proposal , SRC of: shouldEvaluate [PersonProposal]\hasSupported [PersonProposal] if you think there is no type error, add an order between the mismatched concepts. You can do so by using a CLASSIFY statement. /workspaces/4ampersand/Issue_RAP385.adl:155:3 error: Type error in BOX Cannot match:
  • concept Proposal , SRC of: shouldEvaluate [PersonProposal]\hasRefused [PersonProposal] if you think there is no type error, add an order between the mismatched concepts. You can do so by using a CLASSIFY statement.

— Reply to this email directly, view it on GitHub https://github.com/AmpersandTarski/RAP/issues/385#issuecomment-2426933623, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOQRL4CQM5BGXRMVOVWARIDZ4UJA7AVCNFSM6AAAAABQKH2BFCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRWHEZTGNRSGM . You are receiving this because you were mentioned.Message ID: @.***>

EricaRietveld commented 1 month ago

Beste Han, inmiddels heb ik

  1. het script vereenvoudigd: regel 1 beperkt, met als gevolg relatie 10 en regel 7 verwijderd; en de constraints nagelopen waarvan er 2 niet fout maar wel overbodig waren.
  2. vervolgens je advies gevolgd om de regels één voor één toe te voegen.

Helaas gaf compilen zonder alle regels weer error 504. De interface verwijderd: error 504. Nog een constraint verwijderd, [PROP], mogelijk ook overbodig: error 504.

Kortom: ik weet niet wat ik verder nog kan proberen .. Heb jij nog suggesties? Alvast zeer veel dank, Erica

Het resterrende script is nu:

CONTEXT PreapprovalProcedure IN ENGLISH PURPOSE CONTEXT PreapprovalProcedure {+"Before the Board or Council will decide on a proposal, all departments that are involved or affected must have preapproved the proposal."+}

-- Concept statements, see report 9, table 7

CONCEPT Person "Any person relevant for the preapproval procedure." PURPOSE CONCEPT Person {+"We need to know the persons who initiate prapproval procedures, or represent their departments to support or refuse proposals."}

CONCEPT Department "A unit of control within a larger organization." PURPOSE CONCEPT Department {+"We need to know the departments that are involved in or affected by a proposal."+}

CONCEPT Proposal "An idea to do something that the organization has to take a decision about." PURPOSE CONCEPT Proposal {+"We need to know the proposals that are the object of the preapproval procedure."+}

-- Relation statements, selection see report 9, table 15

-- Relaton 1 RELATION hasInitiated [Person*Proposal] [INJ, SUR] MEANING {+"A person has initiated the preapproval procedure for a proposal."+} PURPOSE RELATION hasInitiated {+"We need to know who initiated a proposal, because they do not need to add an opinion."+}

-- Relation 2 RELATION shouldEvaluate [Person*Proposal] MEANING {+"A person should evaluate a proposal."+} PURPOSE RELATION shouldEvaluate {+"We need to know which proposals a person should evaluate."+}

-- Relation 3 RELATION hasSupported [Person*Proposal] MEANING {+"A person has expressed support for a proposal."+} PURPOSE RELATION hasSupported {+"We need to know who has supported a proposal, to decide the result of the procedure."+}

-- Relation 4 RELATION hasRefused [Person*Proposal] MEANING {+"A person has refused support for a proposal."+} PURPOSE RELATION hasRefused {+"We need to know whether somebody has refused to support a proposal, to decide the result of the procedure."+}

-- Relation 5 RELATION hasEvaluated [Person*Proposal] [SUR] MEANING {+"A person has evaluated a proposal."+} PURPOSE RELATION hasEvaluated {+"We need this relation to define the conditions for a completed evaluation, see rule 3."+}

--Relation 6 RELATION hasRepresented [Person*Department] [TOT, UNI, INJ, SUR] MEANING {+"A person represents a department."+} PURPOSE RELATION hasRepresented {+"We need to know who represents a department to handle preapproval requests."+}

-- Relation 7 RELATION isInvolvedIn [Department*Proposal] [SUR] MEANING {+"A department is involved in a proposal."+} PURPOSE RELATION isInvolvedIn {+"We need to know which departments are involved in or affected by a proposal, to select signatories."+}

-- Relation 8 RELATION isPreapproved [Proposal*Proposal] MEANING {+"A proposal is preapproved."+} PURPOSE RELATION isPreapproved {+"We need to know whether a proposal is preapproved."+}

-- Relation 9 RELATION isRejected [Proposal*Proposal] MEANING {+"A proposal is rejected."+} PURPOSE RELATION isRejected {+"We need to know whether a proposal is rejected."+}

--Initial population, see report 9, table 10

POPULATION hasRepresented CONTAINS [ ("RecreationHoD", "Recreation") ; ("TaxHoD", "Tax") ; ("HighwayHoD", "Highway") ; ("AnimalControlHoD", "AnimalControl") ; ("ITHoD", "IT") ; ("FireHoD", "Fire") ; ("ZoningHoD", "Zoning") ; ("JusticeHoD", "Justice") ; ("EngineeringHoD", "Engineering") ; ("PersonnelHoD", "Personnel") ]

-- Rule statements, see report 9, table 12 and table 14

-- Rule 1

--Rule 2

-- Rule 3

-- Rule 4

-- Rule 5

-- Rule 6

-- Interface

ENDCONTEXT

hanjoosten commented 1 month ago

Dag Erica, Is dat laatste script precies het script dat die 504 veroorzaakt? Ik zie namelijk nauwelijks regels.

EricaRietveld commented 1 month ago

Ja, ik heb het gekopieerd uit RAP4. Zoals beschreven had ik eerst alle regels er uit gehaald, toen ook de interface, en toen nog wat properties. En die 504 blijft maar komen ..

EricaRietveld commented 1 month ago

Steeds eerst refresh page gedaan, en dan compile ..

stefjoosten commented 3 weeks ago

Ik heb wat zitten onderzoeken, maar we hebben deze fout vaker gezien in andere omgevingen dan RAP. Maar alleen op het Kubernetes platform. Ik vermoed dat we moeten kijken naar de resources die RAP verbruikt. Knellende resources leiden tot deze symptomen: foutmeldingen van de NGINX server (die buiten RAP ligt) en geen duidelijke aanwijzingen in de logbestanden van RAP. Wat het lastig maakt is dat we niet precies weten hoeveel resources van welke soort RAP precies nodig heeft. Bovendien zit er nog altijd een space leak in...