Sometimes data doesn't show up

Sometimes data doesn't show up

  
Hi,

I created a series of questions for the user to answer.
Occassionally, some of the questions don't display


Before the form is displayed I create answers Id in a different entity in the database for each question.

I link the questions with answers and display them.

Each indvidual questions is in it's own web block.

Occassionally, some of the questions don't display

Eg.
1 Name:
3 Address

Then when I refresh
I'll get
2 Age
3 Address

The questions will randomly display. I suspect it might have something to do with internet speed.
Is there a way I can wait so that all the question will always display? Maybe a ajax refresh.





I could be over loading the database maybe? I think a sleep( 500) might fix it? Are some routine asychronous ( aggregates?)?
Hi Michael,

It's impossible to say what is the problem without knowing what you're doing exactly. Unfortunately from your description, I can't figure that out. Could you perhaps share an eSpace to take a look at?
Hi, Thanks for the reply. 

How does outsystems handle infinite loops ? Maybe I have some infinitie loops running on the server?

https://cstest.tattsgroup.com/LotteriesOutletAudit/

Hi Michael,

All processes can run only a limited amount of time, so the chances that you have infinite loops on the server are rather small.

It feels like the amazon server is returning inconsistent data. Maybe we are on a crappy amazon server? Pretty unllikely though.

I suspect somewhere in outsystem aggregate or web blocks code it isn't actually waiting until it's got all the data before moving onto the next instruction? Can aggregates or web blocks be configured to be synchronous or asynchonous? 

I'll try to check the code a bit more thoroughly.



Hi Michael,

Query's, like the rest of the code, are executed synchronously (except when using lazy loading), so that can't be the problem. I think a thorough code review could indeed be in order :).
I agree, we need to see the code, otherwise it's just guessing.

It could depend when you insert them.
Do you insert them during the same transaction of showing the results.
perhaps the query is not correct.
perhaps the inserts are not entirely correct.

Hi,

Given that data disappears in different places in program, it seems to point at the amazon server being dodgy rather than the code. 

I will migrate the code to production later today and see if the issue persists there and let you know.
Michael,

No way can a "dodgy" server result in this kind of behaviour. If a server is dodgy, you'd get strange errors and the like (e.g. about closed connections), but not a program otherwise running fine. But I'd be interested in hearing how it does in production...
HI,

Prod has the same issue.

I have finished almost everything else in this project so i can concentrate on this issue a bit more.

In the preparation of Show questions, I createorUpdate answers.

In an aggregate, really soon after creating the answers, I get a list of questions joined with the answers.

So essentially the answer is created or updated and then immediately joined to the question for display.

If there's any lag with creating or updating the answer, then I imagine the join with the question wouldn't work.

 
Is there a command to wait 3 seconds after I make the answers?
Hi Michael,

I know what you are getting at, but you are wrong. No transactional, relational database will ever allow updates to its data without returning the updated data in the next call. Of course there's always a matter of parallelism to take into account, but within a single program, there are no race conditions. Both J and I have tried to help you by asking for more details, which you fail to provide. You only keep going on about how you don't trust Amazon, don't trust the database, don't trust anything but your code, while there's obviously a bug in that code that causes the wrong behaviour. Whatever, if you're that obstinacious, I'm done.
Hi,

I agree with Killian. It's not very constructive to only vent your questions/remarks without actually showing the code so we can verify along.  Especially if we asked a couple of times.

In any case, there still is the possibility of the case not being a bug.
Just a simple design-principle of transaction/caching/async inserting.
If you are sure enough, you can do a commit after the inserts and then query the database for the newly inserted records. I cannot verify this, since we have no clue what the actual code looks like.
Hi,

Well, first up - Thanks for your help so far! it is appreciated. 

Sorry, I didn't think the issue was related to the code so didn't want to waste your time. 

Attached is the query that i think is the issue.

Actually, Hold off on doing anything for a bit I will do some of my own testing,


Here is the visual code in this attachment
Here is the OML. I'll have to take this down fairly soon though. Not really supposed to be posting code like this..

All the questions do eventually show up if you refresh about 5 times. 

It doesn't happen everytime. Sometimes it just works.

Actually it might be a proxy issue. I will test on my phone.

To replicate -
1. Create/Edit form - Create a form -
2. Create Question group
3. create 4~5 questions
4. Create a form instance
5. Goto Form.
6. Click through to the questions
7. Your questions may or may not show up.
 



Actually, Hold off on doing anyhting for a bit I will do some of my own testing,

Maybe there is a hidden exception being thrown? i am adding that "all exceptions" -> Exceptions Feedback message - end to the prepataions,

Can't seem to replicate the issue this morning. 
Well, it's not a proxy issue. The same issue happens on my phone.

Still investigating.
OK,
Looks like I've solved it.

It was multiple issues:

1. Aggregates that I was expecting to return a single record, were returning multiple unsorted records. Hence, the randomness of the records being returned. I fixed it by adding more filters, which guaranteed a single record to be returned.

2. A variable of type answer (entity) wasn't getting it's id reset to nullidentifier in a loop, hence would overwrite previous answers. This meant every time you refreshed different questions would display.

Is there an easy way to zero out an entire record variable ? 
eg
ans of type entity Answer
I want to make 

ans.id = nullidentifier()
Ans.textanswer = ""
ans.FormId = Nullidentifier
..

reset all variables.
or do have to set each one manually?




Hi M, 

Glad you have finally solved it!
(Hope this is a wise lesson for ya :) )


normally you have to reset the manually yes.
however, there are some workarounds

1. create a local variable called emptyAnswer of same type, just assign your local to the emptyAnswer.
   this is 1 assign only and it work. downside, you have a extra variable 
2. have a special insert-action, where you provide the specific input parameters (not the complete answer)
 
And as a third alternative, which I wouldn't recommend in this specific case but may come in handy at times, you can create a function with an empty body and a single output parameter of the right type.