Back

Error during 1.4.2 migration - Invalid query: Invalid cursor: UID must contain at most 36 chars.

  • 1
  • General
  • Databases
obiwanzenobi
8 Sep, 2023, 07:32

updated from 1.4.1 to 1.4.2 with sucess, but fails on migration

TypeScript
Migrating Buckets
5 / 5
Migrating Bucket bucket_6 avatars (avatars)
'bucketInternalId' from bucket_6: Attribute already exists
Migrating Bucket bucket_7 images (images)
'bucketInternalId' from bucket_7: Attribute already exists
Migrating Bucket bucket_8 internal (internal)
'bucketInternalId' from bucket_8: Attribute already exists
Migrating Bucket bucket_9 thumbnails (thumbnails)
'bucketInternalId' from bucket_9: Attribute already exists
Migrating Bucket bucket_10 wordpress_export (wordpress_export)
'bucketInternalId' from bucket_10: Attribute already exists
Migrating Documents
Migrating Collection _metadata:
85 / 85
Migrating Collection audit:
100 / 275
200 / 275
275 / 275
Migrating Collection abuse:
0 / 0
Migrating Collection databases:
1 / 1
Migrating Collection attributes:
100 / 574
200 / 574

Fatal error: Uncaught Utopia\Database\Exception\Query: Invalid query: Invalid cursor: UID must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, and underscore. Can't start with a leading underscore in /usr/src/code/vendor/utopia-php/database/src/Database/Database.php:4061
Stack trace:
#0 /usr/src/code/src/Appwrite/Migration/Migration.php(198): Utopia\Database\Database->find(Object(Utopia\Database\Document), Array)
#1 /usr/src/code/src/Appwrite/Migration/Version/V19.php(798): Appwrite\Migration\Migration->documentsIterator('attributes')
#2 {main}
  thrown in /usr/src/code/vendor/utopia-php/database/src/Database/Database.php on line 4061
TL;DR
Error occurred during the 1.4.2 migration process. The error message indicates that there is an invalid cursor with a UID that exceeds the 36 character limit. The user tried going back to version 1.4.1, but encountered the same issue due to the additional "1_21_" in the UID. There also seems to be a problem with attributes in the metadata. The user suspects that the issue lies in the underlying Mariadb database and wonders how to run migration commands in the Mariadb container. The solution recommended is to check the field causing the problem by running commands in the Mariadb container.
obiwanzenobi
8 Sep, 2023, 07:33

where I can check which document is causing problem?

safwan
8 Sep, 2023, 07:36

This seems like an issue in the underlying mariadb database. You technically can run commands in the mariadb container and see which row is causing the issue

obiwanzenobi
8 Sep, 2023, 07:38

ok so copy V19 migration commands and check which field is causing problems

obiwanzenobi
8 Sep, 2023, 07:51

Funny fact - I removed database before migration with appwrite removeDatabase function

obiwanzenobi
8 Sep, 2023, 07:51

so I dont understand why it works on some documents

obiwanzenobi
8 Sep, 2023, 07:59

@safwan there is no sql in this php migrations, how could i run them on mariadb container

obiwanzenobi
8 Sep, 2023, 08:11
TypeScript
            18 Query    SELECT `table_main`.*
            FROM `appwrite`.`_1_databases` as table_main

            ORDER BY table_main._id ASC
            LIMIT 100 OFFSET 0
            18 Query    SELECT COUNT(1) as sum
            FROM
                (
                    SELECT 1
                    FROM `appwrite`.`_1_attributes` table_main


                ) table_count
            18 Query    SELECT `table_main`.*
            FROM `appwrite`.`_1_attributes` as table_main

            ORDER BY table_main._id ASC
            LIMIT 100 OFFSET 0
            18 Query    SELECT `table_main`.*
            FROM `appwrite`.`_1_attributes` as table_main
            WHERE ( table_main._id > 103 )
            ORDER BY table_main._id ASC
            LIMIT 100 OFFSET 0
            18 Quit
230908  8:08:27         7 Query    SELECT *
            FROM `appwrite`.`_console__metadata`
            WHERE _uid = 'schedules'
             7 Query    SELECT `table_main`.*
            FROM `appwrite`.`_console_schedules` as table_main
            WHERE (`region` = 'default') AND (`resourceType` = 'function') AND (`resourceUpdatedAt` >= '2023-09-08 08:08:17.205')
            ORDER BY table_main._id ASC
            LIMIT 1000 OFFSET 0
obiwanzenobi
8 Sep, 2023, 08:11

looks like it fails on quit message

obiwanzenobi
8 Sep, 2023, 09:38

ok so there is also a problem in metadata

obiwanzenobi
8 Sep, 2023, 09:39

for some reason there are cursor keys with underscore name

obiwanzenobi
8 Sep, 2023, 09:40
TypeScript
35 / 78
CURSOR CHECK database_1_collection_15
36 / 78
CURSOR CHECK database_1_collection_16
37 / 78
CURSOR CHECK database_1_collection_17
38 / 78
CURSOR CHECK database_1_collection_18
39 / 78
CURSOR CHECK database_1_collection_19
40 / 78
CURSOR CHECK database_1_collection_20
41 / 78
CURSOR CHECK database_1_collection_21
42 / 78
CURSOR CHECK database_1_collection_22
43 / 78
CURSOR CHECK database_1_collection_23
44 / 78
CURSOR CHECK database_1_collection_24
45 / 78
CURSOR CHECK database_1_collection_25
46 / 78
CURSOR CHECK database_1_collection_26
47 / 78
CURSOR CHECK database_1_collection_27
48 / 78
CURSOR CHECK _26_27
obiwanzenobi
8 Sep, 2023, 09:40

a add logi n cursor validator

obiwanzenobi
8 Sep, 2023, 09:40
TypeScript
Migrating Collection "tokens"
Migrating Collection "sessions"
Migrating Collection "identities"
Migrating Collection "teams"
Migrating Collection "memberships"
Migrating Collection "buckets"
Migrating Collection "stats"
Migrating Buckets
0 / 0
Migrating Documents
Migrating Collection _metadata:
obiwanzenobi
8 Sep, 2023, 09:54
TypeScript
                                                                                                                                         |                1 |
|  86 | _62_69                   | 2023-09-08 07:19:13.494 | 2023-09-08 07:19:13.494 | ["create(\"any\")"]                                                                                                                                                                                                                     | _62_69                   | [{"$id":"dictations","key":"dictations","type":"string","size":255,"required":true,"signed":true,"array":false,"filters":[]},{"$id":"categories","key":"categories","type":"string","size":255,"required":true,"signed":true,"array":false,"filters":[]}]
obiwanzenobi
8 Sep, 2023, 09:56

I also found attributes problem:

TypeScript
200 / 568
CURSOR CHECK 1_21_mostProblematicDictationCheckType

Fatal error: Uncaught Utopia\Database\Exception\Query: Invalid query: Invalid cursor: UID must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, and underscore. Can't start with a leading underscore in /usr/src/code/vendor/utopia-php/database/src/Database/Database.php:4061
Stack trace:
#0 /usr/src/code/src/Appwrite/Migration/Migration.php(198): Utopia\Database\Database->find(Object(Utopia\Database\Document), Array)
#1 /usr/src/code/src/Appwrite/Migration/Version/V19.php(798): Appwrite\Migration\Migration->documentsIterator('attributes')
#2 {main}
obiwanzenobi
8 Sep, 2023, 09:56

my name is 35 char long

obiwanzenobi
8 Sep, 2023, 09:57

but with this additional 1_21_ it exceeds 36 char limit

obiwanzenobi
8 Sep, 2023, 10:16

ok im going back to 1.4.1

obiwanzenobi
8 Sep, 2023, 10:17

I think that provided logs are more than enough to debug it

Meldiron
8 Sep, 2023, 10:50

@Christy Jacob please take a look 🙏

Drake
8 Sep, 2023, 16:25

what exactly is the uid?

Drake
8 Sep, 2023, 16:26

ah this: 1_21_mostProblematicDictationCheckType

Drake
8 Sep, 2023, 16:33
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more