Bug 17261

Summary: Add memcached configuration info to about.pl
Product: Koha Reporter: Tomás Cohen Arazi (tcohen) <tomascohen>
Component: System AdministrationAssignee: Tomás Cohen Arazi (tcohen) <tomascohen>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: abl, chris, gmcharlt, jonathan.druart, josef.moravec, kyle.m.hall, kyle, mtj, nick, tomascohen, veron
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=17262
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:
Bug Depends on: 11921, 17189    
Bug Blocks: 17274    
Attachments: Bug 17261: Add memcached configuration info to about.pl
Bug 17261: Add memcached configuration info to about.pl
Bug 17261: (followup) Rebase against 17189 and 11921
Bug 17261: The default memcached namespace is "koha"
Bug 17261: Memcached may not longer be running
Bug 17261: Add memcached configuration info to about.pl
Bug 17261: (followup) Rebase against 17189 and 11921
Bug 17261: The default memcached namespace is "koha"
Bug 17261: Memcached may not longer be running
Bug 17261: (followup) Mention the need to start memcached before plack
[PASSED QA] Bug 17261: Add memcached configuration info to about.pl
[PASSED QA] Bug 17261: (followup) Rebase against 17189 and 11921
[PASSED QA] Bug 17261: The default memcached namespace is "koha"
[PASSED QA] Bug 17261: Memcached may not longer be running
[PASSED QA] Bug 17261: (followup) Mention the need to start memcached before plack

Description Tomás Cohen Arazi (tcohen) 2016-09-06 19:23:49 UTC
It would be helpful in several situations to have that information at hand, as we do for other stuff (zebra, apache, plack, etc).
Comment 1 Tomás Cohen Arazi (tcohen) 2016-09-06 19:36:00 UTC Comment hidden (obsolete)
Comment 2 Nick Clemens (kidclamp) 2016-09-07 12:59:34 UTC Comment hidden (obsolete)
Comment 3 Tomás Cohen Arazi (tcohen) 2016-09-07 15:47:58 UTC Comment hidden (obsolete)
Comment 4 Jonathan Druart 2016-09-08 09:07:53 UTC Comment hidden (obsolete)
Comment 5 Jonathan Druart 2016-09-08 09:07:56 UTC Comment hidden (obsolete)
Comment 6 Jonathan Druart 2016-09-13 08:22:29 UTC
Can I get a signoff on the 2 last patches?
Comment 7 Tomás Cohen Arazi (tcohen) 2016-09-13 14:21:00 UTC
Created attachment 55535 [details] [review]
Bug 17261: Add memcached configuration info to about.pl

This patch adds a row in the About > System information tab, showing
the current configuration for memcached.

To test:
- Apply this patch, have memcached configured for the current instance (this is the
  default in kohadevbox)
- Make sure you have the memcached server running:
  $ sudo service memcached start
- Open the about page in the browser
=> SUCCESS: You get something like:
  Memcached:    Servers: 127.0.0.1:11211 | Namespace: koha_kohadev | Status: running
- Stop the memcached server:
  $ sudo service memcached stop
- Reload the about page
=> SUCCESS: You get something like
  Memcached:    Servers: 127.0.0.1:11211 | Namespace: koha_kohadev | Status: not running
- Set both MEMCACHED_* variables in the apache config for intranet the empty string:
  $ sudo vim /etc/apache2/sites-enabled/kohadev.conf
..
   SetEnv MEMCACHED_SERVERS ""
    #"127.0.0.1:11211"
   SetEnv MEMCACHED_NAMESPACE ""
    #"koha_kohadev"
..
- Restart apache:
  $ sudo service apache2 restart
- Reload the about page
=> SUCCESS: You get something like:
  Memcached:  Servers: undefined| Namespace: undefined | Status: unknown
- Sign off :-D

Sponsored-by: ByWater Solutions

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 8 Tomás Cohen Arazi (tcohen) 2016-09-13 14:21:28 UTC
Created attachment 55536 [details] [review]
Bug 17261: (followup) Rebase against 17189 and 11921

This patch adjusts the original one so it works on top of 17189
and 11921. It adds an 'Effective caching method' text which can
be useful, when memcached is not available.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 9 Tomás Cohen Arazi (tcohen) 2016-09-13 14:21:44 UTC
Created attachment 55537 [details] [review]
Bug 17261: The default memcached namespace is "koha"

If no namespace is defined in ENV or the config, "koha" is used as the
default memcached namespace (See Koha::Cache->new)

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 10 Tomás Cohen Arazi (tcohen) 2016-09-13 14:22:01 UTC
Created attachment 55538 [details] [review]
Bug 17261: Memcached may not longer be running

If plack is started with memcached, memcached will be considered as
running, even if it has been stopped (or crashed).
This case should be highlighted on the about page.
Note that I am not sure about the consequences of this specific case!

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 11 Tomás Cohen Arazi (tcohen) 2016-09-13 14:53:20 UTC
Created attachment 55542 [details] [review]
Bug 17261: (followup) Mention the need to start memcached before plack

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 12 Jonathan Druart 2016-09-14 11:56:11 UTC
(In reply to Tomás Cohen Arazi from comment #11)
> Created attachment 55542 [details] [review] [review]
> Bug 17261: (followup) Mention the need to start memcached before plack
> 
> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

I cannot explain what's happening but actually it seems that if you restart memcached without plack, the first request will display "not running", but the second one will display "running".
And it seems to work correctly (i.e. the connection to memcached is restored).
Comment 13 Jacek Ablewicz 2016-09-14 12:27:00 UTC
(In reply to Tomás Cohen Arazi from comment #11)
> Created attachment 55542 [details] [review] [review]
> Bug 17261: (followup) Mention the need to start memcached before plack

It seems that in debian packaged versions, koha script (which brings up starman/plack and now rebuild_zebra.pl in daemon mode too) in /etc/rc* is started before memcached and before mysql..
Comment 14 Jacek Ablewicz 2016-09-14 14:20:32 UTC
On top of Bug 11921, there is a possibility that for a given process or plack worker, "Effective caching method" may be in fact sometimes mixed / various (e.g. memcached used for syspref caching and Cache::Memory for everything else, or vice versa).
Comment 15 Jonathan Druart 2016-10-18 16:04:13 UTC
Jacek, do you think 17261 and 17274 are correct or do they need to be reworked?

I think we are cover all the cases and that should work correctly most of the time.
However it will be bad to display wrong informations...
Comment 16 Katrin Fischer 2016-10-26 23:50:50 UTC
Not sure about the last comment - is this ready for QA?
Comment 17 Tomás Cohen Arazi (tcohen) 2016-10-26 23:56:43 UTC
(In reply to Katrin Fischer from comment #16)
> Not sure about the last comment - is this ready for QA?

I think is ready for QA. The problem is that it is possible to construct a scenario in which each Plack worker has a different memcached situation. It will only mean something is not really ok, and make people look at it. Otherwise, users will have the memcached information which is also handy.
Comment 18 Jacek Ablewicz 2016-10-27 08:01:38 UTC
(In reply to Tomás Cohen Arazi from comment #17)
> (In reply to Katrin Fischer from comment #16)
> > Not sure about the last comment - is this ready for QA?
> 
> I think is ready for QA. The problem is that it is possible to construct a
> scenario in which each Plack worker has a different memcached situation.

Or the scenario when the single plack worker has one of eight different hypothetically possible memcached & Cache::Memory combinations / situations ;)
Comment 19 Jacek Ablewicz 2016-10-27 08:06:15 UTC
(In reply to Tomás Cohen Arazi from comment #17)

> I think is ready for QA.

+1

IMO this patchset is fine as it is, and would be a valuable addition even if it doesn't fully cover some very unusual (and almost purely theoretical) situations.
Comment 20 Jacek Ablewicz 2016-10-27 08:31:15 UTC
(In reply to Jonathan Druart from comment #15)

> I think we are cover all the cases and that should work correctly most of
> the time.

+1, if we want to minimize the possibilities of mixed/inconsistent cache initializations, it would be better to do it differently / in different places, eg.:

- improve memcache initialization procedures (currently each one of 3 cache instances has it's own connection to the memcache server = 3 separate inits when plack worker gets created, each init can have different result)

- at some time, maybe get rid of Cache::Memory entirely? - sooner or later working memcached setup should IMO became a hard requirement (especially under plack)
Comment 21 Katrin Fischer 2016-11-01 15:32:05 UTC
This works for me nicely, until I activate Plack.

Testing in a kohadevbox, started testing without Plack, test plan worked.
Then I started Plack:
sudo koha-plack --enable kohadev
sudo service apache2 restart
sudo koha-plack --start kohadev

About page:
Servers: undefined| Namespace: koha | Status: unknown | Effective caching method: Cache::Memory 

I tried restarting memcached:
sudo service memcached restart

No change - is this to be expected?
Comment 22 Jonathan Druart 2016-11-01 15:49:35 UTC
Everything looks ok for me.

Without memcached and plack configured/set:

 Servers: undefined| Namespace: koha | Status: unknown | Effective caching method: Cache::Memory 

% Edit $KOHA_CONF and add memcached_servers
% sudo service memcached start

 Servers: localhost:11211 | Namespace: koha | Status: running.

% sudo koha-plack --enable kohadev
% sudo koha-plack --start kohadev
% sudo service apache2 restart

 Servers: localhost:11211 | Namespace: koha | Status: running.

% sudo service memcached stop

 Servers: localhost:11211 | Namespace: koha | Status: not running. Remember memcached needs to be started before Plack. 

% sudo service memcached start

 Servers: localhost:11211 | Namespace: koha | Status: not running. Remember memcached needs to be started before Plack. 

% sudo koha-plack --restart kohadev

 Servers: localhost:11211 | Namespace: koha | Status: running.
Comment 23 Katrin Fischer 2016-11-01 16:17:04 UTC
Created attachment 57049 [details] [review]
[PASSED QA] Bug 17261: Add memcached configuration info to about.pl

This patch adds a row in the About > System information tab, showing
the current configuration for memcached.

To test:
- Apply this patch, have memcached configured for the current instance (this is the
  default in kohadevbox)
- Make sure you have the memcached server running:
  $ sudo service memcached start
- Open the about page in the browser
=> SUCCESS: You get something like:
  Memcached:    Servers: 127.0.0.1:11211 | Namespace: koha_kohadev | Status: running
- Stop the memcached server:
  $ sudo service memcached stop
- Reload the about page
=> SUCCESS: You get something like
  Memcached:    Servers: 127.0.0.1:11211 | Namespace: koha_kohadev | Status: not running
- Set both MEMCACHED_* variables in the apache config for intranet the empty string:
  $ sudo vim /etc/apache2/sites-enabled/kohadev.conf
..
   SetEnv MEMCACHED_SERVERS ""
    #"127.0.0.1:11211"
   SetEnv MEMCACHED_NAMESPACE ""
    #"koha_kohadev"
..
- Restart apache:
  $ sudo service apache2 restart
- Reload the about page
=> SUCCESS: You get something like:
  Memcached:  Servers: undefined| Namespace: undefined | Status: unknown
- Sign off :-D

Sponsored-by: ByWater Solutions

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Katrin Fischer  <katrin.fischer@bsz-bw.de>
Comment 24 Katrin Fischer 2016-11-01 16:17:08 UTC
Created attachment 57050 [details] [review]
[PASSED QA] Bug 17261: (followup) Rebase against 17189 and 11921

This patch adjusts the original one so it works on top of 17189
and 11921. It adds an 'Effective caching method' text which can
be useful, when memcached is not available.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Katrin Fischer  <katrin.fischer@bsz-bw.de>
Comment 25 Katrin Fischer 2016-11-01 16:17:12 UTC
Created attachment 57051 [details] [review]
[PASSED QA] Bug 17261: The default memcached namespace is "koha"

If no namespace is defined in ENV or the config, "koha" is used as the
default memcached namespace (See Koha::Cache->new)

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Katrin Fischer  <katrin.fischer@bsz-bw.de>
Comment 26 Katrin Fischer 2016-11-01 16:17:16 UTC
Created attachment 57052 [details] [review]
[PASSED QA] Bug 17261: Memcached may not longer be running

If plack is started with memcached, memcached will be considered as
running, even if it has been stopped (or crashed).
This case should be highlighted on the about page.
Note that I am not sure about the consequences of this specific case!

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Katrin Fischer  <katrin.fischer@bsz-bw.de>
Comment 27 Katrin Fischer 2016-11-01 16:17:19 UTC
Created attachment 57053 [details] [review]
[PASSED QA] Bug 17261: (followup) Mention the need to start memcached before plack

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Katrin Fischer  <katrin.fischer@bsz-bw.de>
Comment 28 Kyle M Hall (khall) 2016-11-02 10:55:38 UTC
Pushed to master for 16.11, thanks Tomas, Jonathan!
Comment 29 Mason James 2016-11-30 08:16:35 UTC
enhancement, passing for 16.05