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

[NFR] Read-only mode for maintenance #70

Open
pgasiorowski opened this issue Jun 30, 2014 · 9 comments
Open

[NFR] Read-only mode for maintenance #70

pgasiorowski opened this issue Jun 30, 2014 · 9 comments
Labels
Milestone

Comments

@pgasiorowski
Copy link
Contributor

A simple switch somewhere in system config for read-only mode will be nice to have at some point.

This would be useful for times where some database maintenance is needed such as:

  • reconfiguring master in replication
  • semi-automatic db failover scripts which could put the website in read-only mode
  • other dba tasks: re-indexing huge tables, changing table engine, re-repartitioning etc..
  • basically, everything you would normally have to take the website down or redirect elsewhere

I'm not sure if it'd be possible to control each module globally with this option or if each module will have to implement this on its own.

@lantian
Copy link
Contributor

lantian commented Jul 1, 2014

👍

It is very simple... It can depends on config option maintenance key, if this key is present Application.php will redirect to /public/maintenance.html (mb not redirect, mb just print file_get_contents())... BTW maintenance key can be a key, that can be entered at maintenance to access to working site (via current session).

@pgasiorowski
Copy link
Contributor Author

That would be possible even with simple .htaccess or nginx redirect.
What I actually had in mind is to provide restricted (but still) access to entire site.

Just like stackoverflow does during maintenance to handle high-availability

@lantian
Copy link
Contributor

lantian commented Jul 1, 2014

Yep, and why u can't restrict it via this maintenance key ?

That would be possible even with simple .htaccess or nginx redirect.

But it must be accesible from admin panel.

@pgasiorowski
Copy link
Contributor Author

A few possible situations would be:

  • Disable registration temporarily
  • Prevent changing account details (username, email etc...)
  • Disable posting new topics on forum
  • Disable article hits (SET hits = hits +1) and commenting under articles

Basically everything which require database write. This enables you to send all reads to replicas while new master is being updated/prepared.

@lantian
Copy link
Contributor

lantian commented Jul 1, 2014

Oh... u mean read-only access... didn't notice it in title of this issue... hm...
I really can't understand that mode )))... it's not usable/possible... let's look on joomla... it cache's full page as php... we have no such feature... and wouldn't coz it is bad... Read-only access possible only that way... Maintenance... what is this? This is work stop... process stop... in our case for update/upgrade... and when update is in progress - read or write - is doesn't metter - in that time database structure can be broken - so... read is not possible... that's why it is contradictory...

@pgasiorowski
Copy link
Contributor Author

that's why it is contradictory

I would image that such upgrade takes place on a separate master and a set of replicas (new environment) while read-only replicas serve read-only content (old environment) thus allowing for smooth upgrade.
Once maintenance is completed you turn off the read-only mode and switch to the new environment.
This can only be achieved if read-only mode is accounted in application. Users still can login, access restricted areas of the page but they can't change anything.

@pgasiorowski
Copy link
Contributor Author

There is a wordpress plugin which tries to do this:
http://www.wpbeginner.com/plugins/how-to-put-your-wordpress-site-in-read-only-state-for-site-migrations-and-maintenance/

And generally this has been discussed on SilverStripe's group:
https://groups.google.com/forum/#!topic/silverstripe-dev/GD_vcU1SaRI

@lantian
Copy link
Contributor

lantian commented Jul 1, 2014

Yes... but this is for blog... in that context - it is easy.. but not in unfinished complex system, when final system will be never understanded for us.

I can set this as "low"... but this feature may lead to different problems.. like when we will have extension store.. we will need to add label to modules, that will identity module as "read-only mode is supported" - that means, that market will have estimativly 50% / 50% supported modules and unsupported... it will be not very nice..

As for implementation - it seems to me quit simple - creating own db adapter, that will have "read-only" flag, when flag is enabled - all operations with INSERT/UPDATE will thrown a special exception type... and it will be special method that will check that flag for submodules... like if $db->isReadOnly()){ ... todo ... } .... if there will be no flag in controller (e.g. in blog creation form) - an exception will be thrown... while exception will have special type (if it unhandled) - a special error page will be shown, like... this part of system is currently under update.... something like that...

@pgasiorowski
Copy link
Contributor Author

If it was possible with a plugin that's even better. Please keep this open for now, I'll try experimenting with db adapter and/or plugin when I have a few spare minutes

@lantian lantian modified the milestone: 0.5.0 Nov 8, 2016
@lantian lantian added the FEATURE label Nov 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants