Skip to content

setMulti failed to set key, set works normal? #409

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

Closed
duronrulez opened this issue Oct 18, 2018 · 1 comment · Fixed by #490
Closed

setMulti failed to set key, set works normal? #409

duronrulez opened this issue Oct 18, 2018 · 1 comment · Fixed by #490

Comments

@duronrulez
Copy link

As the title says, when we're using "setMulti" at some point (randomly?) the memcached lib starts spitting out "failed to set key" warnings. While when we use "set" its all normal and works fine all the time.

Is there any difference in the implementation of setMulti and set? From what i understand (havent read the code) under the hood setMulti is doing a cycle and running set anyway?

@Krinkle
Copy link
Contributor

Krinkle commented Aug 18, 2021

This warning is logged by Memcached::setMulti when the s_memc_write_zval() call for one of the keys returns false, which presumably means Memcached was unable to store that key (source code). This is not uncommon and could happen for a number of reasons such as value being too large, unable to be serialized, a timeout, temporary connection issue perhaps, etc.

This warning was added to setMulti in commit a930b41 (pull request #214), first released in php-memcached 3.0.0 and generally used alongside PHP 7.

The Memcached::set() method uses that same s_memc_write_zval() function for storing data, but when it returns false there, no warning is logged in response. So..., I guess the take-away here is that the library has not regressed in php-memcached 3.0.0, and that setMulti is not buggy. It's just that setMulti logs a warning for a seemingly normal runtime condition when storing a key fails, whereas other methods of storing a key do not log such warning.

I do note that the details of these error scenarios are available via ::getResultCode and ::getResultMessage, and this hasn't changed in recent years. Any code you have in place for finding and reporting such background errors will work fine regardless of this setMulti warning. It seems like this was perhaps just added by mistake in #214 and could be removed in in a future release. As a workaround, to improve error signal in your application, one could suppress this warning by using the error control operator specifically when calling setMulti().

Downstream issue for Wikimedia Foundation: T251450.

Krinkle added a commit to Krinkle/php-memcached that referenced this issue Aug 18, 2021
This was introduced in 6837d89494,
pull php-memcached-dev#214. I suspect it
may have been a left-over from debugging something. The test was later
changed in 6837d89 to expect the warning in question, although other
similar tests don't encounter such warning currently.

It appears no other Memcached methods emit a PHP Warning when they encounter
a write read or failure. Instead, they typically turn their return value
into boolean false, and provide details via getResultMessage().

The introduction of this warning since php-memcached 3.0 has led to a number
of confused consumers (locally php-memcached-dev#260, php-memcached-dev#409, php-memcached-dev#450, and more reports
within downstream issue trackers).

Closes php-memcached-dev#409.
Krinkle added a commit to Krinkle/php-memcached that referenced this issue Aug 18, 2021
This was introduced in 6837d89494,
pull php-memcached-dev#214. I suspect it
may have been a left-over from debugging something. The test was later
changed in 6837d89 to expect the warning in question, although other
similar tests don't encounter such warning currently.

It appears no other Memcached methods emit a PHP Warning when they encounter
a write read or failure. Instead, they typically turn their return value
into boolean false, and provide details via getResultMessage().

The introduction of this warning since php-memcached 3.0 has led to a number
of confused consumers (locally php-memcached-dev#260, php-memcached-dev#409, php-memcached-dev#450, and more reports
within downstream issue trackers).

Closes php-memcached-dev#409.
Krinkle added a commit to Krinkle/php-memcached that referenced this issue Aug 18, 2021
This was introduced in 6837d89494,
pull php-memcached-dev#214. I suspect it
may have been a left-over from debugging something. The test was later
changed in 6837d89 to expect the warning in question, although other
similar tests don't encounter such warning currently.

It appears no other Memcached methods emit a PHP Warning when they encounter
a write read or failure. Instead, they typically turn their return value
into boolean false, and provide details via getResultMessage().

The introduction of this warning since php-memcached 3.0 has led to a number
of confused consumers (locally php-memcached-dev#260, php-memcached-dev#409, php-memcached-dev#450, and more reports
within downstream issue trackers).

Closes php-memcached-dev#409.
Krinkle added a commit to Krinkle/php-memcached that referenced this issue Aug 18, 2021
This was introduced in php-memcached-dev@6837d89494,
pull php-memcached-dev#214. I suspect it
may have been a left-over from debugging something. The test was later
changed in 6837d89 to expect the warning in question, although other
similar tests don't encounter such warning currently.

It appears no other Memcached methods emit a PHP Warning when they encounter
a write read or failure. Instead, they typically turn their return value
into boolean false, and provide details via getResultMessage().

The introduction of this warning since php-memcached 3.0 has led to a number
of confused consumers (locally php-memcached-dev#260, php-memcached-dev#409, php-memcached-dev#450, and more reports
within downstream issue trackers).

Closes php-memcached-dev#409.
sodabrew pushed a commit that referenced this issue Aug 23, 2021
This was introduced in 6837d89494,
pull #214. I suspect it
may have been a left-over from debugging something. The test was later
changed in 6837d89 to expect the warning in question, although other
similar tests don't encounter such warning currently.

It appears no other Memcached methods emit a PHP Warning when they encounter
a write read or failure. Instead, they typically turn their return value
into boolean false, and provide details via getResultMessage().

The introduction of this warning since php-memcached 3.0 has led to a number
of confused consumers (locally #260, #409, #450, and more reports
within downstream issue trackers).

Closes #409.
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 a pull request may close this issue.

2 participants