Varying-Vagrant-Vagrants / VVV

An open source Vagrant configuration for developing with WordPress
https://varyingvagrantvagrants.org
MIT License
4.54k stars 847 forks source link

Bug: MongoDB error when attempting to use Tideways on fresh install #2697

Open arose-wt opened 10 months ago

arose-wt commented 10 months ago

Are you using the latest stable or develop branch version of VVV?

Yes (develop)

Is it a new VVV, or an existing VVV that used to work?

New fresh install

Did you use a CustomFile?

No (default)

Whats the problem?

Setup details:

Changes in config/config.yml:

extensions:
  core: # The core VVV extensions
    - tls-ca # HTTPS SSL/TLS certificates
    - phpmyadmin # Web based database client
    #- memcached-admin # Object cache management
    #- opcache-status # opcache management
    #- webgrind # PHP Debugging
    - mongodb # needed for Tideways/XHGui
    - tideways # PHP profiling tool, also installs xhgui check https://varyingvagrantvagrants.org/docs/en-US/references/tideways-xhgui/
    #- nvm # Node Version Manager
    #- php56
    #- php70
    #- php71
    #- php72
    #- php73
    #- php74
    #- php80

What occurs:

The vagrant up --provision output gets riddled with the Unable to load dynamic library 'mongodb.so' warning shown below.

Trying to access tideways.vvv.test results in the slim application error shown below.

vagrant up --provision log:

...
==> default: Running provisioner: extension-core-mongodb (shell)...
    default: Running: C:/Users/Arianna/AppData/Local/Temp/vagrant-shell20240110-24492-2h92y3.sh
    default:  ▷ Running the 'extension-core-mongodb' provisioner...
    default: Warning: apt-key output should not be parsed (stdout is not a terminal)
    default: Warning: apt-key output should not be parsed (stdout is not a terminal)
    default: Created symlink /etc/systemd/system/multi-user.target.wants/mongod.service → /lib/systemd/system/mongod.service.
    default:  ✔ The 'extension-core-mongodb' provisioner completed in 54 seconds.
==> default: Running provisioner: extension-core-tideways (shell)...
    default: Running: C:/Users/Arianna/AppData/Local/Temp/vagrant-shell20240110-24492-xuewwu.sh
    default:  ▷ Running the 'extension-core-tideways' provisioner...
    default: PHP Warning:  PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /usr/lib/php/20220829/mongodb.so (/usr/lib/php/20220829/mongodb.so: cannot open shared object file: No such file or directory), /usr/lib/php/20220829/mongodb.so.so (/usr/lib/php/20220829/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    default: PHP Warning:  PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /usr/lib/php/20220829/mongodb.so (/usr/lib/php/20220829/mongodb.so: cannot open shared object file: No such file or directory), /usr/lib/php/20220829/mongodb.so.so (/usr/lib/php/20220829/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    default: HEAD is now at 5b8516b Merge pull request #468 from kornrunner/0.21.x
    default: PHP Warning:  PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /usr/lib/php/20220829/mongodb.so (/usr/lib/php/20220829/mongodb.so: cannot open shared object file: No such file or directory), /usr/lib/php/20220829/mongodb.so.so (/usr/lib/php/20220829/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    default: Loading composer repositories with package information
    default: Updating dependencies
    default: Nothing to modify in lock file
    default: Installing dependencies from lock file (including require-dev)
    default: Nothing to install, update or remove
    default: Package perftools/xhgui-collector is abandoned, you should avoid using it. No replacement was suggested.
    default: Generating autoload files
    default: No security vulnerability advisories found.
    default: Cloning into '/var/local/tideways-php'...
    default: /var/local/tideways-php7.4/tracing.c: In function ‘tracing_callgraph_get_parent_child_name’:
    default: /var/local/tideways-php7.4/tracing.c:186:38: warning: zero-length gnu_printf format string [-Wformat-zero-length]
    default:   186 |         snprintf(symbol, symbol_len, "");
    default:       |                                      ^~
    default: /var/local/tideways-php8.2/tracing.c: In function ‘tracing_callgraph_get_parent_child_name’:
    default: /var/local/tideways-php8.2/tracing.c:186:38: warning: zero-length gnu_printf format string [-Wformat-zero-length]
    default:   186 |         snprintf(symbol, symbol_len, "");
    default:       |                                      ^~
    default: PHP Warning:  PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /usr/lib/php/20220829/mongodb.so (/usr/lib/php/20220829/mongodb.so: cannot open shared object file: No such file or directory), /usr/lib/php/20220829/mongodb.so.so (/usr/lib/php/20220829/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    default:  ✔ The 'extension-core-tideways' provisioner completed in 129 seconds.
...

full output

Slim Application Error when attempting to access the url for tideways:

Notice: Undefined index: tableWatch in /srv/www/default/xhgui/src/ServiceProvider/PdoStorageProvider.php on line 55

full output

Additional info:

That tideways error also occurred when I had uncommented tideways in extensions/core but hadn't yet uncommented mongodb so, while it may well also be an issue, I am assuming it is unrelated to the mongodb.so issue.

How do we reproduce it?

  1. Run git clone -b stable https://github.com/Varying-Vagrant-Vagrants/VVV.git ~/vvv-local
  2. Run cd ~/vvv-local
  3. Run vagrant plugin install --local
  4. Uncomment - mongodb and - tideways (lines 87 and 88, respectively) in config/config.yml
  5. Run vagrant up --provision

(Terminal displays error)

  1. Open browser and go to one.wordpress.test?enable-tideways=1
  2. Open a new tab and go to tideways.vvv.test

(Tideways error appears)

What is the output of vagrant status

__ __ __ __
\ V\ V\ V / v3.13 Ruby:3.1.3, Path:"C:/Users/Arianna/repos/vvv-fresh"
 \_/\_/\_/  git::develop(4ba78d6a)

Platform: mingw32 windows  missingWinAdminPriv  vagrant-goodhosts monochrome-terminal shared_db_folder_disabled
Vagrant: v2.4.0, virtualbox: v7.0.12

Which Operating System are you using?

Microsoft Windows

Which provider are you using?

VirtualBox 7

welcome[bot] commented 10 months ago

Thanks for opening your first issue here! Be sure to follow the issue template and include your OS/Vagrant/VVV versions! Don't forget you can get support in the VVV slack at https://varyingvagrantvagrants.org/docs/en-US/slack/

VVV
VVV Slack Workspace
Join the VVV Slack Workspace
tomjn commented 10 months ago

That tideways error also occurred when I had uncommented tideways in extensions/core but hadn't yet uncommented mongodb so, while it may well also be an issue, I am assuming it is unrelated to the mongodb.so issue.

My understanding of the Tideways provisioner was that if MongoDB wasn't installed that it would run the MongoDB provisioner to ensure this.

@Mte90 do you have any thoughts? It's been a while since I used Tideways myself.

The other thing that could have impacted this is PHP versions

tomjn commented 10 months ago

I've opened https://github.com/Varying-Vagrant-Vagrants/vvv-utilities/pull/108 to handle Tideways in PHP v8.3, though the default PHP isn't 8.3 so it shouldn't impact this bug

arose-wt commented 10 months ago

Actually this seems to be a known issue with php 8.1 (and, presumably, 8.2 and 8.3): https://bugs.launchpad.net/ubuntu/+source/php-mongodb/+bug/1992999

Short StackOverflow discussion on the matter: https://askubuntu.com/questions/1434953/unable-to-load-dynamic-library-mongodb-so-tried-usr-lib-php-20210902-mongod

I'm going to test with 8.0 and 7.x versions and see where I get.

Launchpad
Bug #1992999 “php8.1-mongodb: mongodb.so parse error at php sta...” : Bugs : php-mongodb package : Ubuntu
I installed a fresh image of 22.04.1 on a Hetzner cloud server apt update && apt upgrade -y and additional apt install php8.1-cli php8.1-mongodb then php-v PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /usr/lib/php/20210902/mongodb.so (/usr/lib/php/20210902/mongodb.so: undefined symbol: ns_parserr), /usr/lib/php/20210902/mongodb.so.so (/usr/lib/php/20210902/mongodb.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 like I ...
Ask Ubuntu
Unable to load dynamic library 'mongodb.so' (tried: /usr/lib/php/20210902/mongodb.so on fresh 22.04.1 LTS
I installed a fresh image updated and upgraded apt nginx-common php8.1-cli php8.1-fpm php8.1-mongodb PHP -v PHP Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: /usr/lib/...
tomjn commented 10 months ago

So we have mongodb because it's how perftools/xhgui-collector stores the data, but that package is deprecated and replaced by https://github.com/perftools/php-profiler which supports other mechanisms such as files etc. This might let us remove mongodb as a dependency.

In the past we've explored this only to find that MongoDB is necessary for certain xhgui features, as were certain versions of PHP

GitHub
GitHub - perftools/php-profiler: A PHP profiling library based on XHGUI Data Collector
A PHP profiling library based on XHGUI Data Collector - GitHub - perftools/php-profiler: A PHP profiling library based on XHGUI Data Collector
tomjn commented 10 months ago

it looks like this is the preferred storage mechanism now https://github.com/perftools/php-profiler?tab=readme-ov-file#upload-saver

I also forgot that we'd already made the switch over and use PDO, so maybe mongodb isn't needed afterall? @Mte90 is removing mongodb feasible?

GitHub
GitHub - perftools/php-profiler: A PHP profiling library based on XHGUI Data Collector
A PHP profiling library based on XHGUI Data Collector - GitHub - perftools/php-profiler: A PHP profiling library based on XHGUI Data Collector
tomjn commented 10 months ago

nevermind I realise now it's XHGUI that's the problem, not the collector, it supports MongoDB or PDO but using PDO removes features from the GUI, and composer expects the mongo PHP extension.

On the plus side they explicitly support 8.0/8.1 now

arose-wt commented 10 months ago

I'm seeing now that PDO is set as the default db option for tideways in VVV's xhgui config.

www\default\xhgui\config\config.php:

$defaults = array(
    'debug' => false,
    'save.handler' => 'pdo',
...

Meaning that what I have seen are separate errors.

MongoDB warning

  1. MongoDB has a warning where it is looking for its .so file but it does not exist (I haven't been able to find the file anywhere under /etc/php/ nor /usr/lib/php). Provisioning a machine with the mongodb extension (as set by config.yml) will trigger this warning, as will running mongo --version on the machine after it finishes provisioning. I am unsure what the consequences of this warning are. This issue occurs even when I explicitly set my site to use php7.0.
  2. Following the previous numbered point, if I set the save.handler in xhgui's config to be mongo.db, I get a 500 internal server error, with no additional user-side information, as soon as I try to access tideways.vvv.test while my site is up.

XHGUI/Tideways error/misbehaviour

  1. If I leave save.handler as pdo (its default), accessing tideways.vvv.test gives me the error I listed here.
  2. Following the previous numbered point, if I modify xhgui's pdo config (adding the tableWatch parameter to make the custom config closer to the default config in www\default\xhgui\config\config.default.php), that removes the 500 error but tideways.vvv.test will instead say Looks like you haven't done any profiling when I refresh--even after I visit one.wordpress.test?enable-tideways=1.

www\default\xhgui\config\config.php modification:

    'pdo' => array(
        'dsn' => 'sqlite:/tmp/xhgui.sqlite3',
        'user' => null,
        'pass' => null,
        'table' => 'results',
        'tableWatch' => 'watches'
    ),
tomjn commented 10 months ago

If I leave save.handler as pdo (its default), accessing tideways.vvv.test gives me the error I listed here.

My editors really struggle with that file but it's missing the error message and only contains the stack trace

MongoDB warning

This implies MongoDB can be jettisoned

arose-wt commented 10 months ago

My editors really struggle with that file but it's missing the error message and only contains the stack trace

Ah! My bad.

Here's the error belonging to that stack trace: Notice: Undefined index: tableWatch in /srv/www/default/xhgui/src/ServiceProvider/PdoStorageProvider.php on line 55

tomjn commented 10 months ago

0.21.3 is the latest version but our provisioner is pinned with:

noroot git checkout "0.20.4"

does checkout out the 0.21.3 tag help with this?

tomjn commented 10 months ago

https://github.com/Varying-Vagrant-Vagrants/vvv-utilities/pull/108 updates the PHP version used to install xhgui and the version it installs

arose-wt commented 10 months ago

Unfortunately the above error occurs even after changing the provisioner script to pull xhgui 0.21.3 and when including the changes from https://github.com/Varying-Vagrant-Vagrants/vvv-utilities/pull/108. Similarly, manually including the tableWatch parameter also still results in the same message ("Looks like you haven't done any profiling").

tomjn commented 10 months ago

@arose-wt that's a shame, would you consider those changes an improvement though? Or did they introduce new issues? I'd like to see if they can be merged so we can continue debugging from a better place, and it sounds like we need to adjust the docs to remove the mongodb mention

tomjn commented 10 months ago

Similarly, manually including the tableWatch parameter also still results in the same message ("Looks like you haven't done any profiling").

If you can do a quick PR upstream for that, I think the message about not getting any profiling is probably a separate issue related to our collector

tomjn commented 10 months ago

I've merged both PRs, does all work as expected for you?

arose-wt commented 10 months ago

| I've merged both PRs, does all work as expected for you?

I'm having unrelated system issues with my system's ssh/ssh-agent at the moment. But when I was testing yesterday I had already made the changes, that were included in both PRs, locally, and still had the same outcomes occur. (See my previous comment here)