Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.0-95 checkin an item Server Error: 500 (Internal Server Error) #1174

Closed
ltt opened this issue Sep 15, 2015 · 14 comments
Closed

v2.0-95 checkin an item Server Error: 500 (Internal Server Error) #1174

ltt opened this issue Sep 15, 2015 · 14 comments
Labels
✋ bug Confirmed bug
Milestone

Comments

@ltt
Copy link

ltt commented Sep 15, 2015

When I check in a item, it throws this message Server Error: 500 (Internal Server Error). This issue happened after I upgraded it a few days ago
tail -f app/storage/logs/log-apache2handler-2015-09-15.txt
#17 /opt/snipe-it/bootstrap/compiled.php(715): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#18 /opt/snipe-it/bootstrap/compiled.php(696): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#19 /opt/snipe-it/vendor/barryvdh/laravel-debugbar/src/Middleware/Stack.php(34): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#20 /opt/snipe-it/bootstrap/compiled.php(7825): Barryvdh\Debugbar\Middleware\Stack->handle(Object(Illuminate\Http\Request), 1, true)
#21 /opt/snipe-it/bootstrap/compiled.php(8432): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#22 /opt/snipe-it/bootstrap/compiled.php(8379): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#23 /opt/snipe-it/bootstrap/compiled.php(11079): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#24 /opt/snipe-it/bootstrap/compiled.php(657): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#25 /opt/snipe-it/public/index.php(49): Illuminate\Foundation\Application->run()
#26 {main} [] []

@snipe
Copy link
Owner

snipe commented Sep 15, 2015

Did you run migrations when you upgraded? That error doesn't look like a useful one... When you're tailing that log, can you hit enter a bunch of times to clear the older stuff offscreen, try to checkout again, and then tell me what new message shows up?

@ltt
Copy link
Author

ltt commented Sep 15, 2015

Thank you for your super fast response.

I did run migrations when I upgraded it. Everything works fine except when I check in an item
Here is the full log

cat app/storage/logs/log-cli-2015-09-15.txt
[2015-09-15 04:06:21] production.ERROR: exception 'PDOException' with message 'SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'thread_id'' in /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Connection.php:369
Stack trace:
#0 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Connection.php(369): PDOStatement->execute(Array)
#1 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Connection.php(617): Illuminate\Database\Connection->Illuminate\Database{closure}(Object(Illuminate\Database\MySqlConnection), 'alter table as...', Array) #2 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Connection.php(581): Illuminate\Database\Connection->runQueryCallback('alter tableas...', Array, Object(Closure))
#3 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Connection.php(370): Illuminate\Database\Connection->run('alter table as...', Array, Object(Closure)) #4 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php(63): Illuminate\Database\Connection->statement('alter tableas...')
#5 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(169): Illuminate\Database\Schema\Blueprint->build(Object(Illuminate\Database\MySqlConnection), Object(Illuminate\Database\Schema\Grammars\MySqlGrammar))
#6 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(94): Illuminate\Database\Schema\Builder->build(Object(Illuminate\Database\Schema\Blueprint))
#7 /opt/snipe-it/bootstrap/compiled.php(3269): Illuminate\Database\Schema\Builder->table('asset_logs', Object(Closure))
#8 /opt/snipe-it/app/database/migrations/2015_07_29_230054_add_thread_id_to_asset_logs_table.php(72): Illuminate\Support\Facades\Facade::__callStatic('table', Array)
#9 /opt/snipe-it/app/database/migrations/2015_07_29_230054_add_thread_id_to_asset_logs_table.php(72): Illuminate\Support\Facades\Schema::table('asset_logs', Object(Closure))
#10 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(135): AddThreadIdToAssetLogsTable->up()
#11 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(111): Illuminate\Database\Migrations\Migrator->runUp('2015_07_29_2300...', 4, false)
#12 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(82): Illuminate\Database\Migrations\Migrator->runMigrationList(Array, false)
#13 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(70): Illuminate\Database\Migrations\Migrator->run('/opt/snipe-it/a...', false)
#14 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Console/Command.php(112): Illuminate\Database\Console\Migrations\MigrateCommand->fire()
#15 /opt/snipe-it/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(253): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Console/Command.php(100): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /opt/snipe-it/vendor/symfony/console/Symfony/Component/Console/Application.php(889): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /opt/snipe-it/vendor/symfony/console/Symfony/Component/Console/Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 /opt/snipe-it/vendor/symfony/console/Symfony/Component/Console/Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#20 /opt/snipe-it/artisan(59): Symfony\Component\Console\Application->run()
#21 {main}

Next exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'thread_id' (SQL: alter table asset_logs add thread_id int null)' in /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Connection.php:625
Stack trace:
#0 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Connection.php(581): Illuminate\Database\Connection->runQueryCallback('alter table as...', Array, Object(Closure)) #1 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Connection.php(370): Illuminate\Database\Connection->run('alter tableas...', Array, Object(Closure))
#2 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php(63): Illuminate\Database\Connection->statement('alter table `as...')
#3 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(169): Illuminate\Database\Schema\Blueprint->build(Object(Illuminate\Database\MySqlConnection), Object(Illuminate\Database\Schema\Grammars\MySqlGrammar))
#4 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php(94): Illuminate\Database\Schema\Builder->build(Object(Illuminate\Database\Schema\Blueprint))
#5 /opt/snipe-it/bootstrap/compiled.php(3269): Illuminate\Database\Schema\Builder->table('asset_logs', Object(Closure))
#6 /opt/snipe-it/app/database/migrations/2015_07_29_230054_add_thread_id_to_asset_logs_table.php(72): Illuminate\Support\Facades\Facade::__callStatic('table', Array)
#7 /opt/snipe-it/app/database/migrations/2015_07_29_230054_add_thread_id_to_asset_logs_table.php(72): Illuminate\Support\Facades\Schema::table('asset_logs', Object(Closure))
#8 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(135): AddThreadIdToAssetLogsTable->up()
#9 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(111): Illuminate\Database\Migrations\Migrator->runUp('2015_07_29_2300...', 4, false)
#10 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php(82): Illuminate\Database\Migrations\Migrator->runMigrationList(Array, false)
#11 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php(70): Illuminate\Database\Migrations\Migrator->run('/opt/snipe-it/a...', false)
#12 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Console/Command.php(112): Illuminate\Database\Console\Migrations\MigrateCommand->fire()
#13 /opt/snipe-it/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(253): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Console/Command.php(100): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 /opt/snipe-it/vendor/symfony/console/Symfony/Component/Console/Application.php(889): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 /opt/snipe-it/vendor/symfony/console/Symfony/Component/Console/Application.php(193): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Database\Console\Migrations\MigrateCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /opt/snipe-it/vendor/symfony/console/Symfony/Component/Console/Application.php(124): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 /opt/snipe-it/artisan(59): Symfony\Component\Console\Application->run()
#19 {main} [] []

@snipe
Copy link
Owner

snipe commented Sep 15, 2015

 production.ERROR: exception 'PDOException' with message 'SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'thread_id'' in /opt/snipe-it/vendor/laravel/framework/src/Illuminate/Database/Connection.php:369

That looks like something that would come from a migration, not from a checkout/checkin. Checkout and checkin doesn't try to create columns. Is this what you're seeing during the migration?

@ltt
Copy link
Author

ltt commented Sep 15, 2015

yes. it's something I saw during the migration

@snipe
Copy link
Owner

snipe commented Sep 15, 2015

Okay, if a migration ever fails, you should post an issue about it. They should never, ever fail, and if they do, other stuff will break, since the migration is what adds database tables, columns, etc, which the code is expecting to be able to use.

Can you show me the contents of your migrations table?

@ltt
Copy link
Author

ltt commented Sep 15, 2015

Here it is
+-------------------------------------------------------------------------+-------+
| migration | batch |
+-------------------------------------------------------------------------+-------+
| 2012_12_06_225921_migration_cartalyst_sentry_install_users | 1 |
| 2012_12_06_225929_migration_cartalyst_sentry_install_groups | 1 |
| 2012_12_06_225945_migration_cartalyst_sentry_install_users_groups_pivot | 1 |
| 2012_12_06_225988_migration_cartalyst_sentry_install_throttle | 1 |
| 2013_03_23_193214_update_users_table | 2 |
| 2013_11_13_075318_create_models_table | 2 |
| 2013_11_13_075335_create_categories_table | 2 |
| 2013_11_13_075347_create_manufacturers_table | 2 |
| 2013_11_15_015858_add_user_id_to_categories | 2 |
| 2013_11_15_112701_add_user_id_to_manufacturers | 2 |
| 2013_11_15_190327_create_assets_table | 2 |
| 2013_11_15_190357_create_licenses_table | 2 |
| 2013_11_15_201848_add_license_name_to_licenses | 2 |
| 2013_11_16_040323_create_depreciations_table | 2 |
| 2013_11_16_042851_add_depreciation_id_to_models | 2 |
| 2013_11_16_084923_add_user_id_to_models | 2 |
| 2013_11_16_103258_create_locations_table | 2 |
| 2013_11_16_103336_add_location_id_to_assets | 2 |
| 2013_11_16_103407_add_checkedout_to_to_assets | 2 |
| 2013_11_16_103425_create_history_table | 2 |
| 2013_11_17_054359_drop_licenses_table | 2 |
| 2013_11_17_054526_add_physical_to_assets | 2 |
| 2013_11_17_055126_create_settings_table | 2 |
| 2013_11_17_062634_add_license_to_assets | 2 |
| 2013_11_18_134332_add_contacts_to_users | 2 |
| 2013_11_18_142847_add_info_to_locations | 2 |
| 2013_11_18_152942_remove_location_id_from_asset | 2 |
| 2013_11_18_164423_set_nullvalues_for_user | 2 |
| 2013_11_19_013337_create_asset_logs_table | 2 |
| 2013_11_19_061409_edit_added_on_asset_logs_table | 2 |
| 2013_11_19_062250_edit_location_id_asset_logs_table | 2 |
| 2013_11_20_055822_add_soft_delete_on_assets | 2 |
| 2013_11_20_121404_add_soft_delete_on_locations | 2 |
| 2013_11_20_123137_add_soft_delete_on_manufacturers | 2 |
| 2013_11_20_123725_add_soft_delete_on_categories | 2 |
| 2013_11_20_130248_create_status_labels | 2 |
| 2013_11_20_130830_add_status_id_on_assets_table | 2 |
| 2013_11_20_131544_add_status_type_on_status_labels | 2 |
| 2013_11_20_134103_add_archived_to_assets | 2 |
| 2013_11_21_002321_add_uploads_table | 2 |
| 2013_11_21_024531_remove_deployable_boolean_from_status_labels | 2 |
| 2013_11_22_075308_add_option_label_to_settings_table | 2 |
| 2013_11_22_213400_edits_to_settings_table | 2 |
| 2013_11_25_013244_create_licenses_table | 2 |
| 2013_11_25_031458_create_license_seats_table | 2 |
| 2013_11_25_032022_add_type_to_actionlog_table | 2 |
| 2013_11_25_033008_delete_bad_licenses_table | 2 |
| 2013_11_25_033131_create_new_licenses_table | 2 |
| 2013_11_25_033534_add_licensed_to_licenses_table | 2 |
| 2013_11_25_101308_add_warrantee_to_assets_table | 2 |
| 2013_11_25_104343_alter_warranty_column_on_assets | 2 |
| 2013_11_25_150450_drop_parent_from_categories | 2 |
| 2013_11_25_151920_add_depreciate_to_assets | 2 |
| 2013_11_25_152903_add_depreciate_to_licenses_table | 2 |
| 2013_11_26_211820_drop_license_from_assets_table | 2 |
| 2013_11_27_062510_add_note_to_asset_logs_table | 2 |
| 2013_12_01_113426_add_filename_to_asset_log | 2 |
| 2013_12_06_094618_add_nullable_to_licenses_table | 2 |
| 2013_12_10_084038_add_eol_on_models_table | 2 |
| 2013_12_12_055218_add_manager_to_users_table | 2 |
| 2014_01_28_031200_add_qr_code_to_settings_table | 2 |
| 2014_02_13_183016_add_qr_text_to_settings_table | 2 |
| 2014_05_24_093839_alter_default_license_depreciation_id | 2 |
| 2014_05_27_231658_alter_default_values_licenses | 2 |
| 2014_06_19_191508_add_asset_name_to_settings | 2 |
| 2014_06_20_004847_make_asset_log_checkedout_to_nullable | 2 |
| 2014_06_20_005050_make_asset_log_purchasedate_to_nullable | 2 |
| 2014_06_24_003011_add_suppliers | 2 |
| 2014_06_24_010742_add_supplier_id_to_asset | 2 |
| 2014_06_24_012839_add_zip_to_supplier | 2 |
| 2014_06_24_033908_add_url_to_supplier | 2 |
| 2014_07_08_054116_add_employee_id_to_users | 2 |
| 2014_07_09_134316_add_requestable_to_assets | 2 |
| 2014_07_17_085822_add_asset_to_software | 2 |
| 2014_07_17_161625_make_asset_id_in_logs_nullable | 2 |
| 2014_08_12_053504_alpha_0_4_2_release | 2 |
| 2014_08_17_083523_make_location_id_nullable | 2 |
| 2014_10_16_200626_add_rtd_location_to_assets | 2 |
| 2014_10_24_000417_alter_supplier_state_to_32 | 2 |
| 2014_10_24_015641_add_display_checkout_date | 2 |
| 2014_10_28_222654_add_avatar_field_to_users_table | 2 |
| 2014_10_29_045924_add_image_field_to_models_table | 2 |
| 2014_11_01_214955_add_eol_display_to_settings | 2 |
| 2014_11_04_231416_update_group_field_for_reporting | 2 |
| 2014_11_05_212408_add_fields_to_licenses | 2 |
| 2014_11_07_021042_add_image_to_supplier | 2 |
| 2014_11_20_203007_add_username_to_user | 2 |
| 2014_11_20_223947_add_auto_to_settings | 2 |
| 2014_11_20_224421_add_prefix_to_settings | 2 |
| 2014_11_21_104401_change_licence_type | 2 |
| 2014_12_09_082500_add_fields_maintained_term_to_licenses | 2 |
| 2015_02_04_155757_increase_user_field_lengths | 2 |
| 2015_02_07_013537_add_soft_deleted_to_log | 2 |
| 2015_02_10_040958_fix_bad_assigned_to_ids | 2 |
| 2015_02_10_053310_migrate_data_to_new_statuses | 2 |
| 2015_02_11_044104_migrate_make_license_assigned_null | 2 |
| 2015_02_11_104406_migrate_create_requests_table | 2 |
| 2015_02_12_001312_add_mac_address_to_asset | 2 |
| 2015_02_12_024100_change_license_notes_type | 2 |
| 2015_02_17_231020_add_localonly_to_settings | 2 |
| 2015_02_19_222322_add_logo_and_colors_to_settings | 2 |
| 2015_02_24_072043_add_alerts_to_settings | 2 |
| 2015_02_25_022931_add_eula_fields | 2 |
| 2015_02_25_204513_add_accessories_table | 2 |
| 2015_02_26_091228_add_accessories_user_table | 2 |
| 2015_02_26_115128_add_deleted_at_models | 2 |
| 2015_02_26_233005_add_category_type | 2 |
| 2015_03_01_231912_update_accepted_at_to_acceptance_id | 2 |
| 2015_03_05_011929_add_qr_type_to_settings | 2 |
| 2015_03_18_055327_add_note_to_user | 2 |
| 2015_04_29_234704_add_slack_to_settings | 2 |
| 2015_05_22_124421_add_reassignable_to_licenses | 2 |
| 2015_05_04_085151_add_parent_id_to_locations_table | 3 |
| 2015_06_10_003314_fix_default_for_user_notes | 3 |
| 2015_06_10_003554_create_consumables | 3 |
| 2015_06_15_183253_move_email_to_username | 3 |
| 2015_06_23_070346_make_email_nullable | 3 |
| 2015_06_26_213716_create_asset_maintenances_table | 3 |
| 2015_07_09_014359_add_currency_to_settings_and_locations | 3 |
| 2015_07_21_122022_add_expected_checkin_date_to_asset_logs | 3 |
| 2015_07_24_093845_add_checkin_email_to_category_table | 3 |
| 2015_07_25_055415_remove_email_unique_constraint | 3 |
+-------------------------------------------------------------------------+-------+

@snipe
Copy link
Owner

snipe commented Sep 15, 2015

Another question - do you have any file uploads in your asset log?

@ltt
Copy link
Author

ltt commented Sep 15, 2015

I do

@snipe
Copy link
Owner

snipe commented Sep 15, 2015

Okay - I suspect that may be the issue behind the bug.

In your migrations table, add the following record for migration:

2015_07_29_230054_add_thread_id_to_asset_logs_table

with batch value being 4 and then re-run migrations and tell me what it says.

@snipe snipe added the ✋ bug Confirmed bug label Sep 15, 2015
@snipe snipe added this to the v2.1.0 milestone Sep 15, 2015
@ltt
Copy link
Author

ltt commented Sep 15, 2015


  • Application In Production!     *
    

Do you really wish to run this command? yes
Migrated: 2015_07_31_015430_add_accepted_to_assets
Migrated: 2015_09_09_195301_add_custom_css_to_settings

@snipe
Copy link
Owner

snipe commented Sep 15, 2015

Can you tell me if you still see the same issue on checkin now?

@ltt
Copy link
Author

ltt commented Sep 15, 2015

Nope. It works. Thank you very much for your help ;)

@snipe
Copy link
Owner

snipe commented Sep 15, 2015

Okay, so somehow that migration got donked up. It's been difficult to reproduce in the past, only affecting some users but not others, and I think the uploads bit is the key. We'll push out a fix for the migration shortly. Thanks for your patience, and for the debugging info.

@ltt
Copy link
Author

ltt commented Sep 15, 2015

Super. Thanks for your awesome app

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✋ bug Confirmed bug
Projects
None yet
Development

No branches or pull requests

2 participants