Skip to content

Default the failure limit to 1 as zero is an invalid value - #3

Merged
GwendolenLynch merged 1 commit into
1.1from
rossriley-patch-1
Feb 25, 2018
Merged

GwendolenLynch merged 1 commit into
1.1from
rossriley-patch-1

Conversation

@rossriley

Copy link
Copy Markdown
Member

Fixes: bolt/bolt#7357

The default of zero throws an invalid argument error despite the Memcached docs indicating that this should be a valid value.

The default of zero throws an invalid argument error despite the Memcached docs indicating that this should be a valid value.

libmemcached requires `MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT` to be a non-zero integer:
 - https://bazaar.launchpad.net/~tangent-trunk/libmemcached/1.0/view/head:/libmemcached/behavior.cc?start_revid=1194#L114

The globals initialization function default to `1`
 - https://github.com/php-memcached-dev/php-memcached/blob/v3.0.4/php_memcached.c#L4081)
@GwendolenLynch

GwendolenLynch commented Feb 23, 2018 •

Copy link
Copy Markdown
Contributor

Are you sure? From http://php.net/manual/en/memcached.constants.php

Memcached::OPT_SERVER_FAILURE_LIMIT
Specifies the failure limit for server connection attempts. The server will be removed 
after this many continuous connection failures.

Type: integer, default: 0.

@GwendolenLynch

Copy link
Copy Markdown
Contributor

Also, I'll grab the CI failures in the morning if that is OK … obviously not related to this.

@rossriley

Copy link
Copy Markdown
Member Author

Yes, sorry should have mentioned, there's a bug in the php docs.

To verify:

echo '<?php $m = new Memcached; $m->setOption(21,0);' | php

And you'll get:

PHP Warning: Memcached::setOption(): error setting memcached option: INVALID ARGUMENTS in - on line 1

Change the zero to 1 or more and all goes through ok.

GwendolenLynch
GwendolenLynch previously approved these changes Feb 24, 2018
@codecov-io

codecov-io commented Feb 24, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #3 into 1.1 will not change coverage.
The diff coverage is 100%.

Impacted Files Coverage Δ Complexity Δ
src/Handler/Factory/MemcachedFactory.php 93.37% <100%> (ø) 52 <0> (ø) ⬇️

@GwendolenLynch

Copy link
Copy Markdown
Contributor

OK, this took a bit to track down what is going on upstream.

What I see happening is that libmemcached requires MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT to be a non-zero integer … easy enough, right?!

But in the current stable, we have

MEMC_SESSION_INI_ENTRY("server_failure_limit", "0", OnUpdateLongGEZero, server_failure_limit)

Intreagued yet? I was 😄

So then looking at the globals initialization function it seems they default to 1.

Soooooo … my question now becomes, is 5 too high a value for the default?

@bobdenotter

Copy link
Copy Markdown
Member

I think 1 could work just as well, as a default. Main improvement is no breakage, and if people need a different value, they can just set it.

@GwendolenLynch GwendolenLynch changed the title Default the failure limit to 5 as zero is an invalid value Default the failure limit to 1 as zero is an invalid value Feb 25, 2018
@GwendolenLynch
GwendolenLynch merged commit f7b5fd6 into 1.1 Feb 25, 2018
@GwendolenLynch
GwendolenLynch deleted the rossriley-patch-1 branch February 25, 2018 09:49
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.

4 participants