antonioribeiro / tracker

Laravel Stats Tracker
MIT License
2.9k stars 597 forks source link

Integrity constraint violation: 1048 Column 'log_id' cannot be null #317

Open haojingliu opened 7 years ago

haojingliu commented 7 years ago

Version: v3.1.4 php: 5.5 When I tried to track event, it throws Integrity constraint violation: 1048 Column 'log_id' cannot be null. It wouldn't be broken immediately after live the code. After around 5 events sent, it would begin to throw this error. Anyone has idea why it happens like this?

Error message log: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'log_id' cannot be null in /home/www/gogosu/vendor/laravel/framework/src/Illuminate/Database/Connection.php:457 Stack trace:

0 /home/www/gogosu/vendor/laravel/framework/src/Illuminate/Database/Connection.php(457): PDOStatement->execute(Array)

1 /home/www/gogosu/vendor/laravel/framework/src/Illuminate/Database/Connection.php(722): Illuminate\Database\Connection->Illuminate\Database{closure}(Object(Illuminate\Database\MySqlConnection), 'insert into `tr...', Array)

2 /home/www/gogosu/vendor/laravel/framework/src/Illuminate/Database/Connection.php(685): Illuminate\Database\Connection->runQueryCallback('insert into `tr...', Array, Object(Closure))

3 /home/www/gogosu/vendor/laravel/framework/src/Illuminate/Database/Connection.php(458): Illuminate\Database\Connection->run('insert into `tr...', Array, Object(Closure))

4 /home/www/gogosu/vendor/laravel/framework/src/Illuminate/Database/Connection.php(414): Illuminate\Database\Connection->statement('insert into `tr...', Array)

5 /home/www/gogosu/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php(32): Illuminate\Database\Connection->insert('insert into `tr...', Array)

6 /home/www/gogosu/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(2107): Illuminate\Database\Query\Processors\Processor->processInsertGetId(Object(Illuminate\Database\Query\Builder), 'insert into `tr...', Array, 'id')

7 [internal function]: Illuminate\Database\Query\Builder->insertGetId(Array, 'id')

8 /home/www/gogosu/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(1423): call_user_func_array(Array, Array)

9 /home/www/gogosu/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1628): Illuminate\Database\Eloquent\Builder->__call('insertGetId', Array)

10 /home/www/gogosu/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1597): Illuminate\Database\Eloquent\Model->insertAndSetId(Object(Illuminate\Database\Eloquent\Builder), Array)

11 /home/www/gogosu/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1488): Illuminate\Database\Eloquent\Model->performInsert(Object(Illuminate\Database\Eloquent\Builder), Array)

12 /home/www/gogosu/vendor/pragmarx/tracker/src/Vendor/Laravel/Models/Base.php(34): Illuminate\Database\Eloquent\Model->save(Array)

13 /home/www/gogosu/vendor/pragmarx/tracker/src/Data/Repositories/Repository.php(83): PragmaRX\Tracker\Vendor\Laravel\Models\Base->save()

14 /home/www/gogosu/vendor/pragmarx/tracker/src/Data/Repositories/Event.php(103): PragmaRX\Tracker\Data\Repositories\Repository->create(Array)

15 /home/www/gogosu/vendor/pragmarx/tracker/src/Data/RepositoryManager.php(715): PragmaRX\Tracker\Data\Repositories\Event->logEvent(Array)

16 /home/www/gogosu/vendor/pragmarx/tracker/src/Tracker.php(482): PragmaRX\Tracker\Data\RepositoryManager->trackEvent(Array)

17 /home/www/gogosu/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(217): PragmaRX\Tracker\Tracker->trackEvent(Array)

topoff commented 6 years ago

Did you register the middleware in http/kernel.php?

adibnoh commented 6 years ago

You could update migration file and set column to nullable,

By the way, I also meet the problem with table tracker_query_arguments when I try to query empty parameter like search?q=&order=desc it will cause an error because parameter q is empty.

haojingliu commented 6 years ago

@topoff Yes.

haojingliu commented 6 years ago

@adibnoh I 'fixed' it the same way.