Repository navigation
Devops: Run-state check that lists every write to a compiled query during a run - #3105
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2596, and only its first step, find every write. It does not close the issue.
What is in the PR
A test tool,
test/runstate/, and nothing undersrc/. It runs the suite and lists every place that writes to a compiledqueryobject, or to one of its sources, while a statement runs. That list is the work list for step 2 of the issue, where each run gets its own object.test/runstate/record.jsis a preload forbun test. It wrapsSelect.prototype.compileand changes the query object and its sources in place when a compile returns, so that a write is recorded and then done as before.test/runstate/run.jsruns the suite with it and turns each place indist/alasql.fs.jsinto a file and a line insrc/.yarn test-runstatebuilds and prints the list.test/runstate/README.mdsays how to read it and what it does not see.The issue suggests
Object.freezein a test build. A frozen object throws at the first write, so a run shows one write and then stops, and the engine has to be changed to try it. The recorder lets every run finish and needs no test build. The suite gives the same answer with it, 2723 pass, 213 skip, 0 fail.No new dependency.
package.jsongets one script line,.gitignoreone folder. The check is not in CI, because the list is not empty yet. After step 2 it is expected to be empty and can become a job then.The list
From
bun test/runstate/run.js --compileon this branch. The columns are the property, the place that writes it, the first test file that made the write, and the line as it is in the bundle.[]after a name is a write inside an array the compile made. When several source lines have the same text, the nearest is given and the others are in brackets.In short, a run writes 24 properties of the query object from 60 places and 8 properties of a source from 15 places.
src/select/queryfn.js, the per-run notepad the issue describes (params,data,groups,xgroups,scope,cb,sourceslen,source.data,source.ix).modifieris written on the query of a subquery, of a UNION part, and of the SELECT inside INSERT, UPDATE, DELETE and SET, each time the outer statement runs. These are writes to another statement's compiled object, so step 2 has to cover them as well as the query's own fields.queriesfnis copied from the outer query to the subquery of a source during a run (src/select/from.jsline 22), which is Give each SELECT its own list of subqueries from parsing on #2666.subqueryCacheis written by the code forIN (subquery)(src/expression/expression.jslines 338 and 373), andremoveKeys,columnsandexplainationget items pushed during a run, so they grow with every run of a cached statement.statement.query.data = []incleanupCache(src/engine/core.jsline 318) is the cleanup the issue says step 2 makes unneeded.The last block is not run state. It is a parent compile that changes the query of a subquery that is already compiled. It is listed because step 2 will meet it.
Write sites the suite does not reach
The recorder only sees code that a test runs. A text search for assignments to
query.andsource.in the files above gives these places that no test reached. I did not write tests to reach them.src/select/queryfn.js454query.removeKeys.push('$$hashKey'), only whenangularis definedsrc/select/queryfn.js662, 664, 667, 708, 739source.ixandsource.datain the index branches ofpreIndexsrc/select/pivot.js43query.columns = []when PIVOT has no rowssrc/select/dojoin.js179 to 183, 191, 192query.sourcesThree more places write inside a value that a run assigned, so they are not shared state by themselves and are not in the list. They are
query.queriesdata[-idx - 1](queryfn.js104),query.joinat[h](dojoin.js80) andquery.columns.push(nc)(pivot.js251).source.data[i] = dataw(queryfn.js626, 681, 732) writes into the array a source handed out, which can be the data of a table.What the check does not see
delete query.x.yynodes, Review #2534 for code improvements: parameters for subqueries in UPDATE #2632) and to the statement function (statement.running, the guard of fix: resolve Promise.all concurrent query collision with identical SQ… #2465 and Give each run of an alasql.compile() statement its own copy while another run is still going #2747).Parity differences
None. No file under
src/and nothing in the build changes, and the parity job of this PR gives 0 differences in 78,515 aligned statements (result 0, error 0, params 0, generated code 0, only in one recording 0, diverged 0), 0 changed API paths of 1,718, and the same sizes.The next step, not started
Step 2 of the issue. Give each run
Object.create(query)and the same for each source, including the queries of subqueries and UNION parts that the list shows, then remove the guard of #2465 and #2747 andcleanupCache, add the tests the issue names, and run this check until the list is empty.