# Laravel Read Replicas: Check if a Replica Has Caught Up

DevFeed: [Laravel Read Replicas: Check if a Replica Has Caught Up](<https://devfeed.tech/articles/laravel-read-replicas-check-if-a-replica-has-caught-up-131217.md>)

Original publisher: [Read original article](<https://laravel-news.com/laravel-read-replica-commit-ids>)

Author: Paul Redmond

Published: 2026-11-11T23:04:37Z

Content type: article

Language: en

Sources: [Laravel](<https://devfeed.tech/sources/laravel.md>)

Topics: [read-replica](<https://devfeed.tech/topics/read-replica.md>), [Laravel](<https://devfeed.tech/topics/laravel.md>), [consistency](<https://devfeed.tech/topics/consistency.md>), [MariaDB](<https://devfeed.tech/topics/mariadb.md>)

Tags: [commit](<https://devfeed.tech/tags/commit.md>), [database](<https://devfeed.tech/tags/database.md>), [ids](<https://devfeed.tech/tags/ids.md>), [job](<https://devfeed.tech/tags/job.md>), [lag](<https://devfeed.tech/tags/lag.md>), [laravel](<https://devfeed.tech/tags/laravel.md>), [laravel-tutorials](<https://devfeed.tech/tags/laravel-tutorials.md>), [mariadb](<https://devfeed.tech/tags/mariadb.md>), [middleware](<https://devfeed.tech/tags/middleware.md>), [mysql](<https://devfeed.tech/tags/mysql.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [read-replicas](<https://devfeed.tech/tags/read-replicas.md>), [replica](<https://devfeed.tech/tags/replica.md>), [write](<https://devfeed.tech/tags/write.md>)

## AI overview

Laravel 13.40 adds commit ID checks that let applications route reads based on whether a replica has applied a write, rather than relying only on a fixed lag window. `getLastCommitId()` reads the primary's position; `hasCommitId()` checks the server used for reads and can check once or wait up to a whole-number timeout; `mergeCommitIds()` combines positions across writes. The article gives two patterns: session middleware stores pending IDs and uses the primary until a replica catches up, while queued jobs receive an ID, wait briefly, then fall back to the primary. Capture the ID after a transaction commits. The middleware adds a replica query per pending request and a primary query per writing request; a job should receive an ID rather than a serialized model to avoid loading it from a lagging replica before the check. Requirements vary: MySQL needs binary logging and GTIDs, MariaDB needs binary logging, SQLite and SQL Server are unsupported, and PostgreSQL 18 and earlier cannot use the wait option. Replica checks follow Laravel's connection routing and must be repeated on each request.

## Source excerpt

Laravel 13.40 adds commit IDs to MySQL, MariaDB, and PostgreSQL connections, so you can check whether a read replica has a write before you read from it. The post Laravel Read Replicas: Check if a Replica Has Caught Up appeared first on Laravel News. Join the Laravel Newsletter to get Laravel articles like this directly in your inbox.