Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature: allow choosing innoDb vs MyIsam engine for MYSQL during installation #1043

Merged
merged 122 commits into from
Apr 29, 2019

Conversation

TonisOrmisson
Copy link
Collaborator

Formerly opened form master #977, now for develop

Some notes:
in order for innoDb to work one needs:

  • innodb_large_prefix = 1
  • innodb_file_format = Barracuda;
  • innodb_file_format_max = Barracuda;

otherwise you will get the "Error 1071: Specified key was too long; max key length is 767 bytes" for the text indexes, (Error 1071: Specified key was too long; max key length is 767 bytes)

I enabled this for travis
https://github.com/LimeSurvey/LimeSurvey/compare/develop...TonisOrmisson:develop-innodb?expand=1#diff-354f30a63fb0907d4ad57269548329e3R45

and checking of this will be done in installer validation here
https://github.com/LimeSurvey/LimeSurvey/compare/develop...TonisOrmisson:develop-innodb?expand=1#diff-12a8fc159f48cb97e97609f6c43aab0aR258

Did some major changes in the installer logic.
Why? because I needed to check the Innodb settings status in the model validation: so the dbConnection needed to move from the controller to the Model. And so all of the connection related things were moved to model. Controller got much more cleaner and is now not doing things that logically should not be there.

Also cleaned up the view along that since there was code that should not be in the view.

Tests:
I enabled separate set of tests for InnoDB and MyIsam. So the whole test set runs both ways now.
Also added PHP 7.2 to the matrix.

... I think we should also use the pgsql for testing on travis. As far as I understand this is also included for travis so I would use an ENV DBTYPE to run test matrix also on available non-mysql options.

I have tested this manually also during the work, but since there is a lot of changes here I would ask for you to review the code as well as also help to test manually. Especially for MSSQL that I do not have and is not tested against!

@TonisOrmisson
Copy link
Collaborator Author

Ok now.
The timings and responses tables are created by the SurveyActivator using the same session. So the timigs table was OK. But tokens table was created with a separate request. This is now fixed also. Also added the engine option to activate_helper and AuditLog table creations. I tested the activation parts wihle changing the engines with responses/timings/tokens table. Feel free to merge.

@TonisOrmisson TonisOrmisson changed the title New Feature: allow choosing innoDb vs MyIsam engine for MYSQL during installation (WIP) New Feature: allow choosing innoDb vs MyIsam engine for MYSQL during installation Mar 22, 2019
@@ -557,6 +557,11 @@ public function beforeActivate()
{
if (!$this->api->tableExists($this, 'log'))
{
$options = '';
if (Yii::app()->db->driverName == 'mysqli' || Yii::app()->db->driverName == 'mysql') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think more of something in API ;) : api->createTable function (but this api is … so … so … light)

@dominikvitt
Copy link
Contributor

I just finished with testing.
There is occasionally a following error when trying to import .lsa file:

Call to a member function getColumnNames() on null
application/helpers/admin/import_helper.php(2205)

There is also this error when trying to activate a survey with many columns:

CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1118 Row size too large (> 8126)

It is obvious those errors are related to innoDB limitation of having too many columns.

In such case, import/activation should be aborted and warning should be shown to user.
Anybody have some idea about this?

@Shnoulle
Copy link
Collaborator

Shnoulle commented Apr 3, 2019

It is obvious those errors are related to innoDB limitation of having too many columns.

InnoDB don't send exception here ?

try {
Yii::app()->db->createCommand()->createTable($sTableName, $aTableDefinition);
Yii::app()->db->schema->getTable($sTableName, true); // Refresh schema cache just in case the table existed in the past
} catch (CDbException $e) {
if (App()->getConfig('debug')) {
return array('error'=>$e->getMessage());
} else {
return array('error'=>'surveytablecreation');
}
}

@Shnoulle
Copy link
Collaborator

Shnoulle commented Apr 3, 2019

Just checkout :

CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'firstname' used in key specification without a key length. The SQL statement executed was: ALTER TABLE lime_participants CHANGE firstname firstname text NOT NULL

But seems all my setup wads broken now … maybe an issue in DBversion …

@TonisOrmisson
Copy link
Collaborator Author

Thanks for testing!
Can you tell whether the InnoDb acts differently compared to MyIsam when the column limit is reached? I would think that such error would be regardless of engine?

Maybe you can add some test files to the tests/data/surveys folder so that this could be tested automatically. Eg a survey with too much columns for MyIsam. And a survey with too much columns for InnoDb.

Did you try with debugging = 0, was it the same?

@dominikvitt
Copy link
Contributor

When activating, it shows nice warning message when debug=0.

@dominikvitt
Copy link
Contributor

Column limit does not apply to the BLOB and TEXT type.
In current development version, all response columns are created as TEXT (because data encryption feature require it).
So, I'll try to merge your changes to my local develop version and see if problem is corrected.

@TonisOrmisson
Copy link
Collaborator Author

@dominikvitt
I guessing it is the same behaviour that we have currently (in master) and with MyIsam. If that's the case, maybe its not specifically related to this feature? If you turn off debugging there is a number of places you might end up with an exception thrown.

@TonisOrmisson
Copy link
Collaborator Author

@Shnoulle can you check what is the status of the engine variables (see top of page):

innodb_large_prefix;
innodb_file_format;
innodb_file_format_max;

your issue sounds like related to innodb_large_prefix.
This should be checked during installation actually. Or maybe you changed some after installation?

@Shnoulle
Copy link
Collaborator

Shnoulle commented Apr 3, 2019

I just checkout my current develop with your's (i want to test set innodb after install too)

Currently : even with core develop : i have issue with my master DB to upgrade to develop.
@dominikvitt : do you know when we check DB updater ?

@dominikvitt
Copy link
Contributor

I would test now upgrading from master to develop.

@Shnoulle
Copy link
Collaborator

Shnoulle commented Apr 3, 2019

I would test now upgrading from master to develop.

Ok , i check too (maybe must do a checkintegrity , i test and if checkintegrity fix my issue i report to do one before upgrade (in fact i think we must do one each time we upgrade : new Feature …)

@dominikvitt
Copy link
Contributor

@Shnoulle Database problem is fixed now, you can try again.

@Shnoulle
Copy link
Collaborator

Shnoulle commented Apr 3, 2019

@dominikvitt
Copy link
Contributor

Current develop version is already using TEXT db fields for all response columns, so we can't solve it like that. Let it stay for now as it is.

@TonisOrmisson Can you add check to see if table is actually created while importing .lsa file?
If table is not created, then you can show the same message as it is for survey activation.

@TonisOrmisson
Copy link
Collaborator Author

created a new survey with this branch, activated and created some responses, exported lsa and imported as new survey. All relevant tables were created. responses, timings, tokens.

@maziminke
Copy link
Collaborator

In current development version, all response columns are created as TEXT (because data encryption feature require it).
Does that mean that e.g. for the date question type or the numeric input a TEXT field is used as well?

How does that work with features like filtering statistics by date or calculating e.g. mean or average values at statistics and other features? Don't they rely on a proper DB field type?

@Shnoulle
Copy link
Collaborator

Shnoulle commented Apr 4, 2019

In current development version, all response columns are created as TEXT (because data encryption feature require it).

Really ? And this was merged in develop … for alpha version … the DB column type is the most complicated system to move to QuestionObject … don't do it at start of devlopment seem realy an issue in my opinion …

@dominikvitt
Copy link
Contributor

How does that work with features like filtering statistics by date or calculating e.g. mean or average values at statistics and other features? Don't they rely on a proper DB field type?

All features you mentioned don't rely on specific DB field type and data would be read the same regardless of DB field type. So, there shouldn't be any different behaviour when using TEXT DB field type.

@dominikvitt
Copy link
Contributor

created a new survey with this branch, activated and created some responses, exported lsa and imported as new survey. All relevant tables were created. responses, timings, tokens.

Please try to create a survey containing large number of response columns (e.g. over 100 or 200) and redo all steps to test it.
Then you should be able to reproduce that error.

@TonisOrmisson
Copy link
Collaborator Author

Maybe you can add some test files to the tests/data/surveys folder so that this could be tested automatically. Eg a survey with too much columns for MyIsam. And a survey with too much columns for InnoDb.

@Shnoulle
Copy link
Collaborator

Shnoulle commented Apr 5, 2019

Maybe you can add some test files to the tests/data/surveys folder so that this could be tested automatically. Eg a survey with too much columns for MyIsam. And a survey with too much columns for InnoDb.

A survey with 10 000 column must broke for all DB ;) (else : tell me the DB to be used for such system)

@dominikvitt dominikvitt merged commit 4f97fb0 into LimeSurvey:develop Apr 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants