quicksketch reports http://skitch.com/quicksketch/dkefx/php-stack-trace
I report that when nextIdDelete fires (shutdown function) from includes/database/mysql/database.inc after a test class is finished in the browser then prefixTables sees the simpletest prefix. Here is a dump once _simpletest_batch_operation is finished from prefixTables (i removed a bunch of newlines from the SQL queries to shorten it:
default prefix
SELECT 1 AS expression FROM {sessions} sessions WHERE (sid = :db_condition_placeholder_0) FOR UPDATE
default prefix
UPDATE {sessions} SET uid=:db_update_placeholder_0, cache=:db_update_placeholder_1, hostname=:db_update_placeholder_2, session=:db_update_placeholder_3, timestamp=:db_update_placeholder_4 WHERE (sid = :db_condition_placeholder_0)
default prefix
SELECT data, created, expire, serialized FROM {cache_bootstrap} WHERE cid = :cid
default prefix
SELECT 1 AS expression FROM {cache_bootstrap} cache_bootstrap WHERE (cid = :db_condition_placeholder_0) FOR UPDATE
default prefix
UPDATE {cache_bootstrap} SET serialized=:db_update_placeholder_0, created=:db_update_placeholder_1, expire=:db_update_placeholder_2, data=:db_update_placeholder_3 WHERE (cid = :db_condition_placeholder_0)
default prefix
UPDATE {batch} SET batch=:db_update_placeholder_0 WHERE (bid = :db_condition_placeholder_0)
default prefix simpletest652543
SELECT MAX(value) FROM {sequences}
That's a db_merge from sessions, then a cache_set for cache_bootstrap, a batch refresh and then nextIdDelete. The right question to ask is why this function fires? It only got called during system install and we presumedly restore the shutdown functions. A dump of drupal_register_shutdown_function does not show nextIdDelete however.
Comment | File | Size | Author |
---|---|---|---|
#25 | graham_number_of_comments.patch | 1.92 KB | chx |
#23 | graham_number_of_comments2.patch | 2.08 KB | Berdir |
#22 | graham_number_of_comments.patch | 2.01 KB | chx |
#15 | ignore_errors.patch | 1.89 KB | chx |
#12 | ignore_errors.patch | 1.78 KB | chx |
Comments
Comment #1
chx CreditAttribution: chx commentedWith less debug.
Comment #2
catchouch.
Comment #3
chx CreditAttribution: chx commentedFiled #840194: We still do not catch all exceptions separately.
Comment #4
Dries CreditAttribution: Dries commentedGood catch. Committed to CVS HEAD. Thanks!
Comment #5
BerdirWe (I, requested by Crell) did not use drupal_register_shutdown_function() on purpose to avoid adding more dependencies. But as this has shown, it's needed, so...
Comment #6
Crell CreditAttribution: Crell commentedAs Berdir notes, not using drupal_register_shutdown_function() there was very deliberate. chx, from your description I don't quite follow why we have to use it here. That's another hard dependency between subsystems that we have gone to great lengths to avoid.
Comment #7
BerdirThe fix is correct (unfortunately ;)).
We clear the shutdown functions after a test run has finished so that they don't run in the original environment (and database)*. We can only do that with functions registered with drupal_register_shutdown_function() as we don't have any influence on those registered with register_shutdown_function().
* I just learned that in this issue, this was new to me too but makes sense. If that wouldn't be the case, we could use register_shutdown_function() and use try/catch to handle any exceptions.
Edit: I wonder if Crell is automatically subscribed to an issue when someone writes down his nickname in a comment... ;)
Comment #8
Damien Tournoud CreditAttribution: Damien Tournoud commentedNo sorry, the fix is wrong.
It is by design that we are getting a prefixed database here. We just need to ignore the exceptions that might be thrown during the cleanup process.
Comment #9
BerdirYes, the prefixed database is by design.
However, the query should never run because it is supposed to be run in the test database and simpletest is responsible for cleaning up the shutdown functions. It can do that only if drupal_register_shutdown_function() is used so I don't see what's wrong with the fix.
In theory, to fully simulate an installation, simpletest could execute the shutdown functions *before* the test database is deleted but it doesn't matter since the whole install is deleted anyway.
That we get these unholy "exception thrown without stackstrace" errors again/still is a different issue and looked at in the other issue.
Comment #10
chx CreditAttribution: chx commentedHrm.
Comment #11
Crell CreditAttribution: Crell commentedI think I still prefer DamZ's suggestion in #8. If the cleanup query fails there's no serious harm, it will only happen if the DB goes away mid-process which only happens during simpletest, and it introduces no dependencies, hard or soft, on the Drupal layers above it.
Comment #12
chx CreditAttribution: chx commentedSure thing. I wrote this patch too before posting the other. :)
Comment #13
Dries CreditAttribution: Dries commentedOopsie! Glad we're fixing it already. :)
Could we mention why it is called with the wrong prefix?
Comment #14
Crell CreditAttribution: Crell commentedThere should also be a period, not a comma, in "ignoring errors here, if these queries".
Other than that and Dries' comment comment (is that a meta comment), I'm good with #12.
Comment #15
chx CreditAttribution: chx commentedNo :D good god. that's difficult to explain.
Comment #16
mcrittenden CreditAttribution: mcrittenden commentedShould be tables.
Two spaces between "called" and "so"
Not a proper sentence.
Comment #17
webchickWhile we're at it, let's comment
this change to indicate that we're intentionally not going through drupal_register_shutdown_function(), so that someone later on doesn't try and "fix" this.
Comment #18
carlos8f CreditAttribution: carlos8f commented@mcrittenden
A literal reference should be surrounded in quotes: "tables".
This needs a period at the end.
"Not a proper sentence." is not a proper sentence :)
Comment #19
Damien Tournoud CreditAttribution: Damien Tournoud commentedI do not comment on meta-comments.
That was a meta-comment.
Comment #20
carlos8f CreditAttribution: carlos8f commented#18 implements hook_humor()
Comment #21
Crell CreditAttribution: Crell commentedI will refrain from commenting on DamZ's lack of comment about carlos8f's comment regarding mcrittenden's comments about the code comments in the latest patch.
Comment #22
chx CreditAttribution: chx commentedComment #23
BerdirRemoved a trailing whitespace and added () to the function in the comment.
Comment #24
tstoecklerneed -> no need
I don't want to start another commenting avalanche, but this typo is really confusing.
Leaving at needs review for more reviews (...), but the next reroll should fix that.
Powered by Dreditor.
Comment #25
chx CreditAttribution: chx commentedyou surely are aware that was there in HEAD and I just indented it?
Comment #26
Crell CreditAttribution: Crell commentedQuick, before someone else comments!
Comment #27
tstoecklerNo I wasn't. Dreditor makes it too easy to ignore the deleted lines...
+1 on the RTBC as someone without deeper insight into either the DB-system or SImpleTest (=== 'me') can grasp the patch and its reasoning from the inline comments.
Comment #28
webchickAdded a comma between
$this->connection
andand
;), and committed to HEAD. thanks!Yay, testbot! So good to have you back!