Issue Details (XML | Word | Printable)

Key: MDL-20339
Type: Sub-task Sub-task
Status: Open Open
Priority: Critical Critical
Assignee: Eloy Lafuente (stronk7)
Reporter: Eloy Lafuente (stronk7)
Votes: 0
Watchers: 4
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle
MDL-14679

OCI breaks badly with statement_cache enabled under certain situations

Created: 24/Sep/09 07:01 AM   Updated: 08/Oct/09 12:31 AM
Return to search
Component/s: Database SQL/XMLDB
Affects Version/s: 2.0
Fix Version/s: 2.0

File Attachments: 1. File testing_oci_stmt_cache_moodle.php (2 kB)
2. File testing_oci_stmt_cache_pureoci.php (3 kB)


Database: Oracle
Participants: Eloy Lafuente (stronk7) and Martin Dougiamas
Security Level: None
QA Assignee: Petr Skoda
Difficulty: Difficult
Affected Branches: MOODLE_20_STABLE
Fixed Branches: MOODLE_20_STABLE


 Description  « Hide
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.

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
Eloy Lafuente (stronk7) added a comment - 24/Sep/09 07:07 AM
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

  • 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!


Martin Dougiamas added a comment - 24/Sep/09 10:41 AM
I added Ashley, perhaps he can help organise some of Netspot's clients who are using Oracle to help in testing 2.0

Eloy Lafuente (stronk7) added a comment - 08/Oct/09 12:17 AM
Attaching pure oci php script able to reproduce the problem.

Eloy Lafuente (stronk7) added a comment - 08/Oct/09 12:31 AM
The bug has been reported to PHP at: http://bugs.php.net/49803