Project

General

Profile

Feature #11404

Implement annotation-based resolution for database dependencies.

Added by Octavian Adrian Gavril 7 months ago. Updated 3 days ago.

Status:
Review
Priority:
Normal
Target version:
-
Start date:
Due date:
% Done:

50%

billable:
No
vendor_id:
GCD
case_num:
version_reported:
version_resolved:
production:
No
env_name:
topics:

Related issues

Related to Conversion Tools - Feature #9638: resolve OO dependencies during parsing using annotations in already converted classes Review
Related to Conversion Tools - Feature #6320: sharded schemata WIP
Related to Conversion Tools - Feature #9639: centralized name management (and conversion) OR jar based resolution New

History

#1 Updated by Octavian Adrian Gavril 7 months ago

  • Related to Feature #9638: resolve OO dependencies during parsing using annotations in already converted classes added

#2 Updated by Octavian Adrian Gavril 7 months ago

The goal here is to stop relying on the file system for database info during conversion.

This was discovered while working on #9638. The current implementation uses P2OLookup instances to solve such dependencies, recursively. Since that task deals with classes already packed into jars, we don’t have access to the original artifacts or ASTs to grab the database details we need.

Eliminating all .p2o usage for both the app-by-app and full conversion cases is preferred.

#3 Updated by Greg Shah 7 months ago

This is relatred to app-by-app conversion. Anything related to the lookup or processing of database/temp-tables that are defined in another "app" (a.k.a. module) must come from the jar instead of the file system since those features will not be present locally or won't be part of the current conversion run even if they are present locally.

#4 Updated by Ovidiu Maxiniuc 7 months ago

This process is similar (if not identical) to that from MetadataManager.populateFileTable() which scans the dmo structure and populates the _file, _fields, _index and relate metas. So we have this information in-memory as H2 database. I wonder if we can (if it is feasible from performance PoV) we use queries on this database during conversion?

Note: these VSTs are R/O during FWD server lifetime, but during conversion they will have to be writeable to accommodate the new table definitions.

#5 Updated by Constantin Asofiei 7 months ago

Ovidiu Maxiniuc wrote:

This process is similar (if not identical) to that from MetadataManager.populateFileTable() which scans the dmo structure and populates the _file, _fields, _index and relate metas. So we have this information in-memory as H2 database. I wonder if we can (if it is feasible from performance PoV) we use queries on this database during conversion?

Note: these VSTs are R/O during FWD server lifetime, but during conversion they will have to be writeable to accommodate the new table definitions.

And temp-table definitions. I don't think we can do that. We need to abstractize the P2OLookup and other cases of dependencies on .ast, where we determine which temp-tables to load from super-classes.

#6 Updated by Ovidiu Maxiniuc 7 months ago

I was thinking mostly of 'provided' dmos from a previous iteration of an app-by-app conversion. There are no .ast provided. The conversion will have to work with what it 'finds' in the classpath, if I get this right.

#7 Updated by Greg Shah 7 months ago

Ovidiu Maxiniuc wrote:

I was thinking mostly of 'provided' dmos from a previous iteration of an app-by-app conversion. There are no .ast provided. The conversion will have to work with what it 'finds' in the classpath, if I get this right.

Correct. Ultimately, when we support shared schemata, then the permanent DMOs may be split across jars and be the source of this kind of schema info.

#8 Updated by Greg Shah 7 months ago

#9 Updated by Greg Shah 7 months ago

  • Related to Feature #9639: centralized name management (and conversion) OR jar based resolution added

#10 Updated by Octavian Adrian Gavril 6 months ago

  • Assignee set to Octavian Adrian Gavril
  • Status changed from New to WIP

#13 Updated by Octavian Adrian Gavril 12 days ago

I am starting the work in 11404a (trunk 16836) with the part of this task which does not depend on 9638a.

The case this task was opened for is already covered by 9638a (revision 16837). A database or a temp-table which an earlier run converted is described from the DMO annotations in its jar, without any .p2o. What remains here is the database .p2o, the .dict and the import without TRPL, as agreed in #6320-23.

9638a also changes how the current run handles its own schemas. A schema which the run converts is handed to the later phases in memory, so the conversion no longer reads it back from disk. The temp-tables of a source file get no .p2o file at all. The .p2o of a database is still written, because the import and the word reindex are run with it and the runtime conversion of dynamic queries (ConversionPool) loads it from the application jar.

The database tools are the part which can be done before 9638a is merged, since neither 9638a nor 6320a touches them. Today import.xml and word_reindex.xml run as TRPL rule sets over the .p2o of the database. These rule sets only collect, per table, what ImportWorker needs, and nearly all of it is already in the DMO annotations. I will present the plan for this part as soon as it is ready.

The rest of the task starts once 9638a is merged, since it builds on the in-memory schema description which 9638a adds:
  • The parser stops reading the .dict (SchemaDictionary).
  • The runtime conversion of dynamic queries stops loading the database .p2o and .dict (ConversionPool).
  • The schema conversion describes the schema without the .p2o AST (P2OLookup, DataModelWorker, SchemaWorker), so the database .p2o is no longer written.

#14 Updated by Octavian Adrian Gavril 12 days ago

11404a revision 16837 replaces the TRPL rule sets of the data import, the word reindex and the FTS migration with ImportWorker.main, which reads the DMOs of the application jar instead of the .p2o of the database. It has three modes, selected with -mode:
  • import (the default) loads the .d dump, creates the indexes and sets the sequences.
  • wordReindex repopulates the word tables.
  • ftsMigrate replaces the word tables with full-text search columns.

The arguments keep the names the rule sets had, passed as -name value pairs. The modes are documented in the class javadoc of ImportWorker.

The indexes defined in the schema hints were the only data missing from the DMO, since they existed only in the .p2o. They are now written to the Indices annotation with synthetic = true, which the runtime ignores. A project with such indexes has to reconvert its schema before importing with this FWD.

import.xml, word_reindex.xml and reindex.xml are removed, and import.sh, word_reindex.sh and fts_migrate.sh now launch ImportWorker with their options unchanged.

The import targets of every project's build_db.xml have to run ImportWorker instead of schema/import, otherwise ant import.db fails with an FWD which includes 11404a. The H2 target becomes:

The PostgreSQL and MariaDB targets change the same way. The change of the testcases project is ready and I will commit it when 11404a is merged. The greenfield template in the fwd-dev plugin needs it too.

I validated 16837 against trunk 16836: the import, the word reindex and the FTS migration give the same databases on H2 and PostgreSQL. The Hotel GUI sample also imports correctly with the changed build_db.xml.

Four standalone rule sets still read the .p2o of a database. They are dead code: nothing in FWD calls them, and neither the testcases project nor the greenfield template uses them.
  • generate_ddl.xml and generate_seq_ddl.xml generate DDL which the conversion already generates, and still depend on Hibernate.
  • data_analyzer.xml runs only in the length mode of ConversionDriver, which warns that it is not in use and not maintained.
  • rpt_data_length.xml reports the output of data_analyzer.xml and has no caller.

Can I remove these four rule sets, together with the code only they use (the length mode and the unused generateDDL method of ConversionDriver)?

The rest of the task has to wait until 9638a is merged. It either changes code which 9638a changes, or builds on the description of a schema from its DMOs which 9638a adds:
  • The parser reads the schema of a database without the .dict (SchemaDictionary, SchemaLoader).
  • The runtime conversion of dynamic queries reads the schema from the DMOs, instead of loading the .p2o and the .dict from the application jar (ConversionPool).
  • The schema conversion describes the schema without the .p2o AST, so the .p2o of a database is no longer written (P2OLookup, DataModelWorker, SchemaWorker).

#15 Updated by Octavian Adrian Gavril 11 days ago

  • % Done changed from 0 to 50

#16 Updated by Greg Shah 11 days ago

  • Status changed from WIP to Review
  • reviewer Eric Faulhaber, Ovidiu Maxiniuc added

Yes, remove the dead code. We've carried it long enough.

This needs a review now from Eric and Ovidiu.

#17 Updated by Octavian Adrian Gavril 11 days ago

11404a revision 16838 removes the dead code:
  • The rule sets generate_ddl.xml, generate_seq_ddl.xml, data_analyzer.xml and rpt_data_length.xml.
  • import_util.rules, which only these rule sets included.
  • The functions of dmo_common.rules which only generate_ddl.xml and generate_seq_ddl.xml called (readMergeDMODefinition, readAllMergeDMODefinition and initVariables).
  • The length mode of ConversionDriver (M1), the length flag of CvtRunMode and the unused generateDDL method of ConversionDriver.

M1 is therefore no longer a valid conversion mode. A reconversion of a test schema gives the same DMOs and DDL as before.

Eric, Ovidiu, please review 11404a.

#18 Updated by Octavian Adrian Gavril 3 days ago

9638a is still work in progress, since I am addressing Constantin's review (#9638-137). One of its findings changes the scope of this task. An incremental conversion must work with the conversion artifacts alone, without the application jar. 9638a wrote no .p2o for temp-tables, so a source whose Java is not in a jar had nothing to describe its temp-tables in a later run. 9638a therefore writes the .p2o of the temp-tables again, as trunk does. The .p2o is only read by a later run. Within a run, the temp-tables still come from memory, and the temp-tables of a class from a jar still come from the annotations of its DMOs.

Removing the temp-table .p2o moves to this task, next to the items still open here (the .dict, ConversionPool and the database .p2o).

An idea for it is to store the schema description which 9638a builds in memory (SchemaModel) in the incremental conversion database, keyed by its source file:
  • A later run reads the description from the database instead of the .p2o file.
  • The temp-table entries of that database (tmpTabNodes) keep the values the rules read, instead of an id into a .p2o tree.
  • The description is removed together with the other incremental state of its source, and it is never shipped with the application.

It is still a stored schema, only not a file. The alternative is to compile the generated DMO interfaces on their own during the conversion, since they depend only on FWD, and to read their annotations as for a jar. Only the DMOs describe the schema then, at the cost of a compile step in every conversion.

I would go with the conversion database, since incremental conversion already needs it and it adds no step to the conversion.

Also available in: Atom PDF