View Issue Details

This bug affects 1 person(s).
 12
IDProjectCategoryView StatusLast Update
18798Bug reportsStatisticspublic2023-07-31 15:02
Reporterollehar Assigned Toollehar  
PriorityhighSeveritycrash 
Status closedResolutionfixed 
Product Version6.0.x 
Summary18798: Out-of-memory problem in statistics export
Description

Response::findAll() cannot work and must be reverted

See code in statistics helper functions

Old code by Dominik that was not stress tested properly. Now it causes out-of-memory white screen of death.

Branch: bug/out-of-memory-statistics (based on 5.x, but needs to be done in master too)

Steps To Reproduce

Need a survey using encryption and 50k+ responses.

TagsNo tags attached.
Bug heat12
Complete LimeSurvey version number (& build)v5
I will donate to the project if issue is resolvedNo
Browser-
Database type & version-
Server OS (if known)-
Webserver software & version (if known)-
PHP Version-

Relationships

related to 18813 new Summary table in statistics is missing opening tbody tag 
related to 18814 closedtibor.pacalat Array question statistics fail for Remote Control 

Users monitoring this issue

There are no users monitoring this issue.

Activities

ollehar

ollehar

2023-05-02 13:53

administrator   ~74750

Last edited: 2023-05-02 13:54

Branch: bug/out-of-memory-statistics (based on 5.x, but needs to be done in master too)

Started some work here already.

The code raw SQL inside displaySimpleResults() needs to be restored and Response::model()->findAll() removed, together with the loops. The raw SQL need to compare with encrypted version of empty string or “-oth-” if the question is encrypted.

DenisChenu

DenisChenu

2023-05-02 15:04

developer   ~74752

Response::findAll() didn't decrypt all response ? Right ?

ollehar

ollehar

2023-05-02 15:39

administrator   ~74755

it does not, Denis, but Dominik looped all responses to decrypt them, which obviously will never work with lots of participants.

DenisChenu

DenisChenu

2023-05-02 16:07

developer   ~74756

it does not, Denis, but Dominik looped all responses to decrypt them, which obviously will never work with lots of participants.

Right … really complex here

What solution we have ?

We :

  • Check ALL questions in statistics
  • Ask for graph for all too

I'm unsure we have a clean solution …

ollehar

ollehar

2023-05-02 16:08

administrator   ~74757

Last edited: 2023-05-02 16:09

What solution we have ?

Read my commit in the branch.

We don't salt the encryptions, so exact compare is possible, which is all that it takes. Dominik didn't realize, it seems.

DenisChenu

DenisChenu

2023-05-02 16:16

developer   ~74759

We don't salt the encryptions, so exact compare is possible, which is all that it takes. Dominik didn't realize, it seems.

Yes, it's a low security encryption here. But it's here : https://github.com/LimeSurvey/LimeSurvey/blob/f0e7e3acbfe76a78237ff8ab4b0989d2acf692d2/application/helpers/admin/statistics_helper.php#L530 (for single choice).

Available only for single choice, you can encrypt Answers code value.
Maybe get the encryoted value her e: https://github.com/LimeSurvey/LimeSurvey/blob/f0e7e3acbfe76a78237ff8ab4b0989d2acf692d2/application/helpers/admin/statistics_helper.php#L639

But if you have 50 free text question : still broken …

gabrieljenik

gabrieljenik

2023-05-02 22:37

manager   ~74764

From my point of view: For the open text questions,

  • either we query for exact match
  • or we don't allow to filter by open text questions which are encrypted. (right now that doesn't work)

I believe a list of text answers is also possible to show there.
Besides being encrypted or not, that would also be very complex with surveys with many answers.
Maybe something to remove? (That's not stats anyway, just list of responses). :)

DenisChenu

DenisChenu

2023-05-03 08:05

developer   ~74765

2 POV

About filter

  • We can filter by encrypted value for single choice (or Y code) : Good idea
  • Disable filter by free text is a bad idea : it work if you have some response and/or a lot of memory : put an alert is the best .

About using to construct the graph (or export etc …)
Maybe we can use an instance when we have a lot ?
See export part for example : https://github.com/LimeSurvey/LimeSurvey/blob/77a234a70fbca29ce65180e895cde85b85ebdbf8/application/helpers/export_helper.php#L133

foreach ($result as $row) {
     $oResponse->decrypt();
}

Maybe : decrypt can use some already Answers->crypted value ? Done at start with all crypted value of single answer ?
Take memory too (the [cryptedValue=>showValue] must be put in memory) but it can really improve a lot of functionnality ?

ollehar

ollehar

2023-05-03 10:13

administrator   ~74767

Ehm, there's no reason to restrict a feature if we can just fix it, or? Unless the fix is very hard.

DenisChenu

DenisChenu

2023-05-03 10:36

developer   ~74768

Disable filter by free text is a bad idea : it work if you have some response and/or a lot of memory : put an alert is the best .

DenisChenu

DenisChenu

2023-05-03 10:36

developer   ~74769

either we query for exact match

A checkbox (with explain that can allow to search on big data in case of memory issue) ?

gabrieljenik

gabrieljenik

2023-05-03 14:29

manager   ~74778

Last edited: 2023-05-03 14:30

there's no reason to restrict a feature if we can just fix it, or? Unless the fix is very hard.

Well,

  • We want to avoid old approach (downloading data into memory + loops + decrypt).
  • We can only query a encrypted field by exact match
  • Filtiering a text input by exact match seems to lead to confusion, false expectations and probably lot of support issues and complains.
    So, what other fix alternatives do we have?

We can filter by encrypted value for single choice (or Y code) : Good idea

Yes. We are already doing that in some places.
And implementing on others.

Disable filter by free text is a bad idea : it work if you have some response and/or a lot of memory : put an alert is the best .

I don't like the alert. "Use at your own risk. Please take into account this may fail"? :)

About using to construct the graph (or export etc …)

Will review it. Bump into this blocking thing. Wanted to solve it as it may guide the rest of the solution.

DenisChenu

DenisChenu

2023-05-03 14:37

developer   ~74780

I don't like the alert. "Use at your own risk. Please take into account this may fail"? :)

But remove a feature to all user because some can have issue it's worst …

You can not remove the current feature allowing to search in contains on 200 response because you need to disable (maybe) in 5 000

gabrieljenik

gabrieljenik

2023-05-03 14:48

manager   ~74783

You can not remove the current feature allowing to search in contains on 200 response because you need to disable (maybe) in 5 000

Well, that's a downside :) haha
I just don't value that feature that much (and think that doesn't fit there), so I think could be removed in favor of a more ordered script/screen.
But I get your point.

Would like to hear @ollehar about other probable fixing ideas.

A checkbox (with explain that can allow to search on big data in case of memory issue) ?

This I think could be a good workaround.

ollehar

ollehar

2023-05-04 13:02

administrator   ~74808

Wasn't the current code already limited to exact match? Maybe I misunderstood it.

gabrieljenik

gabrieljenik

2023-05-04 14:51

manager   ~74812

Well, there is some work to be done here.
This will not work on encrypted questions. I guess we will have to clarify it

image.png (53,637 bytes)   
image.png (53,637 bytes)   
ollehar

ollehar

2023-05-04 14:56

administrator   ~74814

Is that old or current code in your screenshot?
There might be multiple problems, of course, but we're mainly concerned about getting the customer past the current white screen of death.

gabrieljenik

gabrieljenik

2023-05-04 23:14

manager   ~74827

Branch updated:
https://github.com/LimeSurvey/LimeSurvey/compare/5.x...bug/out-of-memory-statistics

Left fixing of some problems out of the scope as to focus on the memory stuff.
Will tackle them later on a different ticket, to be created once this is done.

ollehar

ollehar

2023-05-05 11:42

administrator   ~74830

Added a PR for the branch: https://github.com/LimeSurvey/LimeSurvey/pull/3111

ollehar

ollehar

2023-05-05 13:14

administrator   ~74838

Nice, it works, but customer didn't actually have any encrypted questions, what I can see in the responses view. Sooooo how to test??

gabrieljenik

gabrieljenik

2023-05-05 15:37

manager   ~74847

I am actually working on some unit test scripts for it :)

ollehar

ollehar

2023-05-05 15:40

administrator   ~74848

Brilliant!

gabrieljenik

gabrieljenik

2023-05-09 21:17

manager   ~74906

Initial set of tests: https://github.com/LimeSurvey/LimeSurvey/pull/3121

ollehar

ollehar

2023-05-10 11:02

administrator   ~74912

Cool. You wanna rebranch it to 5.x? That's where the fix is based on. We need to cherry-pick it to master later.

gabrieljenik

gabrieljenik

2023-05-11 22:03

manager   ~74938

New PR for master: SimpleStatistics
https://github.com/LimeSurvey/LimeSurvey/pull/3132

Cool. You wanna rebranch it to 5.x?

Sorry, got delayed enhancing the test with more question types.
Will do it of course.

gabrieljenik

gabrieljenik

2023-05-15 18:21

manager   ~74987

Status.

At the very beginning we had this branch (PR 3121):
https://github.com/LimeSurvey/LimeSurvey/tree/dev/rc_export_statistics_tests

As we were developing it we stumble with this bug.
https://bugs.limesurvey.org/view.php?id=18814
The fix is here:
https://github.com/LimeSurvey/LimeSurvey/commit/3fb81e51289b6ce90cd2d3749bcc62b2bbf699b5

So then created a new branch (deriving from the first branch) holding the tests for array and the bug fix
https://github.com/LimeSurvey/LimeSurvey/tree/dev/rc_export_statistics_array_questions_tests

All this is for v6
We are porting it to v5.

By looking at the code we see more bugs similar to 18814.
Nevertheless, we still didn't get to create its test for pushing the solution+test at the same time.

gabrieljenik

gabrieljenik

2023-05-15 18:27

manager   ~74990

@ollehar Not sure how you prefer to merge this:

  • One branch/PR at a time
  • Or close the PR and just create a new one
gabrieljenik

gabrieljenik

2023-05-15 23:27

manager   ~75002

PR for v5 including fix and tests.
https://github.com/LimeSurvey/LimeSurvey/pull/3141

gabrieljenik

gabrieljenik

2023-05-23 20:18

manager   ~75201

This is the only PR pending for v6
https://github.com/LimeSurvey/LimeSurvey/pull/3165

DenisChenu

DenisChenu

2023-05-24 07:25

developer   ~75203

I rerun failed job to have green and merge if it's OK

gabrieljenik

gabrieljenik

2023-05-24 15:09

manager   ~75218

I believe the error is coming from master.
Merged from master but that didn't work.
Will wait for a while and try again

ollehar

ollehar

2023-05-24 17:02

administrator   ~75219

It was. I reverted the offending commit, please try to merge again now. :)

tibor.pacalat

tibor.pacalat

2023-06-06 13:43

administrator   ~75424

Does the person that worked on this fix has some survey file that they can share to test and verify the fix here https://github.com/LimeSurvey/LimeSurvey/pull/3111?
Also some testing instructions would be great! Thank you in advance ;)

gabrieljenik

gabrieljenik

2023-06-06 14:34

manager   ~75426

The fix is very wide in terms as it updates some basic queries.
There has been auto tests created for this.

tibor.pacalat

tibor.pacalat

2023-06-06 14:56

administrator   ~75427

So you are saying it doesn't need testing or?

gabrieljenik

gabrieljenik

2023-06-06 15:02

manager   ~75428

I am saying the fix is not specific as to have specific testing instructions.

tibor.pacalat

tibor.pacalat

2023-06-06 18:10

administrator   ~75453

Sure, but what are the steps to reproduce one use case where this happens (plus .lsa file)?

ollehar

ollehar

2023-06-07 12:14

administrator   ~75458

Last edited: 2023-06-07 12:14

We had a customer report this error, and I could use the customer's data to reproduce it.

But which customer...

ollehar

ollehar

2023-06-20 12:02

administrator   ~75728

Fix committed to 5.x branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=34856

ollehar

ollehar

2023-06-20 12:05

administrator   ~75729

I merged this now, since it's too hard to test anyway.

ollehar

ollehar

2023-06-20 12:59

administrator   ~75730

Fix committed to 5.x branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=34857

ollehar

ollehar

2023-06-20 13:02

administrator   ~75731

Last edited: 2023-06-20 13:04

Had to revert, CI got red. Please redo the PR and fix any bugs.

gabrieljenik

gabrieljenik

2023-06-20 15:26

manager   ~75740

New v5 PR: https://github.com/LimeSurvey/LimeSurvey/pull/3231

ollehar

ollehar

2023-06-20 15:53

administrator   ~75745

Merged, thank you Gabriel!

guest

guest

2023-06-20 16:36

viewer   ~75746

Fix committed to 5.x branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=34864

LimeBot

LimeBot

2023-06-26 12:04

administrator   ~75860

Fixed in Release 5.6.28+230627

gabrieljenik

gabrieljenik

2023-06-26 14:20

manager   ~75863

Need to do it for master as well, right?

gabrieljenik

gabrieljenik

2023-07-03 15:25

manager   ~75922

Master PR: https://github.com/LimeSurvey/LimeSurvey/pull/3267

guest

guest

2023-07-18 15:22

viewer   ~76135

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=35186

LimeBot

LimeBot

2023-07-31 15:02

administrator   ~76371

Fixed in Release 6.2.0+230732

Related Changesets

LimeSurvey: 5.x 47c40dbe

2023-06-20 14:02

ollehar

Committer: GitHub


Details Diff
Fixed issue 18798: Out-of-memory problem in statistics export (#3111)

Co-authored-by: lapiudevgit <devgit@lapiu.biz>
Affected Issues
18798
mod - application/helpers/admin/statistics_helper.php Diff File

LimeSurvey: 5.x baeb6afc

2023-06-20 14:59

ollehar


Details Diff
Revert "Fixed issue 18798: Out-of-memory problem in statistics export (#3111)"

This reverts commit 47c40dbe4f6b381e97d603de174c25503be60176.
Affected Issues
18798
mod - application/helpers/admin/statistics_helper.php Diff File

LimeSurvey: 5.x e9bec13e

2023-06-20 17:53

Gabriel Jenik

Committer: GitHub


Details Diff
Fixed issue 18798: Out-of-memory problem in statistics export (#3231)

Co-authored-by: lapiudevgit <devgit@lapiu.biz>
Affected Issues
18798
mod - application/helpers/admin/statistics_helper.php Diff File

LimeSurvey: master e581edbc

2023-07-18 17:22

Gabriel Jenik

Committer: GitHub


Details Diff
Fixed issue 18798: Out-of-memory problem in statistics export (#3231) (03267) Affected Issues
18798
mod - application/helpers/admin/statistics_helper.php Diff File

Issue History

Date Modified Username Field Change
2023-05-02 13:50 ollehar New Issue
2023-05-02 13:50 ollehar Assigned To => gabrieljenik
2023-05-02 13:50 ollehar Status new => assigned
2023-05-02 13:50 ollehar Summary Response::findAll() cannot work and must be reverted => Out-of-memory problem in statistics export
2023-05-02 13:50 ollehar Description Updated
2023-05-02 13:51 ollehar Steps to Reproduce Updated
2023-05-02 13:53 ollehar Note Added: 74750
2023-05-02 13:53 ollehar Bug heat 0 => 2
2023-05-02 13:53 ollehar Description Updated
2023-05-02 13:54 ollehar Note Edited: 74750
2023-05-02 13:54 ollehar Note Edited: 74750
2023-05-02 15:04 DenisChenu Note Added: 74752
2023-05-02 15:04 DenisChenu Bug heat 2 => 4
2023-05-02 15:39 ollehar Note Added: 74755
2023-05-02 16:07 DenisChenu Note Added: 74756
2023-05-02 16:07 DenisChenu File Added: Capture d’écran du 2023-05-02 16-06-46.png
2023-05-02 16:08 ollehar Note Added: 74757
2023-05-02 16:09 ollehar Note Edited: 74757
2023-05-02 16:16 DenisChenu Note Added: 74759
2023-05-02 22:37 gabrieljenik Note Added: 74764
2023-05-02 22:37 gabrieljenik Bug heat 4 => 6
2023-05-03 08:05 DenisChenu Note Added: 74765
2023-05-03 10:13 ollehar Note Added: 74767
2023-05-03 10:36 DenisChenu Note Added: 74768
2023-05-03 10:36 DenisChenu Note Added: 74769
2023-05-03 10:44 ollehar Priority none => high
2023-05-03 14:29 gabrieljenik Note Added: 74778
2023-05-03 14:30 gabrieljenik Note Edited: 74778
2023-05-03 14:37 DenisChenu Note Added: 74780
2023-05-03 14:48 gabrieljenik Note Added: 74783
2023-05-04 13:02 ollehar Note Added: 74808
2023-05-04 14:51 gabrieljenik Note Added: 74812
2023-05-04 14:51 gabrieljenik File Added: image.png
2023-05-04 14:56 ollehar Note Added: 74814
2023-05-04 23:14 gabrieljenik Note Added: 74827
2023-05-05 11:42 ollehar Note Added: 74830
2023-05-05 13:14 ollehar Note Added: 74838
2023-05-05 15:37 gabrieljenik Note Added: 74847
2023-05-05 15:40 ollehar Note Added: 74848
2023-05-09 21:17 gabrieljenik Note Added: 74906
2023-05-10 11:02 ollehar Note Added: 74912
2023-05-11 22:03 gabrieljenik Note Added: 74938
2023-05-11 22:09 gabrieljenik Issue cloned: 18813
2023-05-11 22:09 gabrieljenik Relationship added related to 18813
2023-05-11 22:11 gabrieljenik Issue cloned: 18814
2023-05-11 22:11 gabrieljenik Relationship added related to 18814
2023-05-15 18:21 gabrieljenik Note Added: 74987
2023-05-15 18:27 gabrieljenik Note Added: 74990
2023-05-15 23:27 gabrieljenik Note Added: 75002
2023-05-17 23:19 gabrieljenik Assigned To gabrieljenik => ollehar
2023-05-17 23:19 gabrieljenik Status assigned => ready for merge
2023-05-23 20:18 gabrieljenik Note Added: 75201
2023-05-24 07:24 DenisChenu Assigned To ollehar => DenisChenu
2023-05-24 07:25 DenisChenu Note Added: 75203
2023-05-24 15:09 gabrieljenik Note Added: 75218
2023-05-24 17:02 ollehar Note Added: 75219
2023-05-31 08:35 DenisChenu Assigned To DenisChenu => gabrieljenik
2023-05-31 15:02 gabrieljenik Assigned To gabrieljenik => ollehar
2023-06-06 13:43 tibor.pacalat Note Added: 75424
2023-06-06 13:43 tibor.pacalat Bug heat 6 => 8
2023-06-06 14:34 gabrieljenik Note Added: 75426
2023-06-06 14:56 tibor.pacalat Note Added: 75427
2023-06-06 15:02 gabrieljenik Note Added: 75428
2023-06-06 18:10 tibor.pacalat Note Added: 75453
2023-06-07 12:14 ollehar Note Added: 75458
2023-06-07 12:14 ollehar Note Edited: 75458
2023-06-20 12:02 ollehar Changeset attached => LimeSurvey 5.x 47c40dbe
2023-06-20 12:02 ollehar Note Added: 75728
2023-06-20 12:02 ollehar Resolution open => fixed
2023-06-20 12:05 ollehar Status ready for merge => resolved
2023-06-20 12:05 ollehar Note Added: 75729
2023-06-20 12:59 ollehar Changeset attached => LimeSurvey 5.x baeb6afc
2023-06-20 12:59 ollehar Note Added: 75730
2023-06-20 13:02 ollehar Status resolved => new
2023-06-20 13:02 ollehar Resolution fixed => reopened
2023-06-20 13:02 ollehar Note Added: 75731
2023-06-20 13:04 ollehar Note Edited: 75731
2023-06-20 15:26 gabrieljenik Note Added: 75740
2023-06-20 15:26 gabrieljenik Status new => ready for code review
2023-06-20 15:26 gabrieljenik Complete LimeSurvey version number (& build) master => v5
2023-06-20 15:53 ollehar Status ready for code review => resolved
2023-06-20 15:53 ollehar Note Added: 75745
2023-06-20 16:36 Changeset attached => LimeSurvey 5.x e9bec13e
2023-06-20 16:36 guest Note Added: 75746
2023-06-20 16:36 guest Bug heat 8 => 10
2023-06-26 12:04 LimeBot Note Added: 75860
2023-06-26 12:04 LimeBot Status resolved => closed
2023-06-26 12:04 LimeBot Resolution reopened => fixed
2023-06-26 12:04 LimeBot Bug heat 10 => 12
2023-06-26 14:20 gabrieljenik Status closed => assigned
2023-06-26 14:20 gabrieljenik Note Added: 75863
2023-07-03 15:25 gabrieljenik Note Added: 75922
2023-07-03 15:25 gabrieljenik Status assigned => ready for code review
2023-07-18 15:22 Changeset attached => LimeSurvey master e581edbc
2023-07-18 15:22 guest Note Added: 76135
2023-07-31 15:02 LimeBot Note Added: 76371
2023-07-31 15:02 LimeBot Status ready for code review => closed