[DC-326] Running out of memory while executing single record lookup. Created: 04/Dec/09  Updated: 07/Dec/09

Status: Open
Project: Doctrine 1
Component/s: Record
Affects Version/s: 1.2.0
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Alex Agulyansky Assignee: Jonathan H. Wage
Resolution: Unresolved Votes: 1
Labels: None
Environment:

Mac OS 10.5, Zend Server CE, PHP 5.3
Symfony 1.4



 Description   

I have the model class as follows:

schema.yml
options:
  collate: utf8_unicode_ci
  charset: utf8
  type: INNODB
Identity:
  tableName: Identity
  columns:
    id:
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    username:
      type: string(50)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    email:
      type: string(50)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    password:
      type: string(100)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    created_at:
      name: created_at
      type: timestamp
      # default: CURRENT_TIMESTAMP
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    updated_at:
      name: updated_at
      type: timestamp
      fixed: false
      unsigned: false
      primary: false
      default: null
      notnull: false
      autoincrement: false
  relations:
    Roles:
      class: Role
      local: id
      foreign: ident_id
      type: many
    Token:
      local: id
      foreign: entity_id
      type: many
    Devices:
      class: Device
      local: id
      foreign: account_id
      type: many
    Rides:
      class: Ride
      local: id
      foreign: account_id
      type: many
    OwnGroups:
      class: CoachGroup
      local: id
      foreign: owner_id
      type: many
    GroupMemberships:
      class: GroupMembership
      local: id
      foreign: ident_id
      type: many
  actAs:
    Timestampable:
      created:
        name: created_at
        type: timestamp
        expression: NOW()
      update:
        onInsert: false
Role:
  tableName: Role
  columns:
    identId:
      name: ident_id
      type: integer(4)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
    role:
      type: string(50)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: false
  relations:
    Identity:
      onDelete: CASCADE
      onUpdate: CASCADE
      local: ident_id
      foreign: id
      foreignAlias: Roles
Token:
  tableName: Token
  columns:
    entity_id:
      name: entity_id
      type: integer(4)
      fixed: false
      unsigned: false
      notnull: true
      primary: false
      autoincrement: false
    token:
      name: token
      type: string(50)
      fixed: true
      unsigned: false
      primary: true
      default: ''
      notnull: true
      autoincrement: false
    type:
      type: enum(50)
      fixed: false
      unsigned: false
      values:
        - EMAIL_VERIFICATION
        - PASS_RESET
      primary: false
      default: EMAIL_VERIFICATION
      notnull: true
      autoincrement: false
    created_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    expires_at:
      type: timestamp(25)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
  indexes:
    entity:
      fields: [entity_id]
  relations:
    Identity:
      onDelete: CASCADE
      onUpdate: CASCADE
      local: entity_id
      foreign: id
      type: one
  actAs:
    Timestampable:
      created:
        name: created_at
        type: timestamp
      updated:
        disabled: true

and my unit test for the model:

TokenModelTest.php
$t = new lime_test(3);
$t->diag("=== Token model test ===");

$t->info('Token creation =>');
$token = new Token();
$token->setEntityId(1);
$token->generateUniqueToken();

$t->info('Set valid token type...');
$token->setType(Token::TYPE_EMAIL_VERIFICATION);
try{
  $t->info('Saving the token...');
  $token->save();
  $t->pass('Token was saved successfully...');
}
catch(Exception $e){
  $t->is(($e instanceof Exception), true, $e->getMessage());
}

$t->isnt($token->getCreatedAt(), null, ' Creation datetime is set to '.$token->getCreatedAt().'...');

$t->info('Get this token from DB...');
$tokenFromDb = Doctrine::getTable('Token')->findOneByToken($token->getToken());

$t->info('Compare the two...');
$t->is($tokenFromDb->getEntityId(), $token->getEntityId(), 'Entity ID...');
$t->is($tokenFromDb->getToken(), $token->getToken(), 'Token string...');
$t->is($tokenFromDb->getType(), $token->getType(), 'Token string...');
$t->is($tokenFromDb->getCreatedAt(), $token->getCreatedAt(), 'Token creation date...');
$t->is($tokenFromDb->getExpiresAt(), $token->getExpiresAt(), 'Token expration date...');
$t->is($tokenFromDb->getExpiresAt(), null, 'Token expration date is null...');

$t->info('Delete token...');
$t->is($token->delete(), true, 'Successful deletion...');

On test execution on this line:

$tokenFromDb = Doctrine::getTable('Token')->findOneByToken($token->getToken());

I'm getting a fatal error:

ERROR
# === Token model test ===
> Token creation =>
> Set valid token type...
> Saving the token...
ok 1 - Token was saved successfully...
ok 2 -  Creation datetime is set to 2009-12-04 01:13:31...
> Get this token from DB...
PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 261900 bytes) in /ApacheWebServer/htdocs/Clients/enki/enkiweb/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Core.php on line 550

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 261900 bytes) in /ApacheWebServer/htdocs/Clients/enki/enkiweb/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Core.php on line 550


 Comments   
Comment by Jonathan H. Wage [ 07/Dec/09 ]

Anymore information? Not much I can really do right now. If you have some more information to help I can look at the problem again. A Doctrine test case would be helpful.

Generated at Thu Jul 31 05:23:09 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.