orientdb icon indicating copy to clipboard operation
orientdb copied to clipboard

[2.1.2] Error importing database exported by v.1.5.0

Open giastfader opened this issue 11 years ago • 7 comments

Note: this worked untill 2.0

TLTR: during the import this error is raised: importing database schema...ERROR (1 entries): com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: sql.alter class E shortname E The import SEEMS to continue but at the end of the procedure several classes and all the manual indexes are missed. The same backup is loaded correctly in versions 1.7.9 and 2.0-M2

Long version: Here is the console output of version 1.7.9

create database remote:localhost/test root <pass> plocal

orientdb> create database remote:localhost/test root <pass> plocal

Creating database [remote:localhost/test] using the storage type [plocal]...
Connecting to database [remote:localhost/test] with user 'admin'...OK
Database created successfully.

Current database is: remote:localhost/test
orientdb {db=test}> import database /tmp/adminImportJson.json

Importing database /tmp/adminImportJson.json...
Started import of database 'remote:localhost/test' from /tmp/adminImportJson.json...
Non merge mode (-merge=false): removing all default non security classes
- Class E was removed.
- Class V was removed.
- Class ORestricted was removed.
- Class OTriggered was removed.
- Class OSchedule was removed.
- Class ORIDs was removed.
- Class OFunction was removed.
Removed 7 classes.
Importing database info...OK
Importing clusters...
- Creating cluster 'internal'...OK, assigned id=0
- Creating cluster 'default'...OK, assigned id=3
- Creating cluster 'orole'...OK, assigned id=4
- Creating cluster 'ouser'...OK, assigned id=5
- Creating cluster 'ofunction'...OK, assigned id=6
- Creating cluster 'oschedule'...OK, assigned id=7
- Creating cluster 'orids'...OK, assigned id=8
- Creating cluster 'v'...OK, assigned id=9
- Creating cluster 'e'...OK, assigned id=10
- Creating cluster '_bb_nodevertex'...OK, assigned id=11
- Creating cluster '_bb_node'...OK, assigned id=12
- Creating cluster '_bb_user'...OK, assigned id=13
- Creating cluster '_bb_userattributes'...OK, assigned id=14
- Creating cluster '_bb_resetpwd'...OK, assigned id=15
- Creating cluster '_bb_collection'...OK, assigned id=16
- Creating cluster '_bb_asset'...OK, assigned id=17
- Creating cluster '_bb_fileasset'...OK, assigned id=18
- Creating cluster 'created'...OK, assigned id=19
Rebuilding indexes of truncated clusters ...
Done 2 indexes were rebuilt.
Done. Imported 18 clusters
Importing database schema...OK (19 classes)
Importing records...
- Importing records into cluster 'internal' (id=0) = 2 records
- Importing records into cluster 'default' (id=3) = 31 records
- Importing records into cluster 'orole' (id=4) = 6 records
- Importing records into cluster 'ouser' (id=5) = 3 records
- Importing records into cluster '_bb_nodevertex' (id=11) = 3 records
- Importing records into cluster '_bb_user' (id=13) = 3 records
- Importing records into cluster '_bb_userattributes' (id=14) = 1 records
- Importing records into cluster '_bb_userattributes' (id=14)
Started migration of links (-migrateLinks=true). Links are going to be updated according to new RIDs:
- Cluster _bb_fileasset... Processed: 0
- Cluster _bb_userattributes... Processed: 2
- Cluster orids... Processed: 0
- Cluster e... Processed: 0
- Cluster created... Processed: 0
- Cluster ouser... Processed: 3
- Cluster default... Processed: 31
- Cluster oschedule... Processed: 0
- Cluster _bb_asset... Processed: 0
- Cluster orole... Processed: 6
- Cluster _bb_user... Processed: 3
- Cluster _bb_collection... Processed: 0
- Cluster v... Processed: 0
- Cluster _bb_resetpwd... Processed: 0
- Cluster _bb_node... Processed: 0
- Cluster _bb_nodevertex... Processed: 3
- Cluster ofunction... Processed: 0
Total links updated: 48

Done. Imported 49 records

Importing indexes ...
- Index '_BB_Node.id'...OK
- Index 'dictionary'...OK
- Index 'ouser.name'...OK
- Index '_bb_application'...OK
- Index '_bb_password_recovery'...OK
- Index '_BB_asset.name'...OK
- Index 'ORole.name'...OK
- Index '_bb_internal'...OK
- Index '_bb_images'...OK
- Index '_BB_Collection.name'...OK
- Index '_bb_push'...OK
Done. Created 11 indexes.
Importing manual index entries...
- Index 'dictionary'...OK (0 entries)
- Index '_bb_application'...OK (5 entries)
- Index '_bb_password_recovery'...OK (24 entries)
- Index '_bb_internal'...OK (2 entries)
- Index '_bb_images'...OK (0 entries)
- Index '_bb_push'...OK (0 entries)
Done. Imported 6 indexes.
Rebuild of stale indexes...
Stale indexes were rebuilt...
Deleting RID Mapping table...OK


Database import completed in 2095 ms

orientdb {db=test}> info

Current database: test (url=remote:localhost/test)

DISTRIBUTED CONFIGURATION: none (OrientDB is running in standalone mode)

DATABASE PROPERTIES
--------------------------------+----------------------------------------------------+
 NAME                           | VALUE                                              |
--------------------------------+----------------------------------------------------+
 Name                           | null                                               |
 Version                        | 9                                                  |
 Date format                    | yyyy-MM-dd                                         |
 Datetime format                | yyyy-MM-dd HH:mm:ss                                |
 Timezone                       | Europe/Rome                                        |
 Locale Country                 |                                                    |
 Locale Language                | nap                                                |
 Charset                        | UTF-8                                              |
 Schema RID                     | #0:1                                               |
 Index Manager RID              | #0:2                                               |
 Dictionary RID                 | null                                               |
--------------------------------+----------------------------------------------------+

CLUSTERS
----------------------------------------------+-------+---------------------+---------+-----------------+
 NAME                                         |   ID  | TYPE                | DATASEG | RECORDS         |
----------------------------------------------+-------+---------------------+---------+-----------------+
 _bb_asset                                    |    17 | PHYSICAL            |      -1 |               0 |
 _bb_collection                               |    16 | PHYSICAL            |      -1 |               0 |
 _bb_fileasset                                |    18 | PHYSICAL            |      -1 |               0 |
 _bb_node                                     |    12 | PHYSICAL            |      -1 |               0 |
 _bb_nodevertex                               |    11 | PHYSICAL            |      -1 |               3 |
 _bb_resetpwd                                 |    15 | PHYSICAL            |      -1 |               0 |
 _bb_user                                     |    13 | PHYSICAL            |      -1 |               3 |
 _bb_userattributes                           |    14 | PHYSICAL            |      -1 |               2 |
 created                                      |    19 | PHYSICAL            |      -1 |               0 |
 default                                      |     3 | PHYSICAL            |      -1 |              31 |
 e                                            |    10 | PHYSICAL            |      -1 |               0 |
 index                                        |     1 | PHYSICAL            |      -1 |               7 |
 internal                                     |     0 | PHYSICAL            |      -1 |               3 |
 manindex                                     |     2 | PHYSICAL            |      -1 |               8 |
 ofunction                                    |     6 | PHYSICAL            |      -1 |               0 |
 orids                                        |     8 | PHYSICAL            |      -1 |               0 |
 orole                                        |     4 | PHYSICAL            |      -1 |               6 |
 oschedule                                    |     7 | PHYSICAL            |      -1 |               0 |
 ouser                                        |     5 | PHYSICAL            |      -1 |               3 |
 v                                            |     9 | PHYSICAL            |      -1 |               0 |
----------------------------------------------+-------+---------------------+---------+-----------------+
 TOTAL = 20                                                                 |         |              66 |
----------------------------------------------------------------------------+---------+-----------------+

CLASSES
----------------------------------------------+------------------------------------+------------+----------------+
 NAME                                         | SUPERCLASS                         | CLUSTERS   | RECORDS        |
----------------------------------------------+------------------------------------+------------+----------------+
 _BB_Asset                                    | _BB_Node                           | 17         |              0 |
 _BB_Collection                               | _BB_Node                           | 16         |              0 |
 _BB_FileAsset                                | _BB_Asset                          | 18         |              0 |
 _BB_Node                                     | ORestricted                        | 12         |              0 |
 _BB_NodeVertex                               | V                                  | 11         |              3 |
 _BB_ResetPwd                                 |                                    | 15         |              0 |
 _BB_User                                     | _BB_Node                           | 13         |              3 |
 _BB_UserAttributes                           | ORestricted                        | 14         |              2 |
 Created                                      | E                                  | 19         |              0 |
 E                                            |                                    | 10         |              0 |
 OFunction                                    |                                    | 6          |              0 |
 OIdentity                                    |                                    | -          |              0 |
 ORestricted                                  |                                    | -          |              0 |
 ORIDs                                        |                                    | 8          |              0 |
 ORole                                        | OIdentity                          | 4          |              6 |
 OSchedule                                    |                                    | 7          |              0 |
 OTriggered                                   |                                    | -          |              0 |
 OUser                                        | OIdentity                          | 5          |              3 |
 V                                            |                                    | 9          |              0 |
----------------------------------------------+------------------------------------+------------+----------------+
 TOTAL = 19                                                                                                   17 |
----------------------------------------------+------------------------------------+------------+----------------+

INDEXES
----------------------------------------------+------------+-----------------------+----------------+------------+
 NAME                                         | TYPE       |         CLASS         |     FIELDS     | RECORDS    |
----------------------------------------------+------------+-----------------------+----------------+------------+
 ___exportImportRIDMap                        | DICTION... |                       |                |          0 |
 _bb_application                              | DICTIONARY |                       |                |          5 |
 _BB_Asset.name                               | UNIQUE     | _BB_Asset             | name           |          0 |
 _BB_Collection.name                          | UNIQUE     | _BB_Collection        | name           |          0 |
 _bb_images                                   | DICTIONARY |                       |                |          0 |
 _bb_internal                                 | DICTIONARY |                       |                |          2 |
 _BB_Node.id                                  | UNIQUE     | _BB_Node              | id             |          0 |
 _bb_password_recovery                        | DICTIONARY |                       |                |         24 |
 _bb_push                                     | DICTIONARY |                       |                |          0 |
 dictionary                                   | DICTIONARY |                       |                |          0 |
 ORole.name                                   | UNIQUE     | ORole                 | name           |          6 |
 OUser.name                                   | UNIQUE     | OUser                 | name           |          3 |
----------------------------------------------+------------+-----------------------+----------------+------------+
 TOTAL = 12                                                                                                   40 |
-----------------------------------------------------------------------------------------------------------------+

Meanwhile, here is the output of v.2.1.2

create database remote:localhost/test root <pass> plocal
import database /tmp/adminImportJson.json

Importing database database /tmp/adminImportJson.json...
Started import of database 'remote:localhost/test' from /tmp/adminImportJson.json...
Non merge mode (-merge=false): removing all default non security classes
- Class E was removed.
- Class V was removed.
- Class ORestricted was removed.
- Class OTriggered was removed.
- Class OSchedule was removed.
- Class ORIDs was removed.
- Class OFunction was removed.
Removed 7 classes.
Importing database info...OK
Importing clusters...
- Creating cluster 'internal'...OK, assigned id=0
- Creating cluster 'default'...OK, assigned id=3
- Creating cluster 'orole'...OK, assigned id=4
- Creating cluster 'ouser'...OK, assigned id=5
- Creating cluster 'ofunction'...OK, assigned id=6
- Creating cluster 'oschedule'...OK, assigned id=7
- Creating cluster 'orids'...OK, assigned id=8
- Creating cluster 'v'...OK, assigned id=9
- Creating cluster 'e'...OK, assigned id=10
- Creating cluster '_bb_nodevertex'...OK, assigned id=11
- Creating cluster '_bb_node'...OK, assigned id=12
- Creating cluster '_bb_user'...OK, assigned id=13
- Creating cluster '_bb_userattributes'...OK, assigned id=14
- Creating cluster '_bb_resetpwd'...OK, assigned id=15
- Creating cluster '_bb_collection'...OK, assigned id=16
- Creating cluster '_bb_asset'...OK, assigned id=17
- Creating cluster '_bb_fileasset'...OK, assigned id=18
- Creating cluster 'created'...OK, assigned id=19
Rebuilding indexes of truncated clusters ...
Done 2 indexes were rebuilt.
Done. Imported 18 clusters
Importing database schema...ERROR (1 entries): com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: sql.alter class E shortname E
Rebuild of stale indexes...
Start rebuild index ouser.name
Rebuild  of index ouser.name is completed.
Start rebuild index orole.name
Rebuild  of index orole.name is completed.
Stale indexes were rebuilt...
Deleting RID Mapping table...OK


Database import completed in 264 ms
orientdb {db=test}> info

Current database: test (url=remote:localhost/test)

DISTRIBUTED CONFIGURATION: none (OrientDB is running in standalone mode)

DATABASE PROPERTIES
--------------------------------+----------------------------------------------------+
 NAME                           | VALUE                                              |
--------------------------------+----------------------------------------------------+
 Name                           | null                                               |
 Version                        | 14                                                 |
 Conflict Strategy              | version                                            |
 Date format                    | yyyy-MM-dd                                         |
 Datetime format                | yyyy-MM-dd HH:mm:ss                                |
 Timezone                       | Europe/Rome                                        |
 Locale Country                 |                                                    |
 Locale Language                | nap                                                |
 Charset                        | UTF-8                                              |
 Schema RID                     | #0:1                                               |
 Index Manager RID              | #0:2                                               |
 Dictionary RID                 | null                                               |
--------------------------------+----------------------------------------------------+

DATABASE CUSTOM PROPERTIES:
 +-------------------------------+--------------------------------------------------+
 | NAME                          | VALUE                                            |
 +-------------------------------+--------------------------------------------------+
 | strictSql                     | true                                             |
 +-------------------------------+--------------------------------------------------+

CLUSTERS (collections)
----------------------------------------------+-------+-------------------+----------------+
 NAME                                         | ID    | CONFLICT STRATEGY | RECORDS        |
----------------------------------------------+-------+-------------------+----------------+
 _bb_asset                                    |    17 |                   |              0 |
 _bb_collection                               |    16 |                   |              0 |
 _bb_fileasset                                |    18 |                   |              0 |
 _bb_node                                     |    12 |                   |              0 |
 _bb_nodevertex                               |    11 |                   |              0 |
 _bb_resetpwd                                 |    15 |                   |              0 |
 _bb_user                                     |    13 |                   |              0 |
 _bb_userattributes                           |    14 |                   |              0 |
 created                                      |    19 |                   |              0 |
 default                                      |     3 |                   |              0 |
 e                                            |    10 |                   |              0 |
 index                                        |     1 |                   |              9 |
 internal                                     |     0 |                   |              3 |
 manindex                                     |     2 |                   |              1 |
 ofunction                                    |     6 |                   |              0 |
 orids                                        |     8 |                   |              0 |
 orole                                        |     4 |                   |              0 |
 oschedule                                    |     7 |                   |              0 |
 ouser                                        |     5 |                   |              0 |
 v                                            |     9 |                   |              0 |
----------------------------------------------+-------+-------------------+----------------+
 TOTAL = 20                                                               |             13 |
--------------------------------------------------------------------------+----------------+

CLASSES
----------------------------------------------+------------------------------------+------------+----------------+
 NAME                                         | SUPERCLASS                         | CLUSTERS   | RECORDS        |
----------------------------------------------+------------------------------------+------------+----------------+
 Created                                      |                                    | 19         |              0 |
 E                                            |                                    | 10         |              0 |
 OIdentity                                    |                                    | -          |              0 |
 ORole                                        | [OIdentity]                        | 4          |              0 |
 OUser                                        | [OIdentity]                        | 5          |              0 |
----------------------------------------------+------------------------------------+------------+----------------+
 TOTAL = 5                                                                                                     0 |
----------------------------------------------+------------------------------------+------------+----------------+

INDEXES
----------------------------------------------+------------+-----------------------+----------------+------------+
 NAME                                         | TYPE       |         CLASS         |     FIELDS     | RECORDS    |
----------------------------------------------+------------+-----------------------+----------------+------------+
 dictionary                                   | DICTIONARY |                       |                |          0 |
 ORole.name                                   | UNIQUE     | ORole                 | name           |          0 |
 OUser.name                                   | UNIQUE     | OUser                 | name           |          0 |
----------------------------------------------+------------+-----------------------+----------------+------------+
 TOTAL = 3                                                                                                     0 |
-----------------------------------------------------------------------------------------------------------------+

As you can see all manual and automatic indexes are gone, many clusters are been created, but the corresponding classes are missing too.

I can send the backup file if it is needed

giastfader avatar Sep 30 '15 10:09 giastfader

Update: I imported the backup into 1.7.9 and then I exported it. OrientDB 2.1.2 still does not import the database. This means that because of some reasons 2.1.2 fails to import backuped database files that were done using previous versions.

giastfader avatar Oct 01 '15 10:10 giastfader

Update 2: I found that the exported JSON(s) have this declaration:

            {
                "cluster-ids": [
                    10
                ],
                "cluster-selection": "round-robin",
                "default-cluster-id": 10,
                "name": "E",
                "short-name": "E"
            },

Seems that this creates problem to the v.2.1.2 importer. How can avoid this problem if I have old databases exported using v.1.5.0 that has such declaration?

giastfader avatar Oct 01 '15 11:10 giastfader

Could it be a side effect of the fix provided for https://github.com/orientechnologies/orientdb/issues/4658 ? I think that since export files are made by OrientDB itself, newer version should take them and swallow exceptions and log one or more warnings, not just interrupt the import procedure because of a unhandled (new) exception that eventually will result in a corrupt database. WDYT?

giastfader avatar Oct 01 '15 13:10 giastfader

It's not clear if removing the "short-name": "E" did the job or not.

lvca avatar Oct 05 '15 16:10 lvca

Yes it did. But the problem is that I did it manually, meanwhile the import procedure should handle this case because it is not always possible to hack the exported file as in my case (the file was not too big to handle with a text editor). If I had a very big exported file, I had no chance to open it and change it. Moreover I have an automatic procedure to restore databases and it is not convenient to open them one by one manually. Maybe the easiest thing to do is to ignore the command (set short name) if the "short name" is equals to the class name it self. WDYT?

giastfader avatar Oct 05 '15 16:10 giastfader

Got it, if that fixed the problem, I can ignore this case ;-)

lvca avatar Oct 05 '15 16:10 lvca

Done. We accept also PR ;-)

lvca avatar Oct 05 '15 16:10 lvca