Problem/Motivation
The original problem was that SQLite has a variable limit of 999 for versions before 3.32.0 (core 10 requires SQLITE_MINIMUM_VERSION = '3.26'
) which is not configurable and which makes this database driver unusable for medium sized sites. The solution that we came up with is combining multiple inserts and updates in a single query, which makes SQLite a lot faster. The newer minimum required version of SQLite has a much higher variable limit and therfor it is no longer a problem in combination with Drupal. Only it makes multiple insert queries and multiple upsert queries a lot faster. See #2031261-124: Make SQLite faster by combining multiple inserts and updates in a single query. In the order of from 108k microseconds to 16k microseconds.
Proposed resolution
Combining multiple inserts and in a single query and combining multiple upserts and in a single query. For both queries is having more than 50 variables the limit for merging it into a single query.
Original report by @axel.rutz
SQLite performance Optimization: PDO::ATTR_EMULATE_PREPARES
Like we've done on Mysql and Postgres we should also do on Sqlite. See #827554: PostgreSQL performance Optimization: PDO::ATTR_EMULATE_PREPARES.
(As suggested by Damien Tournoud in #2028713-11: Menu router does "too many SQL variables" on SQLite resulting in silent nondisplay of menu items)
See #2028713: Menu router does "too many SQL variables" on SQLite resulting in silent nondisplay of menu items but this can bite us in any other place too.
A first patch that set PDO::ATTR_EMULATE_PREPARES on the connection (proposed by Damien Tournoud) did not work out probably due to a bug in the underlying driver. This can be reproduced as outlined in #2028713-18: Menu router does "too many SQL variables" on SQLite resulting in silent nondisplay of menu items:
php > $options = array(
php ( PDO::ATTR_EMULATE_PREPARES => true,
php ( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
php ( );
php > $dbh=new PDO('sqlite:dummy.sqlite', NULL, NULL, $options);
php > $dbh->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); // Give it another try.
php > $values = range(1,1111);
php > $placeholders = implode(',', array_fill_keys(array_keys($values), '?'));
php > $query = "select v from (select 0 v) where v not in ($placeholders);";
php > $stmt = $dbh->prepare($query);
PHP Warning: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1 too many SQL variables' in php shell code:1
Comment | File | Size | Author |
---|---|---|---|
#174 | 2031261-174.patch | 15.22 KB | Gunjan Rao Naik |
|
Issue fork drupal-2031261
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #1
geek-merlinPatch flying in for 7.x.
Comment #2
geek-merlinComment #3
geek-merlinPatch flying in for 8.x
Comment #4
geek-merlinAlso note #2028713-13: Menu router does "too many SQL variables" on SQLite resulting in silent nondisplay of menu items which indicates this is a win.
Comment #5
geek-merlinSetting prio to major as this fixes #2028713: Menu router does "too many SQL variables" on SQLite resulting in silent nondisplay of menu items, which makes drupal on sqlite unusable for sites with more than 999 menu entries.
THe patch itself is a nobrainer and mimics what we do in all other db drivers. See #827554: PostgreSQL performance Optimization: PDO::ATTR_EMULATE_PREPARES.
Comment #5.0
geek-merlinUpdated issue summary.
Comment #6
geek-merlinComment #7
geek-merlinImproved patch according to the issue summary flying in, first for 7.x
Comment #8
geek-merlinSame for 8.x
Comment #9
geek-merlinHuh, this still has issues, probably with quoting.
Comment #10
geek-merlin8: drupal-2031261-8.patch queued for re-testing.
Comment #11
geek-merlinComment #12
geek-merlinCompletely reworked patch flying in.
Comment #13
geek-merlinAnd the same for 8.x
Comment #14
xjmComment #15
xjm13: drupal-8.x-2031261-13.patch queued for re-testing.
Comment #16
mradcliffeThis is related to the new drupalci_testbot project, which stores simpletest data in sqlite. Discovered this when the postgresql test bot couldn't stuff all the errors into simpletest table.
Comment #17
ricardoamaro CreditAttribution: ricardoamaro commentedThe new drupalci_testbot project can use both options, installing via "drush" or "none". This last one runs tests with sqlite.
DCI_INSTALLER="none" # Try to use core non install tests. The other option is "drush".
so i'm running a test with :
Comment #18
jhedstromWould it be possible to write a test that illustrates the current failing behavior?
Comment #19
geek-merlinHere's some code to start with:
#2028713-18: Menu router does "too many SQL variables" on SQLite resulting in silent nondisplay of menu items
Comment #20
ybabel CreditAttribution: ybabel commentedpatch #12 worked for me ... at first
but then, after a drush cc all, I got errors on rules & WSOD
I tried drush rr but in vain.
If I remove the patch, the error disapear.
Comment #22
geek-merlinLet's try a test.
Comment #23
geek-merlinThis fix should do no harm to blobs.
(EDIT: which should fix #20)
Comment #24
geek-merlinjust for the records: 8.x core ran away and a git blame shows that our codebase has been changed (minorly) in:
* #2465633: Bring back the custom Statement class for the SQLite driver
* #2475247: SQLite: Fix views\Tests\Handler\FilterStringTest
* #2486831: The $dbh and $connection members are mixed up in Drupal\Core\Database\StatementPrefetch
...so we needed a reroll.
Some links:
* Sqlite meta issue: #2454513: [meta] Make Drupal 8 work with SQLite
Comment #27
geek-merlinImproved the test.
Comment #30
lilbebel CreditAttribution: lilbebel commentedI am having this issue with D8.1.x-dev
https://www.drupal.org/node/2746027#comment-11281037
This is really serious. Can someone please help? I have a site that needs to go live and now the thing has this major issue. I'm in a serious situation here having spend many many hours building the site to this point only for this to happen. There is no way I can start from scratch and need to know how to fix this.
Thank you.
m
Comment #31
daffie CreditAttribution: daffie commented@lilbebel: If this issue is so important to you, can you do a review.
Comment #32
lilbebel CreditAttribution: lilbebel commentedDaffie, thank you for comment. I cannot do a review as I am not a developer and it is beyond my skill set. I was referred to this page by a senior member of Drupal and advised to push the matter as it is serious. It won't only affect me. This is already established as being a major issue by senior developers. This is not just about me. This is a major issue that will affect many. The tone of your comment seems curt which is not helpful or appropriate. I am simply asking for help from those who know more than I do. If you did not intend it to sound so, I apologize. I wish that I could do such coding tasks but we are not all coders.
Comment #33
daffie CreditAttribution: daffie commented@lilbebel: It is normal for people on Drupal to work on issues that they find interesting to them or issues they want to get fixed. With that being the normal work ethic on Drupal, I suggested that you can help this issue by doing a review. I did not know your skill set and I was not out to be negative to you in any way. I am sorry if I came over to you in a negative way. Also I would like to mentioning that English is not my native language. So my expression in English is not always as good as I would like it to be.
Comment #34
cilefen CreditAttribution: cilefen commented@lilbebel English is my native language and I write things like #31 all the time. That is a normal part of working in an open source community. I did not interpret it as snarky at all.
Comment #35
lilbebel CreditAttribution: lilbebel commentedDaffie, I apologize. My bad. Sometimes, things come across differently in writing than they are intended. I am doing my best to try to find solutions and contribute but am not equipped to write patches and such. I have a theming and creative background. I would love to contribute more if I could.
My server provider looked into things on my end and, I don't know if it helps but, they said the following:
Maybe this information is relevant? If there is anything I can do to help, I am more than happy to.
Thank you all.
M
Comment #36
pwolanin CreditAttribution: pwolanin as a volunteer commented@lilbebel - if you are using MySQL then this issue is not relevant to you. You are using MySQL or sqlite as the database? In general I don't think sqlite is really thought to be suited for production sites.
Comment #37
lilbebel CreditAttribution: lilbebel commented@pwolanin - I'm using:
Database system SQLite
Database system version 3.8.10.2
On my dev desktop version, it would only allow me to use SQLite. Is it possible to change it now without redoing the site?
Many thanks.
M
Comment #38
daffie CreditAttribution: daffie commented@axel.rutz: I would like to help you get this issue fixed. If you work on the patch I will do the reviewing. What I found in the first review:
I am not a great fan of inline functions. I find them difficult to read. Do we really need 3 of them in the function getStatement().
Can you explain how this line of code works and why it is necessary.
Can we use KernelTestBase instead of UnitTestBase. KernelTestBase has already a database connection.
If somebody else wants to work on this patch that would also be great.
Comment #39
daffie CreditAttribution: daffie commentedLets move this to the SQLite driver.
Comment #40
geek-merlin@daffie, thanks for jumping in here.
I think all your comments make sense. BUT:
I'm struggeling with a much deeper problem, which may be completely unsolvable:
What i' trying here is doing the job of the DB driver to sanitize and insert variables into the query to overcome the limitations.
So in the above code block we need a way to handle both cases (string and blob) without the knowledge what we actually have.
So we have to
a) either find a way that works for both cases
b) or a robust check for string/blob
We might code a test first that writes some evil values to a table and checks they are written correctly.
So if you want to help, this is what is needed.
Comment #41
daffie CreditAttribution: daffie commented@alex.rutz: I think that you are right with that it is difficult/impossible to distinct between strings and BLOB's.
I have updated your test patch from comment #27 to use KernelTestBase. The problem is that it passes without any changes to core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php. So am I doing something wrong or is there no problem?
Comment #43
daffie CreditAttribution: daffie commentedI found out why the test where passing on my local machine. I am using Ubuntu and they have raised the value of SQLITE_MAX_VARIABLE_NUMBER to 250000. The default is 999 and that is the root cause of this issue.
Created a new patch with tests for integers, floats, strings and blobs. I also added a small change to the Statement class to see if it helps.
Comment #46
daffie CreditAttribution: daffie commentedThe tests only patch should fail. So increasing the number of variables to 2000.
Comment #47
daffie CreditAttribution: daffie commented@axel.rutz: Do you have any insight why the tests only patch is not failing?
Comment #48
mradcliffeThe testbots are also running Ubuntu. Could that be it?
Comment #49
daffie CreditAttribution: daffie commentedStatic variables should be addressed differently.
Comment #51
daffie CreditAttribution: daffie commentedThe tests are now fixed with the patch from comment #49.
New patch with the fix from comment #23 made by alex.rutz and the new tests.
Comment #53
daffie CreditAttribution: daffie commentedTests were not good: "Fatal error: Undefined class constant 'number_of_variables'".
Comment #54
daffie CreditAttribution: daffie commentedComment #57
daffie CreditAttribution: daffie commentedJust to make sure that the fix from comment #43 does not work.
The tests only patch from comment #54 is the one we need for further testing any possible fixes.
Comment #59
geek-merlinThanks @daffie for working on this!
So #54 fixes the original tests.
I think we need some more tests that check writing edge case strings and blobs.
(Remember that serialized PHP variables contain zero bytes.)
And maybe we just use this to decide string/blob quoting.
mb_check_encoding($s,"UTF-8")
(Also note that $dbh->quote() seems to be buggy for strings/blobs.)
If the above code is too heavy performance-wise we might count variables and only do userland quoting forthe variables >999...
Comment #60
daffie CreditAttribution: daffie commentedComment #61
mradcliffeI think
Unicode::validateUTF8
would work for this if Multibyte support is not available. It uses PCRE though.Comment #62
geek-merlin> I think Unicode::validateUTF8 would work for this if Multibyte support is not available.
aah rite, MB is optional.
then we can use this (i don't remember the stackoverflow link):
which returns different truth values for valid and invalid unicode.
Comment #63
daffie CreditAttribution: daffie commentedIf someone writes a patch for the fix, I will do the reviewing.
@alex.rutz: Can you give some more directions for the extra tests that you would like.
Comment #64
geek-merlinIf we don't have random blob/unicode generators in the test base class, this should really go there.
Some research on this:
* unicode - Really Good, Bad UTF-8 example test data - Stack Overflow
* unicode - Generate random UTF-8 string in Python - Stack Overflow
* unicode - Optimal function to create a random UTF-8 string in PHP? (letter characters only) - Stack Overflow
Comment #67
andypostThis blocks usage of *config_installer*
No very big site but have a 2429 variables, including config translations
Comment #69
andypostLooks last comments about utf-detection needs separate issue, let's make this issue focused of variables
Comment #71
andypostComment #72
jofitz CreditAttribution: jofitz at ComputerMinds commentedRe-rolled.
Comment #74
daffie CreditAttribution: daffie commentedI think that we should use a change of tactics to fix this problem. I think that we should split up a insert or update statement with a large number of variables in multiple statements with less then 999 variables each.
Comment #75
geek-merlin> I think that we should split up a insert or update statement with a large number of variables in multiple statements with less then 999 variables each.
This sounds like an interesting approach. Some thoughts:
* While this is not possible in all cases, i think it should be possible in all real-world cases.
* While this schould be quite easy with dynamic queries (
db_insert(...)->fields(...)
), it is quite difficult (needs a sql parser) with static queries(db_query()
).* Assuming that the problematic queries are dynamic ones, it's good enough to work on that layer.
Comment #76
geek-merlinSee:
* Insert::execute | Insert.php | Drupal 8.5.x | Drupal API / Insert::execute | Insert.php | Drupal 8.5.x | Drupal API
* Update::execute | Update.php | Drupal 8.5.x | Drupal API
Comment #78
davidwbarratt CreditAttribution: davidwbarratt for Sail Venice commentedI think this might be the cause of #3049948: SQLSTATE[HY000]: General error: 1 too many SQL variables: INSERT OR REPLACE INTO {cache_content} (cid, expire, created, tags, checksum, data, serialized)?
Comment #79
andypost@davidwbarratt yep, all of them face with limit
Comment #80
davidwbarratt CreditAttribution: davidwbarratt for Sail Venice commentedAh. Thanks.
Unfortunately the work-around doesn't work if you are using the Drupal Docker Image because there isn't a way to recompile PHP without starting an image from scratch. :(
Comment #81
andypostThat's a matter of sqlite configuration of build so vary per os package, you can always rebuild sqlite with needed options as workaround
Comment #82
phenaproximaI’m hitting this too. One possible mitigation—not a fix—that occurs to me is maybe we could make SQLite insert/update queries “batchable” under the hood. So, if you are about to run a query that exceeds 999 variables, the query is internally split up into two separate queries, 500 variables each, and executed one after the other. Not sure if this would work at all, or even be desirable, but it’s a thought.
Comment #83
andypost@phenaproxima not sure it will help because each distro has own limits (
SQLITE_MAX_VARIABLE_NUMBER
) and I found no way to get this limit at runtimeThe good news is that most of distros using to increase this limit to 250k
Comment #85
effulgentsia CreditAttribution: effulgentsia at Acquia commentedMoving this to 9.0.x to fix there first, then we can discuss backporting to 8.
Comment #86
effulgentsia CreditAttribution: effulgentsia at Acquia commentedHere's an approach that I think will work. Just posting the patch for now, and will follow up tomorrow with a comment explaining it.
Comment #87
andypostAs I'm using sqlite everyday I will prefer to have 999 is not hardcoded limit.
I don't wanna patch every app to replace this limit in code for sane OS I'm using or for docker php image
@effulgentsia interesting approach! Just a question of how to make it opt-in/opt-out
Comment #88
daffie CreditAttribution: daffie commentedWhen we create the connection to the SQLite database we can read the max variable limit and use that value instead of the 999 as the hardcoded value.
@effulgentsia: Great to see a new approach.
Comment #89
Gábor HojtsyIn #3107155: Discuss lowering SQLite version requirement from 3.26 to 3.22 in Drupal 9 we were discussing warning people (in system_requirements()) about the low variable limit. Looks like even with the workaround in place, performance would be more optimal if the variable limit would not be in place(?) If so, adding that warning alongside the workaround here would be best IMHO.
Comment #90
daffie CreditAttribution: daffie commented@effulgentsia: Great new solution idea!
Can we create a protected class variable for this?
Could we add some documentation about this line and what it does.
Can we use the json variable solution for this instead of using batches?
The limit of 999 variables for SQLite can be set higher. Lets change the test by getting the actual maximum number of variables from the database + 1 and use that number for testing.
Comment #91
daffie CreditAttribution: daffie commentedIf I add the following tests to Drupal\KernelTests\Core\Database\SelectTest::testLargeInCondition(), those extra tests should pass.
However they do not. See patch 2031261-91-nested-condition-should-fail.patch
The patch from @effulgentsia from comment #86 adds driver specific code to the Drupal\Core\Database\Query\Condition class.
The problem is that the database sub-system add the moment does not do driver specific conditions.
And we need that to fix this issue in the correct way. In #3113403: Make Drupal\Core\Database\Query\Condition driver overridable we make the condition driver overridable.
Added the patch 2031261-91-combined-with-3113403-16.patch to see that a combined patch fixes the problem.
Comment #92
daffie CreditAttribution: daffie commentedPostponing this issue on #3113403: Make Drupal\Core\Database\Query\Condition driver overridable.
Comment #93
BeakerboyIs there a minimum number of parameters that is considered universally acceptable? Microsoft SQL server has a limit of 2100. Would this driver also need extra parameter handling? I believe it currently performs some “emulate prepares” operations manually in order to overcome this limit. I’d like to simplify the driver wherever possible.
Comment #94
daffie CreditAttribution: daffie commented@Beakerboy: I do not think that will be enough. I am working on getting a testbot for custom database drivers. So that we can see what the problems are for your driver. These 2 issues are needed for such a testbot: #3109761: Allow custom db, php and chrome docker images from non-drupalci docker hub profiles and #3110803: Allow contrib modules to run the tests for Drupal core. Both are ready for a review and have an explanation of how to test the patch.
Comment #95
BeakerboyIs there a test for this somewhere? The driver is able to fully install core, and passes all but 2 database kernel tests, and it passes all of the Entity kernel tests. The two failures are related to casting varchar to binary fields. Are there other part of the test suite that I should run on my Travis-CI VM?
Comment #96
daffie CreditAttribution: daffie commented@Beakerboy: The problems are with the importing of configuration data. Not sure which test it is.
Comment #97
daffie CreditAttribution: daffie commentedSorry wrong issue. Please ignore.
Comment #98
daffie CreditAttribution: daffie commentedComment #99
daffie CreditAttribution: daffie commented#3113403: Make Drupal\Core\Database\Query\Condition driver overridable has landed.
Comment #100
daffie CreditAttribution: daffie commentedReroll needed.
Comment #101
daffie CreditAttribution: daffie commented#3113403: Make Drupal\Core\Database\Query\Condition driver overridable has been unlanded.
Comment #102
Beakerboy#3113403 is ready for review again, if anyone wants to keep moving this forward.
Comment #103
daffie CreditAttribution: daffie commented#3113403: Make Drupal\Core\Database\Query\Condition driver overridable has landed.
Comment #104
daffie CreditAttribution: daffie commentedRerolled the patch.
Comment #106
daffie CreditAttribution: daffie commentedComment #107
daffie CreditAttribution: daffie commentedBack to 9.0.x, because #3113403: Make Drupal\Core\Database\Query\Condition driver overridable has been landed on 9.0.x
Comment #108
daffie CreditAttribution: daffie commentedComment #109
daffie CreditAttribution: daffie commentedUsed the same trick for upsert queries as @effulgentsia used for the select queries.
Comment #110
effulgentsia CreditAttribution: effulgentsia at Acquia commentedNice!
What do you think of this, as a way to make the execute() method clearer?
Comment #111
daffie CreditAttribution: daffie commented@effulgentsia: Yes, you are right your changes to the execute() method are an improvement. Thanks. What else needs to be done to get this issue committed?
Comment #112
jungleWould like to have an 8.8.x patch to test against with.
Comment #114
jungleFix coding standards only in #110
(Wrong interdiff file extension, sorry!)
Comment #115
junglemissed one
Comment #116
daffie CreditAttribution: daffie commentedAdded testing that counts the number of placeholders used in the query.
@jungle: Thanks for the coding standards errors.
Comment #117
daffie CreditAttribution: daffie commentedMinor fix.
Comment #118
daffie CreditAttribution: daffie commentedTo answer my own review from comment #90:
For #90.1: Lets keep 50 as a sensible default.
For #90.2: Done.
For #90.3: Done.
For #90.4: Added testing that the queries one use one placeholder.
For #90.5: Was not necessary.
The patch is ready for a review from somebody else.
Comment #120
daffie CreditAttribution: daffie commentedBack to needs review
Comment #121
andypostIt needs profiling because more code executed each query
Also contrib fallback driver could be another workaround
Comment #122
xjmLooks like we can go all the way back to 8.9.x with this as well based on #3113403: Make Drupal\Core\Database\Query\Condition driver overridable.
Comment #124
daffie CreditAttribution: daffie commentedThe XHProf testing for the patch contains 2 parts: one for the select query and the second for the upsert query.
XHProf testing the select query
The part of the code that I used for XHProf testing the select query:
I ran the XHProf testing 5 time with and without the fix. For the select testing without the patch, I removed the method
Drupal\Core\Database\Driver\sqlite\Condition::compileValueList()
.The median result for XHProf testing with the patch is:
The median result for XHProf testing without the patch is:
My conclusion is that the select test with the patch is significantly faster.
XHProf testing the upsert query
The part of the code that I used for XHProf testing the select query:
I ran the XHProf testing 5 time with and without the fix. For the upsert testing without the patch, I removed the method
Drupal\Core\Database\Driver\sqlite\Upsert::execute()
.The median result for XHProf testing with the patch is:
The median result for XHProf testing without the patch is:
My conclusion is that the upsert test with the patch is significantly faster.
For both the select testing and the upsert testing is the solution with the patch significantly faster.
Comment #125
geek-merlinSo the patch speeds up upsert and select queries by factor 5-8? Amazing.
In a followup let's factor out this code and see if it can help other drivers.
At least it can help with #1210606: Document that operations that delete in bulk can hit limits for the number of arguments.
Comment #126
andypostGreat news! 3.32 released and brings limit increase to 32766, also new opcache for prepared statements https://sqlite.org/releaselog/3_32_0.html
Comment #127
BeakerboyMicrosoft SQL Server has a limit of 2100 parameters. One way the driver gets around this is is performs upsert queries in batches and within a transaction. If each statement has 10 fields, then the batch size is 200 statements.
Comment #128
daffie CreditAttribution: daffie commented@Beakerboy: Can you use the solution from this issue for the SQL Server?
Comment #129
BeakerboyI’ll have to look at the patch closer so see how it works. I don’t get it, but I’ve never used json in sql before.
The large IN clause test will work on SQL Server because it uses EMULATE_PREPARES when a SELECT statement has >2100 parameters.
Hopefully someone has filed a bug report with the PHP group regarding the PDO EMULATE bug. I found a PDO but with the way it manages the ESCAPE part of LIKE statements. They said the fix would have to wait for PHP8!
Comment #130
andypostIt could use follow-up to make 50 configurable via connection options, often it much easier to build sqlite for own needs in docker image this days
Comment #131
daffie CreditAttribution: daffie commentedComment #132
daffie CreditAttribution: daffie commentedProfiling has been added.
Comment #134
jungleThe default value is 32766 nowadays. So should this be a won't fix?
(Edited: @andypost mentioned it in #128 already)
Comment #135
daffie CreditAttribution: daffie commented@jungle I would still very much like land this issue. I know that 32766 is a high number, only the patch fixes it for any number of variables.
Comment #136
jungleThanks, @daffie. If so, I think the test needs updating, the default is not always 999. It might be 32766.
Comment #137
daffie CreditAttribution: daffie commentedBecause #3159073: Use the new UPSERT capability from SQLite 3.24 landed, the patch needed to be rerolled and updated (the query changed).
@jungle: The default limit of 999 placeholders is the current limit for the minimum supported version of Drupal. It will probably change in D10. Only that is still more then a year from now and it is also not that important as the test makes sure that the query one uses 1 placeholder. The other reason why I would like this patch to land is because when working with config queries, they are with this patch a lot quicker. See comment #124. Could I interest you in doing a review of the patch?
Comment #138
andypostAdditionally to #134 not clear why
ATTR_EMULATE_PREPARES
makes sense to use (pgsql and mysql drivers using it) for sqlite.Original bug is fixed via unbundling of sqlite in PHP 7.4 https://bugs.php.net/bug.php?id=79269
The related still needs work https://bugs.php.net/bug.php?id=79272 (reproducible)
moreover the error message has change in php8 https://3v4l.org/oke3S
Comment #141
SHIJU JOHN CreditAttribution: SHIJU JOHN at Cognizant Technology Solutions commented#137 is failing in 9.3.x branch. Is there any latest patch available for this?
Comment #142
quietone CreditAttribution: quietone at PreviousNext commentedNeeds a reroll
Comment #143
karishmaamin CreditAttribution: karishmaamin at Specbee commentedRe-rolled patch against 9.4.x
Comment #144
BeakerboySeveral phpcs failures
Comment #145
karishmaamin CreditAttribution: karishmaamin at Specbee commentedFixed coding standard failures
Comment #147
NitinSP CreditAttribution: NitinSP commented#145 is failing for drupal 9.4.0-rc2 version. Please let me know if any other patch is compatible with 9.4.0-rc2.
Comment #148
_pratik_ CreditAttribution: _pratik_ as a volunteer and at Specbee for Drupal India Association commentedComment #149
_pratik_ CreditAttribution: _pratik_ as a volunteer and at Specbee for Drupal India Association commentedTry this patch, rerolled for version above 9.4.0
Comment #150
_pratik_ CreditAttribution: _pratik_ as a volunteer and at Specbee for Drupal India Association commentedMoving for review.
Thanks
Comment #151
_pratik_ CreditAttribution: _pratik_ as a volunteer and at Specbee for Drupal India Association commentedComment #152
_pratik_ CreditAttribution: _pratik_ as a volunteer and at Specbee for Drupal India Association commentedComment #153
pooja saraah CreditAttribution: pooja saraah at Srijan | A Material+ Company for Drupal India Association commentedFixed failed commands on #152
Attached patch against Drupal 9.5.x
Comment #154
pooja saraah CreditAttribution: pooja saraah at Srijan | A Material+ Company for Drupal India Association commentedComment #156
quietone CreditAttribution: quietone at PreviousNext commentedThought I would fix the tests.
This patch fixes two namespaces errors, adds types to some @params and adds a constructor in \Drupal\sqlite\Driver\Database\sqlite\Upsert to remove the return option.
Comment #158
daffie CreditAttribution: daffie commentedComment #161
mondrakeChanged to MR workflow and split tests into driver specific ones.
Comment #162
andypostIS needs actualization
- limit in 999 affects only few distros, the most of them has it 250000+
- profiling in comment#124
- is this still a bug?
Comment #163
daffie CreditAttribution: daffie at Finalist commentedI have updated the IS.
I have changed the issue to a task as it is no longer a bug.
All code changes look good to me.
Testing has been added.
For me it is RTBC.
2mondrake: Thank you for working on this.
Comment #164
alexpottThe code talks about the 999 limit yet #162 disputes this.
What is the actual minimum limit or our current minimum version?
Comment #165
andypostThe tricky moment is that real value defined by distro and default value which is 32766 since https://sqlite.org/releaselog/3_32_0.html see #124 is only could be found when someone has build sqlite and php himself
Comment #166
alexpottSo I think we should have a setting that's based on SQLITE_MAX_VARIABLE_NUMBER - we set it to the current default 32766 and do things based on that number rather than the 999.
Also are we sure about
Reading the docs - it does not say that the max can be lowered at compile time... https://sqlite.org/limits.html#max_variable_number
Can someone give an example of a distro with a default lower than 32766 on an sqlite 3.32 or above...
Comment #167
alexpottOh I'm wrong... see the compile time options here - https://www.sqlite.org/compile.html#_options_to_set_size_limits
So yeah I think we should introduce a setting that defaults to the default upper bound. And use that to work out how to chunk queries. And have a status report where we check the DB value and the setting value and ensure that they match. We can get the MAX_VARIABLE_NUMBER by doing a
PRAGMA compile_options;
query and parsing the output. Fun. Maybe there is a better way.Comment #168
alexpottFor me locally
MAX_VARIABLE_NUMBER=500000
which is much higher than the default max /shrug.Comment #169
andypostI recall @effulgentsia did research per distros and it was near 200k but since that new versions released
++ To read real value from pragma
Comment #170
andypostupdated IS with a link to variable limit
On Ubuntu 22.04
MAX_VARIABLE_NUMBER=250000
On Fedora 31 there's no option displayed so it could fallback to default
Also #138 has link to https://bugs.php.net/bug.php?id=79272 which is unresolved yet
Comment #171
daffie CreditAttribution: daffie at Finalist commentedFor some reason the patch does not make the testbot run any faster.
HEAD 10.0.x 58 min https://dispatcher.drupalci.org/job/drupal8_core_regression_tests/70540/
With patch 58 min https://dispatcher.drupalci.org/job/drupal_patches/153946/
Comment #172
effulgentsia CreditAttribution: effulgentsia at Acquia commented#3107155-14: Discuss lowering SQLite version requirement from 3.26 to 3.22 in Drupal 9 has the summary of my research from 3 years ago, and based on that, I think we might still be in a situation where Drupal 10 on PHP 8.1 on RHEL/CentOS 8 with SQLite 3.26 would still have a 999 limit. We could check that to make sure, since who knows, maybe that's changed?
Comment #173
effulgentsia CreditAttribution: effulgentsia at Acquia commentedBack then I opened https://bugzilla.redhat.com/show_bug.cgi?id=1798134 asking RedHat to compile with a higher value and they closed it as won't fix.
Comment #174
Gunjan Rao Naik CreditAttribution: Gunjan Rao Naik commentedAdded patch against #156 in 10.1.x version
Comment #176
andypostPDO::ATTR_EMULATE_PREPARES
is fixed in PHP 8.1.22/8.2.9/8.3-dev https://github.com/php/php-src/commit/e0aadc1c0daee1473c77d8794ce0121826...Probably needs separate issue