ERROR: current transaction is aborted, commands ignored until end of transaction block (PG::InFailedSqlTransaction)

I’m trying to insert new row by using the import function from discourse, create_categories. It throw me this error.

What cause this error appear ?

I’m using this way to restore the docker data for keep testing on importing

./launcher stop import
rsync -avzh /var/discourse/shared/standalone.fresh/ /var/discourse/shared/standalone
./launcher start import

Full error message from console

59: from /var/www/discourse/script/import_scripts/phpwind9.rb:1610:in `<main>'
	58: from /var/www/discourse/script/import_scripts/base.rb:47:in `perform'
	57: from /var/www/discourse/script/import_scripts/phpwind9.rb:170:in `execute'
	56: from /var/www/discourse/script/import_scripts/phpwind9.rb:367:in `import_main_categories'
	55: from /var/www/discourse/script/import_scripts/base.rb:416:in `create_categories'
	54: from /usr/local/lib/ruby/gems/2.6.0/gems/rack-mini-profiler-2.0.1/lib/patches/db/mysql2.rb:8:in `each'
	53: from /usr/local/lib/ruby/gems/2.6.0/gems/rack-mini-profiler-2.0.1/lib/patches/db/mysql2.rb:8:in `each'
	52: from /var/www/discourse/script/import_scripts/base.rb:435:in `block in create_categories'
	51: from /var/www/discourse/script/import_scripts/base.rb:469:in `create_category'
	50: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/suppressor.rb:48:in `save!'
	49: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/transactions.rb:319:in `save!'
	48: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/transactions.rb:366:in `with_transaction_returning_status'
	47: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/transactions.rb:212:in `transaction'
	46: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:281:in `transaction'
	45: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/abstract/transaction.rb:278:in `within_new_transaction'
	44: from /usr/local/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
	43: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/abstract/transaction.rb:280:in `block in within_new_transaction'
	42: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:281:in `block in transaction'
	41: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/transactions.rb:375:in `block in with_transaction_returning_status'
	40: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/transactions.rb:319:in `block in save!'
	39: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/validations.rb:53:in `save!'
	38: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/persistence.rb:503:in `save!'
	37: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/timestamp.rb:129:in `create_or_update'
	36: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/callbacks.rb:328:in `create_or_update'
	35: from /usr/local/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:827:in `_run_save_callbacks'
	34: from /usr/local/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:135:in `run_callbacks'
	33: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/callbacks.rb:328:in `block in create_or_update'
	32: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/persistence.rb:906:in `create_or_update'
	31: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/timestamp.rb:111:in `_create_record'
	30: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/callbacks.rb:332:in `_create_record'
	29: from /usr/local/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:827:in `_run_create_callbacks'
	28: from /usr/local/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:136:in `run_callbacks'
	27: from /usr/local/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:518:in `invoke_after'
	26: from /usr/local/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:518:in `each'
	25: from /usr/local/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:518:in `block in invoke_after'
	24: from /usr/local/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:239:in `block in halting_and_conditional'
	23: from /usr/local/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/callbacks.rb:429:in `block in make_lambda'
	22: from /var/www/discourse/app/models/category.rb:756:in `delete_category_permalink'
	21: from /var/www/discourse/app/models/permalink.rb:71:in `find_by_url'
	20: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/core.rb:204:in `find_by'
	19: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/statement_cache.rb:134:in `execute'
	18: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/querying.rb:46:in `find_by_sql'
	17: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/abstract/query_cache.rb:107:in `select_all'
	16: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:70:in `select_all'
	15: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/abstract/database_statements.rb:487:in `select'
	14: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:98:in `exec_query'
	13: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `execute_and_clear'
	12: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:670:in `exec_no_cache'
	11: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:708:in `log'
	10: from /usr/local/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/notifications/instrumenter.rb:24:in `instrument'
	 9: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:717:in `block in log'
	 8: from /usr/local/lib/ruby/2.6.0/monitor.rb:235:in `mon_synchronize'
	 7: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/abstract_adapter.rb:718:in `block (2 levels) in log'
	 6: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:671:in `block in exec_no_cache'
	 5: from /usr/local/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/dependencies/interlock.rb:47:in `permit_concurrent_loads'
	 4: from /usr/local/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/concurrency/share_lock.rb:187:in `yield_shares'
	 3: from /usr/local/lib/ruby/gems/2.6.0/gems/activesupport-6.0.1/lib/active_support/dependencies/interlock.rb:48:in `block in permit_concurrent_loads'
	 2: from /usr/local/lib/ruby/gems/2.6.0/gems/activerecord-6.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:672:in `block (2 levels) in exec_no_cache'
	 1: from /usr/local/lib/ruby/gems/2.6.0/gems/rack-mini-profiler-2.0.1/lib/patches/db/pg.rb:69:in `exec_params'
/usr/local/lib/ruby/gems/2.6.0/gems/rack-mini-profiler-2.0.1/lib/patches/db/pg.rb:69:in `exec_params': ERROR:  current transaction is aborted, commands ignored until end of transaction block (PG::InFailedSqlTransaction)

Solution

In many cases, it should be corrupted in PostgreSQL database, I’ve found the way that repair on this. Make sure you backup your data before try this command.

./launcher enter import
su postgres -c "psql discourse"
\d
vacuum;
vacuum analyze;
vacuum full;

You may read more on this function from Postgres SQL VACUUM

Tags:

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.