# Command: apply\_migration, originalError: Error 1845: LOCK=NONE is not supported for this operation. Try LOCK=SHARED

**URL:** <https://forums.percona.com/t/command-apply-migration-originalerror-error-1845-lock-none-is-not-supported-for-this-operation-try-lock-shared/19579>\
**Category:** Percona XtraDB Cluster 8.x\
**Created:** [January 12, 2023, 1:28am UTC](https://forums.percona.com/t/command-apply-migration-originalerror-error-1845-lock-none-is-not-supported-for-this-operation-try-lock-shared/19579 "2023-01-12T01:28:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laimis](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/laimis/32/1410_2.png) [@Laimis](https://forums.percona.com/u/Laimis)\
**Post date:** [January 12, 2023, 1:28am UTC](https://forums.percona.com/t/command-apply-migration-originalerror-error-1845-lock-none-is-not-supported-for-this-operation-try-lock-shared/19579/1 "2023-01-12T01:28:15Z")

</div>

I’ve got this error during app schema migration:

`{"timestamp":"2023-01-11 11:53:09.043 Z","level":"fatal","msg":"Failed to apply database migrations.","caller":"sqlstore/store.go:169","error":"driver: mysql, message: failed when applying migration, command: apply_migration, originalError: Error 1845: LOCK=NONE is not supported for this operation. Try LOCK=SHARED., query: \n\nSET @preparedStatement = (SELECT IF(\n (\n SELECT COUNT(*) FROM INFORMATION_SCHEMA.STATISTICS\n WHERE table_name = 'Posts'\n AND table_schema = DATABASE()\n AND index_name = 'idx_posts_create_at_id'\n ) > 0,\n 'SELECT 1;',\n 'CREATE INDEX idx_posts_create_at_id on Posts(CreateAt, Id) LOCK=NONE;'\n));\n\nPREPARE createIndexIfNotExists FROM @preparedStatement;\nEXECUTE createIndexIfNotExists;\nDEALLOCATE PREPARE createIndexIfNotExists;\n\n"}`

Any options do I have? Any workaround to pass this with extra manual steps and then use app as usual? This is needed only for schema migration.

Thanks

---

<div class="post-metadata">

**Author:** ![Abhinav\_Gupta](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/abhinav_gupta/32/6262_2.png) [@Abhinav\_Gupta](https://forums.percona.com/u/Abhinav_Gupta)\
**Post date:** [January 12, 2023, 6:23am UTC](https://forums.percona.com/t/command-apply-migration-originalerror-error-1845-lock-none-is-not-supported-for-this-operation-try-lock-shared/19579/2 "2023-01-12T06:23:38Z")

</div>

> [@Laimis](#):
>
> CREATE INDEX idx\_posts\_create\_at\_id on Posts(CreateAt, Id) LOCK=NONE;

Here you could either altogether remove the “LOCK=NONE” option from the DDL OR, as recommended in the error message, use the “LOCK=SHARED” with the DDL to let it complete.

[https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html#online-ddl-index-operations](https://dev.mysql.com/doc/refman/5.7/en/innodb-online-ddl-operations.html#online-ddl-index-operations)

---

<div class="post-metadata">

**Author:** ![Laimis](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/laimis/32/1410_2.png) [@Laimis](https://forums.percona.com/u/Laimis)\
**Post date:** [January 18, 2023, 6:04pm UTC](https://forums.percona.com/t/command-apply-migration-originalerror-error-1845-lock-none-is-not-supported-for-this-operation-try-lock-shared/19579/3 "2023-01-18T18:04:52Z")

</div>

I confirm, it worked. Thank you.
