DoctrineExtensions icon indicating copy to clipboard operation
DoctrineExtensions copied to clipboard

[Timestampable] not-null violation on create

Open drekinov opened this issue 2 years ago • 5 comments

Hi, We get not-null sql violation from time to time when one specific entity is created. It is happening randomly without any obvious pattern.

Entity is table inheritance with

#[ORM\InheritanceType(value: 'SINGLE_TABLE')]
#[ORM\DiscriminatorColumn(name: 'discr', type: Types::STRING)]
#[ORM\DiscriminatorMap([.....])

//...

 #[ORM\Column(name: 'created_at', type: Types::DATETIMETZ_IMMUTABLE, nullable: false)]
    #[Gedmo\Timestampable(on: 'create')]
    private DateTimeImmutable $createdAt;

    #[ORM\Column(name: 'updated_at', type: Types::DATETIMETZ_IMMUTABLE, nullable: false)]
    #[Gedmo\Timestampable(on: 'update')]
    private DateTimeImmutable $updatedAt;

It happen on production with following prod specific config for doctrine (i think it is default for symfony 6.x):

when@prod:
    doctrine:
        orm:
            auto_generate_proxy_classes: false
            proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies'
            metadata_cache_driver:
                type: pool
                pool: cache.doctrine_metadata
            query_cache_driver:
                type: pool
                pool: cache.doctrine_query
            result_cache_driver:
                type: pool
                pool: cache.doctrine_result

i recall it started after switching to php attributes with Symfony 5.3+-. Right now app is Symfony 6.2 and it continue to appear as randomly as before.

Fix which i apply is to flush redis database holding prod caches + execute CLI commands which should do the same + restart all messenger workers so they get new cache / empty cache.

I have no idea what is wrong or where to start debug for last 6+ months.

Database is postgresql 14.x

drekinov avatar Jan 03 '23 07:01 drekinov

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Jul 14 '23 09:07 github-actions[bot]

Looks to be a duplicate of https://github.com/hyraiq/topcat/pull/8870

ndench avatar Jul 22 '23 05:07 ndench

We are getting similar problems - it only happens with one entity and doesn't happen every time a new entity is created. Very puzzling.

AndrewDBattye avatar Aug 23 '23 10:08 AndrewDBattye

More details here: https://github.com/doctrine-extensions/DoctrineExtensions/issues/2600

AndrewDBattye avatar Aug 24 '23 07:08 AndrewDBattye

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Feb 20 '24 09:02 github-actions[bot]