Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Add NOWAIT and SKIP LOCKED lock support for MySQL #7236

Merged
merged 4 commits into from
Jan 11, 2021

Conversation

lacunadream
Copy link
Contributor

Adds SKIP LOCKED (pessimistic_partial_write) and NOWAIT (pessimistic_write_or_fail) support for Mysql drivers.

Database support as follows

Database SKIP LOCKED NOWAIT
MySQL 8.0 8.0
MariaDB Unsupported 10.3.0

Added test cases, but they do not pass with the current versions listed in docker-compose. (Have tested with the versions listed above and they pass). Generally, how does typeorm handle cases like this?

References:
https://dev.mysql.com/doc/refman/8.0/en/innodb-locking-reads.html
https://jira.mariadb.org/browse/MDEV-13115
https://mariadb.com/kb/en/wait-and-nowait/

Add pessimistic_write_or_fail and pessimistic_partial_write support for mysql

Closes: typeorm#6530
@jorenvandeweyer
Copy link
Collaborator

Nice, thanks for adding this!
I wanted to open a pull request myself for this too today.

Any idea how fast this can be pushed into the next release?

@nebkat
Copy link
Contributor

nebkat commented Jan 1, 2021

Probably have to add a check for the driver version so it doesn't get used on earlier MySQL versions.

@pleerock
Copy link
Member

pleerock commented Jan 3, 2021

Thank you for contribution!

As @nebkat mentioned, we need to add a version check (can be added into test itself) in order to prevent CI fail.

@lacunadream
Copy link
Contributor Author

@pleerock added the tests with version checks. CI passes now.

@nebkat
Copy link
Contributor

nebkat commented Jan 9, 2021

Probably outside the scope of this PR but seeing as all the checks in createLockExpression() are solely based on lockMode and driver they should really be moved to the drivers themselves. Then the version logic can be implemented specifically for the MySQL driver rather than requiring the user to do so.

@pleerock pleerock merged commit 9407507 into typeorm:master Jan 11, 2021
@pleerock
Copy link
Member

Thank you for contribution! 🎉

zshipleyTAG pushed a commit to Amherst-Development/typeorm that referenced this pull request Oct 7, 2022
* typeorm-0.2.30: (212 commits)
  version bump
  docs: fix javascript usage examples (typeorm#7031)
  fix: resolve migration for UpdateDateColumn without ON UPDATE clause (typeorm#7057)
  fix: Error when sorting by an embedded entity while using join and skip/take (typeorm#7082)
  fix: resolves Postgres sequence identifier length error (typeorm#7115)
  feat: closure table custom naming (typeorm#7120)
  feat: relations: Orphaned row action (typeorm#7105)
  docs: fix invalid code block in "find many options" (typeorm#7268)
  docs: Embodying the example (typeorm#7116)
  docs: document withDeleted option (typeorm#7132)
  fix: return 'null' (instead of 'undefined') on lazy relations that have no results (typeorm#7146) (typeorm#7147)
  docs: update cascade options (typeorm#7140)
  docs: add .ts to supported ormconfig formats (typeorm#7139)
  fix: improve stack traces when using persist executor (typeorm#7218)
  refactor: remove Oracle multirow insert workaround (since typeorm#6927) (typeorm#7083)
  feat: add NOWAIT and SKIP LOCKED lock support for MySQL (typeorm#7236)
  docs: update OneToMany grammar (typeorm#7252)
  feat: JavaScript file migrations output (typeorm#7253)
  docs: update Repository.ts (typeorm#7254)
  chore: update dependency cli-highlight to v2.1.10 (typeorm#7265)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants