Repository navigation
Skip concurrently stored link pairs and tell FOR UPDATE OF by the MySQL version - #7
Merged
Merged
Conversation
Repository is open for extension since RC4, which makes adding a public method a possible break for an application's subclass. The API reference and the changelog now state what subclasses can rely on throughout 1.x: Repository stays a non-final readonly class with final public methods and private state, a minor release may add public methods, and constructor parameters keep their names and order, with new ones optional and last.
LinkSet::attach() and sync() read the stored pairs and insert the missing ones. A pair another writer stored between that read and the INSERT failed the whole operation on the pivot's unique key, although it is the link the caller asked for. The INSERT now carries the conflict clause shared with upserts: ON CONFLICT (pair) DO NOTHING on PostgreSQL and SQLite, ON DUPLICATE KEY UPDATE on MySQL and MariaDB. Foreign-key violations still propagate; other platforms keep the plain INSERT. Concurrent attaches of one pair now both succeed on MySQL and on PostgreSQL in READ COMMITTED. MariaDB with snapshot isolation and PostgreSQL above READ COMMITTED still refuse a transaction whose snapshot is older than the other writer's commit. On PostgreSQL and SQLite a pivot without the UNIQUE pair the guide requires now fails these writes.
A locking read named its table with FOR UPDATE OF on MySQL when the platform was a MySQL80Platform. DBAL deprecates its MySQL 8 platform classes and drops them with MySQL 5.7 support, after which MySQLPlatform itself stands for MySQL 8: the check would then turn false without an error, and the lock would also cover the rows the read joins. The server version now decides, 8.0.1 or later on a MySQLPlatform; MySQL 5.7 and MariaDB keep the plain FOR UPDATE. The tests no longer refer to a deprecated DBAL platform class.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes found while moving the dilio storefront onto
v1.0.0-RC5, plus the subclass compatibility rules for 1.x:FOR UPDATE OFon MySQL throughMySQL80Platform, which DBAL deprecates.Changes
LinkSetskips a pair another writer stored first.attach()andsync()read the stored pairs and insert the missing ones. A pair another writer stored between that read and the INSERT failed the whole operation on the unique key, although it is the link the caller asked for. The INSERT now carries the conflict clause shared with upserts (Database::upsertClause()):ON CONFLICT (foreignPivotKey, relatedPivotKey) DO NOTHINGon PostgreSQL and SQLite;ON DUPLICATE KEY UPDATE fk = fkon MySQL and MariaDB;The read stays, so attaching pairs that are already stored still only reads. Foreign-key violations still propagate.
FOR UPDATE OFon MySQL by the server version.Database::executeLocked()named the read's table when the platform was aMySQL80Platform. DBAL deprecates its MySQL 8 platform classes and drops them with MySQL 5.7 support, after whichMySQLPlatformitself stands for MySQL 8: the check would turn false without an error, and the lock would also cover the rows the read joins. It now asks for aMySQLPlatformand a server version of 8.0.1 or later; MySQL 5.7 and MariaDB keep the plainFOR UPDATE. The tests no longer use deprecated DBAL platform classes.Subclass compatibility rules (ce1a080): what typed repositories can rely on throughout 1.x.
Docs:
docs/guide/api.md,details.md,migration.mdand the changelog section "Changes since 1.0.0-RC5".Behavior changes for RC5 users
UniqueConstraintViolationException. MariaDB withinnodb_snapshot_isolation(its default since 11.6, error 1020) and PostgreSQL in REPEATABLE READ or SERIALIZABLE (40001) still refuse a transaction whose snapshot is older than the other writer's commit; an exact final set still needs an owner lock.ON CONFLICTneeds the UNIQUE(foreignPivotKey, relatedPivotKey)that the guide already required; a pivot without it now fails these writes there.Verification
644 unit tests, PHPStan max and PSR-12;
composer validate --strict; the examples run; the documentation builds. The lowest supported DBAL, 4.3.5, also passes, the integration suite included.New tests:
LinkSetTest::testInsertsSkipPairsStoredSinceTheRead— the pair INSERT on MySQL, MariaDB, PostgreSQL, SQLite and another platform;LockingReadTestcases carry the server version, including MySQL 8 on the baseMySQLPlatformand MySQL 5.7.Integration suite on MySQL 8.4, MariaDB 12.3 and PostgreSQL 17, 39 tests on each. A second session stores a pair between
attach()'s read and its INSERT (through aQueryLoghook), at the server's default isolation and at REPEATABLE READ:attach()rolls backattach()rolls backThe existing
NOWAITtest still shows that MySQL 8.4 locks only the read's table, so the version check appliesOF.The dilio storefront moves to RC6 right after the tag.
🤖 Generated with Claude Code