Details
-
Type:
Sub-task
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 2.0
-
Fix Version/s: 2.0
-
Component/s: Database SQL/XMLDB
-
Labels:None
-
Database:Oracle
-
Difficulty:Difficult
-
Affected Branches:MOODLE_20_STABLE
-
Fixed Branches:MOODLE_20_STABLE
Description
While developing the Moodle 2.0 oracle native driver both Petr and me have ended with some "random" bugs happening when executing 100% trivial queries in DB functional tests.
After some research, it seems that the creation/dropping/creation of one table multiple times with some difference in columns between both creations cause any "SELECT *" operation in the table to break badly with one not-self-explaining at all error ORA-01007: variable not in select list
After searching for that error, at all levels, I found some comments in one thread about OCI-C, commenting about cached metadata being the responsible of those errors, so... I set:
oci8.statement_cache_size = 0
in my php.ini file and then, all the problems magically disappeared. So it seems that the PHP driver is caching some statements and, if any change happens in the underlying tables (add/drop on field, or recreate the table with same name and other specs), the cache doesn't become invalidated and next cached query fails with the silly "ORA-01007: variable not in select list" error. At least the driver should give us some option to invalidate the cache (or do that automatically).
And I've reproduced it under PHP 5.2.10 running the latest OCI 1.2.5 driver
So I'm going to:
1) Create one PHP script, for use in Moodle 2.0 with oci_native_driver configured able to reproduce the problem.
2) Create one PHP script, for standalone use, using the low level oci driver able to reproduce the problem.
3) Send the standalone script to the PHP bugs.
4) Try to use a newer OCI driver (1.3.5 is current one) from PECL to see if the problem continues happening.
5) If no solution arrives, we'll need to check for the value of that setting (oci8.statement_cache_size), recommending 0 as the value to set. After all, in our non-persistent conections, that cache isn't supposed to help in a noticeable way, afaik.
I've attached one simple script (testing_oci_stmt_cache_moodle.php) able to reproduce the problem by forcing one table to be created, dropped and recreated with slightly different columns.
Please, if you've one Moodle 2.0 test server running against oracle with the native driver... execute the test and post results here.
Here there are my results:
With oci8.statement_cache_size = 20
With oci8.statement_cache_size = 0
TIA!
- Operating System: Darwin
- PHP Version: 5.2.10
- Database: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production, 10.2.0.1.0
- OCI Version: (you can get it from the phpinfo page, OCI8 section)
- oci8.statement_cache_size: 20
- Test Result: ERROR! ORA-01007: variable not in select list - SELECT * FROM m_unit_table
With oci8.statement_cache_size = 0- Operating System: Darwin
- PHP Version: 5.2.10
- Database: Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production, 10.2.0.1.0
- OCI Version: (you can get it from the phpinfo page, OCI8 section)
- oci8.statement_cache_size: 0
- Test Result: OK!
TIA!