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

NEW Allow database read-only replicas #11379

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

emteknetnz
Copy link
Member

Issue #11352

* List of rules that must only use the primary database and not a replica
*/
private static array $must_use_primary_db_rules = [
'Security'
Copy link
Member Author

@emteknetnz emteknetnz Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm enforcing must_use_primary on anything "Security" related - i.e. any url that matches /Security, any DataObject under the Security namespace, to prevent any weird issues that could happen when a replica is out of sync with the primary

For instance a password is changed, the user logs out, but cannot log back in because the replica isn't synced up yet.

Having replicas be slightly out of sync is one of the trade-offs for using replicas, though for anything security related it introduces risk so it's disallowed

@emteknetnz emteknetnz force-pushed the pulls/5/db-replica branch 9 times, most recently from bc7692c to 2d388e9 Compare September 18, 2024 23:12
@emteknetnz emteknetnz marked this pull request as ready for review September 18, 2024 23:53
Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't tested locally yet but here's some requested changes based on reviewing the code

cli-script.php Outdated Show resolved Hide resolved
src/Control/Director.php Outdated Show resolved Hide resolved
src/ORM/DB.php Show resolved Hide resolved
src/Control/Director.php Outdated Show resolved Hide resolved
src/ORM/DB.php Outdated Show resolved Hide resolved
tests/php/ORM/DBReplicaTest.php Outdated Show resolved Hide resolved
tests/php/ORM/DBReplicaTest.php Outdated Show resolved Hide resolved
tests/php/ORM/DBReplicaTest.php Outdated Show resolved Hide resolved
tests/php/ORM/DBReplicaTest.php Outdated Show resolved Hide resolved
tests/php/ORM/DBReplicaTest.php Outdated Show resolved Hide resolved
@emteknetnz emteknetnz force-pushed the pulls/5/db-replica branch 4 times, most recently from e57f963 to 2d41361 Compare September 25, 2024 02:58
src/Control/Director.php Outdated Show resolved Hide resolved
src/ORM/DB.php Outdated Show resolved Hide resolved
src/ORM/DB.php Outdated Show resolved Hide resolved
src/ORM/DB.php Outdated Show resolved Hide resolved
src/ORM/DB.php Outdated Show resolved Hide resolved
src/ORM/DB.php Outdated Show resolved Hide resolved
tests/php/ORM/DBReplicaTest.php Outdated Show resolved Hide resolved
src/ORM/DB.php Outdated Show resolved Hide resolved
src/Core/CoreKernel.php Outdated Show resolved Hide resolved
src/Core/CoreKernel.php Outdated Show resolved Hide resolved
src/ORM/DB.php Outdated Show resolved Hide resolved
Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/ORM/DB.php Outdated Show resolved Hide resolved
@emteknetnz emteknetnz changed the base branch from 5 to 6 September 27, 2024 02:37
@emteknetnz emteknetnz force-pushed the pulls/5/db-replica branch 2 times, most recently from af8c2ac to 2dbb1a4 Compare October 2, 2024 01:45
Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed a couple of changes which make it seem like this PR probably wasn't updated fully when you retargetted 6? Please double check before I continue my review.

src/ORM/DB.php Outdated Show resolved Hide resolved
src/ORM/DB.php Outdated Show resolved Hide resolved
@emteknetnz emteknetnz force-pushed the pulls/5/db-replica branch 2 times, most recently from 0a6f3db to 4aaca65 Compare October 3, 2024 04:18
src/ORM/DB.php Outdated Show resolved Hide resolved
src/ORM/DB.php Outdated Show resolved Hide resolved
src/ORM/DB.php Outdated Show resolved Hide resolved
src/ORM/DB.php Show resolved Hide resolved
@GuySartorelli
Copy link
Member

There's also some failing CI - does some of that rely on other PRs?

@emteknetnz
Copy link
Member Author

I think the unit test failures are related to the branch having /5/ in it when it's a CMS 6 PR (originally it pointed to CMS 6) - our CI looks at the branch pattern to get the version of installer

Issue links to a recipe sink build so we can rely on that

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@GuySartorelli GuySartorelli merged commit f83f56e into silverstripe:6 Oct 10, 2024
10 checks passed
@GuySartorelli GuySartorelli deleted the pulls/5/db-replica branch October 10, 2024 21:53
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.

2 participants