Skip to content
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

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'backdrop.simpletest[xxxxx]semaphore' doesn't exist #5943

Open
klonos opened this issue Jan 18, 2023 · 5 comments

Comments

@klonos
Copy link
Member

klonos commented Jan 18, 2023

I can consistently reproduce this on my local, with the latest 1.x (reported as 1.25.x-dev), on php 8.0.26, but haven't been able to reproduce on a demo sandbox (still running core 1.23.1 on php 7.4.33).

  1. Enable the "Testing" (simpletest) module
  2. Head to admin/config/development/testing and try to run any test -> everything's OK 👍🏼
  3. Enable the "Language" module
  4. Head to admin/config/regional/language and add any language
  5. Head to admin/config/development/testing and try to run any test again -> error 👎🏼

Full error:

An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows.
Path: /batch?id=4&op=do_nojs&op=do StatusText: error ResponseText: PDOException:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'backdrop.simpletest804726semaphore'
doesn't exist: SELECT expire, value FROM {semaphore} WHERE name = :name;
Array ( [:name] => locale_cache_en ) in lock_may_be_available()
(line 166 of /app/docroot/core/includes/lock.inc).
Uncaught exception thrown in session handler.PDOException: SQLSTATE[42S02]:
Base table or view not found: 1146 Table 'backdrop.simpletest804726sessions'
doesn't exist: UPDATE {sessions} SET `uid`=:db_update_placeholder_0,
`hostname`=:db_update_placeholder_1, `session`=:db_update_placeholder_2,
`timestamp`=:db_update_placeholder_3 WHERE ( (`sid` = :db_condition_placeholder_0) AND
(`ssid` = :db_condition_placeholder_1) ); Array ( [:db_update_placeholder_0] =>
1 [:db_update_placeholder_1] => 172.20.0.2 [:db_update_placeholder_2] =>
batches|a:2:{i:3;b:1;i:4;b:1;} [:db_update_placeholder_3] =>
1674042925 [:db_condition_placeholder_0] => iDBpsz6yPGbe_RWx5E5XTTdHesdM70FMz4QFumuW1Ag
[:db_condition_placeholder_1] => iDBpsz6yPGbe_RWx5E5XTTdHesdM70FMz4QFumuW1Ag )
in _backdrop_session_write() (line 206 of /app/docroot/core/includes/session.inc).
Warning: Undefined array key 0 in /app/docroot/core/includes/errors.inc on line 282
Warning: Undefined array key "line" in
/app/docroot/core/modules/simpletest/backdrop_web_test_case.php on line 227
Warning: Undefined array key "file" in
/app/docroot/core/modules/simpletest/backdrop_web_test_case.php on line 228
Fatal error: Uncaught PDOException: SQLSTATE[23000]:
Integrity constraint violation: 1048 Column 'line' cannot be null in
/app/docroot/core/includes/database/database.inc:2285 Stack trace:
#0 /app/docroot/core/includes/database/database.inc(2285): PDOStatement->execute(Array)
#1 /app/docroot/core/includes/database/database.inc(717):
DatabaseStatementBase->execute(Array, Array)
#2 /app/docroot/core/includes/database/mysql/query.inc(34):
DatabaseConnection->query('INSERT INTO {si...', Array, Array)
#3 /app/docroot/core/modules/simpletest/backdrop_web_test_case.php(235):
InsertQuery_mysql->execute()
#4 /app/docroot/core/modules/simpletest/backdrop_web_test_case.php(533):
BackdropTestCase->assert('exception', 'Unknown: Failed...', 'Warning', Array)
#5 /app/docroot/core/modules/simpletest/backdrop_web_test_case.php(679):
BackdropTestCase->error('Unknown: Failed...', 'Warning', Array)
#6 [internal function]: BackdropTestCase->errorHandler(2, 'Unknown: Failed...', 'Unknown', 0)
#7 {main} thrown in /app/docroot/core/includes/database/database.inc on line 2285
@argiepiano
Copy link

I've seen this a few times when running tests in my local, after a test goes completely haywire - something goes very wrong and the semphahore table that Backdrop creates for the testing environment is somehow removed and not created again when running the test again . Even after pressing "Clean environment", this thing still happened. The solution for me has been to completely uninstall Testing and reinstall it. But I never noticed any connection with Language.

Worth testing and looking into...

@argiepiano
Copy link

One more data point: I've been able to reproduce this crash consistently in my local if I enable Locale and run any test.

Disabling Locale and clearing the testing environment seems to bring things back to normal with tests. So, while I haven't looked into the code, I think there are two things going on: 1. Locale has something that crashes the testing environment, and 2. Once it crashes, you start getting the semaphore error if you try running tests again, even after clearing the environment.

Disabling Locale and clearing the environment gets the testing back on track for me.

So, definitely something going on with Locale. I'm testing with PHP 7.4

@indigoxela
Copy link
Member

Yes, that's a known problem. At least, I know it. Wonder, why I didn't open an issue for this yet. (Possibly did?)

@klonos
Copy link
Member Author

klonos commented Jan 18, 2023

Thanks for taking the time to report back @argiepiano and @indigoxela 🙏🏼

The solution for me has been to completely uninstall Testing and reinstall it.

Tried that, but it didn't work in my case 🤔

...I never noticed any connection with Language.

Yup, if I run the tests on vanilla, things work fine. Soon as I enable the Language module AND add a language, this starts happening. If I disable the Language module (no need to fully uninstall it), things start working again. So odd.

I've been able to reproduce this crash consistently in my local if I enable Locale and run any test.

I'm guessing that this is because Locale depends on Language, so you need to enable that as well - I still think it's related to the Langue module, since it happens when I enable that alone. I've been trying to run LanguageListTest myself (troubleshooting a single remaining failure in the PR for #3422 if t matters).

...Wonder, why I didn't open an issue for this yet. (Possibly did?)

That's my thing, so here's an issue for you 😅 ...before opening this one, I tried searching the queue with various related terms, including semaphore. Nothing apparently related came up. ...now wondering if #4518 has anything to do with it 🤔

@klonos
Copy link
Member Author

klonos commented Jan 18, 2023

...now wondering if #4518 has anything to do with it 🤔

What do you know?! ... @docwilmot in that issue suggested the following:

Interesting. Could you add require_once BACKDROP_ROOT . '/' . settings_get('lock_inc', 'core/includes/lock.inc'); to install_begin_request() (somewhere after the line backdrop_bootstrap(BACKDROP_BOOTSTRAP_CONFIGURATION);) and recheck?

And doing just that fixes the issue! 🎉 (for me at least)

Anyway, with this fix/workaround, I am now unblocked for what I was trying to do, so I'll leave this issue here to the experts 😅 ...I hope that all this investigation/testing/troubleshooting will be enough to help them figure things out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants