Skip to content

Missing memcache should not cause occ hard-fail#17663

Merged
MorrisJobke merged 3 commits intomasterfrom
occ-memcache
Jul 17, 2015
Merged

Missing memcache should not cause occ hard-fail#17663
MorrisJobke merged 3 commits intomasterfrom
occ-memcache

Conversation

@RobinMcCorkell
Copy link
Copy Markdown
Member

Warning is now printed to logs, but occ will still work. The memcache factory is primed with null memcaches in this case, so no caching will be performed.

Fixes #17329

cc @MorrisJobke @DeepDiver1975 @RealRancor @rullzer @MightyCreak

BTW, I noticed something a little strange... in case the ownCloud instance isn't installed yet, or debug is enabled, we fall back to using ArrayCache, but the Factory is constructed using ArrayCache instances, while the factory itself needs class names (it initialises the caches itself when required). I think this is a bug? cc @LukasReschke

@ghost
Copy link
Copy Markdown

ghost commented Jul 15, 2015

Can't say something about the code but is this also catching the issue where cron.php is not running because of the missing APC/APCu?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use \OC::$CLI instead and it will fix the cron.php problem too :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah, that's the variable I was looking for!

@MorrisJobke
Copy link
Copy Markdown
Contributor

I tested this and with the proposed change it will also fix the cron stuff. Maybe adjust the log message then to CLI instead of occ

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

info is enough for this in my opinion

@RobinMcCorkell
Copy link
Copy Markdown
Member Author

Screw you too Jenkins

@owncloud-bot retest this please

@MightyCreak
Copy link
Copy Markdown

Since it's not recommended to enable memcache with APCu on CLI, why don't we simply test directly in the factory?

Something like that:

if (\OC::$CLI && $memcache === "APCu") {
    // APCu memcache is not recommended by upstream for CLI.
    return null;
}
else {
    // all good.
    return new Memcache;
}

We could even check for apc.encable_cli so that if the user really want to activate it anyway, we just send a warning saying it's not recommended by upstream, but it's been forced so we obliged.

@RobinMcCorkell
Copy link
Copy Markdown
Member Author

@MightyCreak The problem here isn't specific to APCu, XCache will also have the same problem (it runs in-process too). What's more, the CLI should never need a memcache for operation. The only reason the exception throwing was introduced was due to the idiom that any unavailable service should prevent the OC instance from running, be that LDAP, DB or (now) memcache. For CLI this isn't a problem, so memcache failures shouldn't be a hard-fail.

@MightyCreak
Copy link
Copy Markdown

@Xenopathic Ok, but then why should we catch an exception from \OC\Memcache\Factory? The ifin the catch block should directly be in the Factory function, don't you think?

Catching an exception to handle a case that is not an error seems like a workaround to me. But if everyone is fine with that, then it's fine by me ;)

@RobinMcCorkell
Copy link
Copy Markdown
Member Author

@MightyCreak Hmm, that might be a better idea. Avoiding catch is always a good thing!

Now get back to Mesamatrix and implement new features! 😆

Robin McCorkell added 2 commits July 15, 2015 22:53
Warning is now printed to logs, but occ and cron will still work.
Memcache factory expects a class name, not an instantiated object
@RobinMcCorkell
Copy link
Copy Markdown
Member Author

So I moved the checking logic to the memcache factory, removing the try catch statements. Also modified the wording of the exception text/logging text:

Memcache {class} not available for {use} cache

instead of

Missing memcache class {class} for {use} cache

Also pre-emptively fixed the issue I mentioned in the original post, with the class name vs object.

In case this is worse than what was here before, I'm leaving this commit ID to revert back to: a629f16cacc55227f769acde3c9c46a24a36c600

@scrutinizer-notifier
Copy link
Copy Markdown

A new inspection was created.

@MorrisJobke MorrisJobke added this to the 8.2-current milestone Jul 16, 2015
@MightyCreak
Copy link
Copy Markdown

👍 ^^

@MorrisJobke
Copy link
Copy Markdown
Contributor

Jenkins PR: #17681

@MorrisJobke
Copy link
Copy Markdown
Contributor

Tested and works 👍

MorrisJobke added a commit that referenced this pull request Jul 17, 2015
Missing memcache should not cause occ hard-fail
@MorrisJobke MorrisJobke merged commit f7a78cf into master Jul 17, 2015
@MorrisJobke MorrisJobke deleted the occ-memcache branch July 17, 2015 11:15
@MorrisJobke
Copy link
Copy Markdown
Contributor

@karlitschek Should we backport this to fix the broken behaviour of APCu on CLI for the occ tool? The original ticket was against 8.1.1

@karlitschek
Copy link
Copy Markdown
Contributor

I think a backport would be good 👍

@MorrisJobke
Copy link
Copy Markdown
Contributor

@Xenopathic Can you please backport? Keep in mind: stable8.1 freeze is planned for monday evening ... ;)

@lock lock bot locked as resolved and limited conversation to collaborators Aug 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing memcache class on CLI upgrade

5 participants