Feature #6083
schema (.df) changes in incremental conversion mode should only reconvert those programs that reference the changed schema
100%
Related issues
History
#1 Updated by Greg Shah over 4 years ago
Some schema changes may not affect all programs in an application. Optimally, this would be limited to those programs that reference a given table (including any field change/add/delete or index change/add/delete or any table-level option change/add/delete) or sequence which is changed. The idea is that most schema changes only affect a small amount of the application yet we force a full reconversion. Let's not do that.
#2 Updated by Greg Shah about 1 year ago
- Related to Bug #10208: do not convert the schema in incremental mode if it hasn't changed added
#3 Updated by Greg Shah about 1 year ago
- Assignee set to Dănuț Filimon
In addition to calculating the non-schema dependencies for incremental mode, whatever changes to the schemata have been made must be reflected in running M0 on those changes (and only those changes).
#4 Updated by Dănuț Filimon 12 months ago
- Status changed from New to WIP
Created 6083a from latest trunk/16087.
#5 Updated by Dănuț Filimon 12 months ago
Note: Everything I mention will consider the implementation from 10208a to be part of this task.
Even if there are changes made to the schema, the incremental conversion will not pick up any file if there are no source changes. I propose that duringTransferDriver.executeJob() we do the following:
- Mode the schema check before
depFilesis populated so thatschemasChangedwill contain the schemas that were modified. - In each converted <file>.ast we have access to
db_referencesannotation andBUFFER_SCOPEast nodes that contain the name of the database and tables, maybe we can use this information to find if the changed table from the schema is among them. But there should be cases where incremental conversion should not reconvert files even if the changed table is among them: - Adding/Deleting a field/index/sequence/trigger that is not used
- How to determine what table/sequence was changed? I suggest using ConversionData to store information about the table, we can compute a hash for each table depending on the fields and options, indexes, and triggers. The same thing should be done to sequences.
#6 Updated by Dănuț Filimon 11 months ago
- When we have changed schemas, I iterate over the ones that are modified and call
loader.getModifiedSchemaTables(changed)to get the set of tables and sequences that were modified. The set can be empty, meaning that no table or sequence was modified and in this case we can remove the schema fromschemasChangedcollection. We store the non-empty sets in a mapMap<String, Set<String>> schemaTablesChanged = null;. - In ConversionData, I created a new table called table_signature with two fields
table_sigandhash(I will need to store the type - table/sequence and create a constraint next). AddedsaveSchemaTableHash()method to insert into the table,isSchemaModified()method to check if there are matching records in the table andcontainsModifiedSchemaTable()method that will check if a file uses a schema and contains any of the modified tables/sequences. To check if a file needs to be reconverted,db_referencesannotation is checked to confirm the schema is used and then allBUFFER_SCOPEnodes at the first level are searched in the set of modified tables.
- I am calculating the table hash and overriding before I can compare it
- No difference between sequences/tables stored.
- Even if a sequence is changed, there's no need to reconvert a file for this.
#7 Updated by Dănuț Filimon 11 months ago
Dănuț Filimon wrote:
Issues:
- I am calculating the table hash and overriding before I can compare it
I have the dict files available and I can load them, I was using importSchema() which saved new hash values. This fixes the issue.
#8 Updated by Dănuț Filimon 11 months ago
Rebased 6083a to latest trunk/16124.
#9 Updated by Dănuț Filimon 11 months ago
- % Done changed from 0 to 80
Committed 6083a/16125. Keep track of modified tables in incremental conversion.
I've noticed that during conversion, all tables from the hotel schema are considered modified because I am using the hashCode() method on a ProgressAst instance. I need a reliable way of calculating the hash code for such asts to wrap up the implementation.
#11 Updated by Dănuț Filimon 11 months ago
Greg Shah wrote:
We could calculate the checksum for the original input text for that table. That would be more consistent with our file-based approach for source code (and presumeably with the file-based approach we take to the
.dfchecking).
This should work.
Another issue I noticed:- same table name, but different databases. This will not work out with the current implementation when inserting into table_signature. The solution will be to store the database and table name and create a primary key for those two fields.
#12 Updated by Dănuț Filimon 11 months ago
- The original text of the table, e.g.:
guest - The db_signature of the table (annotation of the TABLE node)
- A way to determine is the table/field/index properties were changed (AREA, DESCRIPTION, DUMP-NAME, FORMAT, INITIAL, LABEL, POSITION, MAX-WIDTH, COLUMN-LABEL, ORDER, UNIQUE, PRIMARY, INDEX-FIELD, ASCENDING, DESCENDING) - this is the problem
#13 Updated by Dănuț Filimon 11 months ago
Dănuț Filimon wrote:
To calculate the checksum for a table, we need:
- The original text of the table, e.g.:
guest- The db_signature of the table (annotation of the TABLE node)
- A way to determine is the table/field/index properties were changed (AREA, DESCRIPTION, DUMP-NAME, FORMAT, INITIAL, LABEL, POSITION, MAX-WIDTH, COLUMN-LABEL, ORDER, UNIQUE, PRIMARY, INDEX-FIELD, ASCENDING, DESCENDING) - this is the problem
I've come up with this method and placed it in AstManager
public int computeAstHash(Aast ast)
{
int result = ast.getType();
if (ast.getText() != null && !ast.getText().isEmpty())
{
result = 31 * result + ast.getText().hashCode();
}
for (int i = 0 ; i < ast.getNumImmediateChildren(); i++)
{
result = 31 * result + computeAstHash(ast.getChildAt(i));
}
return result;
}
Starting from the ast type, avoid computing the hash when there is no text or "", iterate all immediate children to get the correct hash.
The hash is correct in the end, but the problem I noticed it that even if I change a table it will give the old hash (because I did not load the new schema yet).
I end up with this problem:- The old hash will be used because I did not load the new schema yet.
- I can't run the SchemaLoader because I will override the old hashes.
#15 Updated by Dănuț Filimon 11 months ago
Greg Shah wrote:
If we are operating on the original text from the
.dfthen we would NOT be calculating any changes in the AST.
I am working with the dict files and not the df file. I already know that the schema file was modified (10208a changes), so I am trying to determine what table was modified after the modified schema is processed into a dict file during incremental conversion.
#16 Updated by Greg Shah 11 months ago
The original detection of a change to the .df might just be from whitespace changes or ordering differences (content is the same but in different order). Processing based on the ASTs will not necessarily match the same results, when a user might expect it to do so.
We could extend our checksum processing to calculate checksums of sections (e.g. a table and all its fields/indexes) of the .df instead of calculating the checksum for the entire file.
#17 Updated by Dănuț Filimon 11 months ago
So one section will be like this:
ADD TABLE "guest" AREA "Schema Area" DESCRIPTION "Guest staying in a room" DUMP-NAME "guest" ADD FIELD "stay-id" OF "guest" AS integer FORMAT "->,>>>,>>9" INITIAL "0" LABEL "Stay ID" POSITION 2 MAX-WIDTH 4 COLUMN-LABEL "Stay ID" ORDER 10 ... ADD INDEX "stay-order" ON "guest" AREA "Schema Area" UNIQUE PRIMARY INDEX-FIELD "stay-id" ASCENDING INDEX-FIELD "order" ASCENDINGand so on. We'll use ConversionData to calculate the checksum, save it and retrieve it during incremental conversion.
#19 Updated by Dănuț Filimon 11 months ago
- Status changed from WIP to Review
- % Done changed from 80 to 100
- reviewer Greg Shah added
The only issue that I can see right now, is that the last table parsed will contain the df footer:
. PSC cpstream=ISO8859-15 . 0000010674
I've committed 6083a/16126 where I implemented #6083-16 and simplified the process. I also switched from iterating and checking BUFFER_SCOPE nodes to simply checking the table_list annotation which contains all tables used in the file. If the above is not a big problem, this branch can be reviewed.
#21 Updated by Dănuț Filimon 11 months ago
Greg Shah wrote:
The only issue that I can see right now, is that the last table parsed will contain the df footer:
That must be fixed otherwise the last table may always be detected as changed. The
.can be used to detect the footer and avoid futher checksumming.
Good point, I committed 6083a/16127.
#23 Updated by Dănuț Filimon 11 months ago
- Related to Bug #7793: incremental conversion with deleted table from .df added
#24 Updated by Dănuț Filimon 11 months ago
Rebased 6083a to latest trunk/16147, the branch is now at revision 16154.
#27 Updated by Alexandru Lungu 10 months ago
Danut, can you document which changes are mandatory for customer projects once 6083a gets into trunk?
#28 Updated by Dănuț Filimon 10 months ago
Alexandru Lungu wrote:
Danut, can you document which changes are mandatory for customer projects once 6083a gets into trunk?
There's #10536-1 and the required changes for some projects in #10536-5. All projects will need to have their configuration updated, because name_map.xml will be defaulted to the cvt folder.
Summary of the configuration changes:- name_map.xml must be included in the <project>/build/classes/ and be part of the jar, it will no longer be placed in both the project root and src/<pkgroot>
- name_map.xml no longer needs to be deleted since deleting the cvt folder will also delete the file
- ensure the cvt folder is created by the prepare target (not all projects require this)
EDIT: additional change
#29 Updated by Constantin Asofiei 10 months ago
- Related to Bug #10613: Incremental conversion issue: temp-table dmo does not get converted added
#30 Updated by Constantin Asofiei 10 months ago
- Related to Bug #10626: DMO names can collide on case-insensitive file-system added
#31 Updated by Greg Shah 10 months ago
- Related to Bug #10639: Incremental conversion - unexpected DMO generation for space-only changes added
#33 Updated by Dănuț Filimon 10 months ago
Greg Shah wrote:
I have reconsidered the
name_map.xmlchanges. It was my mistake to force that into this task. Please separate that change into another task (and branch). This will make 6083a a non-breaking change which can be tested and merged safely and quickly.
I'll make the necessary changes. The changes are not that complex, so I don't think there will be a need for regression testing.
#34 Updated by Dănuț Filimon 10 months ago
Dănuț Filimon wrote:
Greg Shah wrote:
I have reconsidered the
name_map.xmlchanges. It was my mistake to force that into this task. Please separate that change into another task (and branch). This will make 6083a a non-breaking change which can be tested and merged safely and quickly.I'll make the necessary changes. The changes are not that complex, so I don't think there will be a need for regression testing.
Committed 6083a/16223. I also had to reintroduce some changes to copy the name_map.xml to the right project location when deleting the mappings.
#35 Updated by Dănuț Filimon 10 months ago
- Related to Feature #10685: Move name_map.xml to the cvt folder added
#37 Updated by Dănuț Filimon 10 months ago
Greg Shah wrote:
Code REview Task Branch 6083a Revision 1622
I'm fine with the changes.
Please do enough testing to confirm it is safe.
Only incremental conversion needs to be tested, to ensure mappings from name_map.xml are removed properly. I'll go with ETF, ChUI and another small customer application.
#38 Updated by Dănuț Filimon 9 months ago
Committed 6083a/16224. Fixed file copy and file separator.
#40 Updated by Alexandru Lungu 9 months ago
- Status changed from Internal Test to Merge Pending
You can merge 6083a to trunk now.
#41 Updated by Dănuț Filimon 9 months ago
- version_resolved set to trunk/16220
- Status changed from Merge Pending to Test
Branch 6083a was merged to trunk revision 16220 and archived.