Skip to content

With RO db, prevent reading from slaves after write will cause failed SELECT with the same table after writes #176

@willis-zhang

Description

@willis-zhang

My db-config.php is as below, config as Read-Only:

$wpdb->add_database( array(
	'host'     => DB_HOST,     // If port is other than 3306, use host:port.
	'user'     => DB_USER',
	'password' => DB_PASSWORD,
	'name'     => DB_NAME,
	'write'    => 0,
	'read'     => 1,
	'dataset'  => 'global',
	'timeout'  => 0.2,
) );

I found when a write query is execute, any query after for the same table will be executed as global__w. And with my read-only configuration, that causes SELECT statement returning empty result.

I checked code, this is intensional to prevent reading from slaves which might be lagging after a write.

so any idea to solve my situation?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions