Can't access packages available in CentOS 7 base

takes the id of a repository not a product. You can easily take it from the UI URL of a repository, i.e. you go to the repository page and the URL looks like https://foreman.example.com/products/12/repositories/23

You feed the 23 into the find…

Ok. Progressing…

# c7-base-repo = 17
# c7-updates-repo = 18
# c7-extras-repo = 19
irb(main):007:0> root = Katello::RootRepository.find(17)
=> #<Katello::RootRepository id: 17, name: "c7-base-repo", created_at: "2021-05-05 15:56:08", updated_at: "2022-08-15 08:44:57", major: nil, minor: nil, gpg_key_id: 7, content_id: "1620230169017", arch: "noarch", label: "c7-b...
irb(main):007:0> ForemanTasks.async_task(::Actions::Candlepin::Product::ContentAdd, owner: root.product.organization.label, product_id: root.product.cp_id, content_id: root.content_id)
=> #<ForemanTasks::Task::DynflowTask id: "a831ff23-5b1b-4167-8db9-a2476457f135", type: "ForemanTasks::Task::DynflowTask", label: "Actions::Candlepin::Product::ContentAdd", started_at: "2022-08-15 17:08:24", ended_at: nil, state: "planned", result: "pending", external_id: "53bb6f9b-fdb0-4758-bb4c-54eec3d4e993", parent_task_id: nil, start_at: "2022-08-15 17:08:24", start_before: nil, action: "Content add", user_id: 2, state_updated_at: "2022-08-15 17:08:24">

Then on my host

# subscription-manager refresh --force

and finally the c7-base-repo is back in the redhat.repo file

However for c7-extras-repo

=> #<Katello::RootRepository id: 19, name: "c7-extras-repo", created_at: "2021-05-05 15:56:18", updated_at: "2022-08-15 08:44:47", major: nil, minor: nil, gpg_key_id: 7, content_id: "1620230179550", arch: "noarch", label: "c7...
irb(main):010:0> ForemanTasks.async_task(::Actions::Candlepin::Product::ContentAdd, owner: root.product.organization.label, product_id: root.product.cp_id, content_id: root.content_id)
=> #<ForemanTasks::Task::DynflowTask id: "32b91137-8431-4c5d-9301-4d8f2c6fed6a", type: "ForemanTasks::Task::DynflowTask", label: "Actions::Candlepin::Product::ContentAdd", started_at: "2022-08-15 17:10:34", ended_at: nil, state: "planned", result: "pending", external_id: "abc02944-e6a9-4574-bf94-c2b3275ee28f", parent_task_id: nil, start_at: "2022-08-15 17:10:34", start_before: nil, action: "Content add", user_id: 2, state_updated_at: "2022-08-15 17:10:34">

Error in Task

Runtime Error could not execute statement at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse:2,675

backtrace:

/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.5.0/app/lib/actions/middleware/propagate_candlepin_errors.rb:21:in `rescue in propagate_candlepin_errors'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.5.0/app/lib/actions/middleware/propagate_candlepin_errors.rb:18:in `propagate_candlepin_errors'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.5.0/app/lib/actions/middleware/propagate_candlepin_errors.rb:9:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:23:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:27:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware.rb:19:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.5.0/app/lib/actions/middleware/remote_action.rb:16:in `block in run'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.5.0/app/lib/actions/middleware/remote_action.rb:40:in `block in as_remote_user'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.5.0/app/models/katello/concerns/user_extensions.rb:21:in `cp_config'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.5.0/app/lib/actions/middleware/remote_action.rb:27:in `as_cp_user'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.5.0/app/lib/actions/middleware/remote_action.rb:39:in `as_remote_user'
/opt/theforeman/tfm/root/usr/share/gems/gems/katello-4.5.0/app/lib/actions/middleware/remote_action.rb:16:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:23:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:27:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware.rb:19:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/rails_executor_wrap.rb:14:in `block in run'
/opt/theforeman/tfm/root/usr/share/gems/gems/activesupport-6.0.4.7/lib/active_support/execution_wrapper.rb:91:in `wrap'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/rails_executor_wrap.rb:13:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:23:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:27:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware.rb:19:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/action/progress.rb:31:in `with_progress_calculation'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/action/progress.rb:17:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:23:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:27:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware.rb:19:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/load_setting_values.rb:20:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:23:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:27:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware.rb:19:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/keep_current_request_id.rb:15:in `block in run'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/keep_current_request_id.rb:52:in `restore_current_request_id'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/keep_current_request_id.rb:15:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:23:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:27:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware.rb:19:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/keep_current_timezone.rb:15:in `block in run'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/keep_current_timezone.rb:44:in `restore_curent_timezone'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/keep_current_timezone.rb:15:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:23:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:27:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware.rb:19:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/keep_current_taxonomies.rb:15:in `block in run'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/keep_current_taxonomies.rb:45:in `restore_current_taxonomies'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/keep_current_taxonomies.rb:15:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:23:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:27:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware.rb:19:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware.rb:32:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:23:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:27:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware.rb:19:in `pass'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/keep_current_user.rb:15:in `block in run'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/keep_current_user.rb:54:in `restore_curent_user'
/opt/theforeman/tfm/root/usr/share/gems/gems/foreman-tasks-6.0.2/app/lib/actions/middleware/keep_current_user.rb:15:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/stack.rb:23:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/middleware/world.rb:31:in `execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/action.rb:581:in `block (2 levels) in execute_run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/action.rb:580:in `catch'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/action.rb:580:in `block in execute_run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/action.rb:483:in `block in with_error_handling'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/action.rb:483:in `catch'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/action.rb:483:in `with_error_handling'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/action.rb:575:in `execute_run'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/action.rb:296:in `execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:18:in `block (2 levels) in execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/execution_plan/steps/abstract.rb:167:in `with_meta_calculation'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:17:in `block in execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:32:in `open_action'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/execution_plan/steps/abstract_flow_step.rb:16:in `execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/director.rb:69:in `execute'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/executors/sidekiq/worker_jobs.rb:11:in `block (2 levels) in perform'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/executors.rb:18:in `run_user_code'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/executors/sidekiq/worker_jobs.rb:9:in `block in perform'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/executors/sidekiq/worker_jobs.rb:25:in `with_telemetry'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/executors/sidekiq/worker_jobs.rb:8:in `perform'
/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.6.4/lib/dynflow/executors/sidekiq/serialization.rb:27:in `perform'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/processor.rb:192:in `execute_job'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/processor.rb:165:in `block (2 levels) in process'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/middleware/chain.rb:128:in `block in invoke'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/middleware/chain.rb:133:in `invoke'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/processor.rb:164:in `block in process'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/processor.rb:137:in `block (6 levels) in dispatch'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/job_retry.rb:109:in `local'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/processor.rb:136:in `block (5 levels) in dispatch'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq.rb:37:in `block in <module:Sidekiq>'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/processor.rb:132:in `block (4 levels) in dispatch'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/processor.rb:250:in `stats'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/processor.rb:127:in `block (3 levels) in dispatch'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/job_logger.rb:8:in `call'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/processor.rb:126:in `block (2 levels) in dispatch'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/job_retry.rb:74:in `global'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/processor.rb:125:in `block in dispatch'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/logging.rb:48:in `with_context'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/logging.rb:42:in `with_job_hash_context'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/processor.rb:124:in `dispatch'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/processor.rb:163:in `process'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/processor.rb:83:in `process_one'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/processor.rb:71:in `run'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/util.rb:16:in `watchdog'
/opt/theforeman/tfm/root/usr/share/gems/gems/sidekiq-5.2.10/lib/sidekiq/util.rb:25:in `block in safe_thread'
/opt/theforeman/tfm/root/usr/share/gems/gems/logging-2.3.0/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'

I think /var/log/candlepin/error.log or /var/log/candlepin/candlepin.log should contain more information about that candlepin error.

2022-08-15 17:14:29,254 [thread=http-bio-127.0.0.1-23443-exec-6] [req=6edbf6a1-2941-4a6d-b4cd-2a620c843410, org=, csid=] ERROR org.candlepin.exceptions.mappers.CandlepinExceptionMapper - Runtime Error could not execute statement at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse:2,675
org.hibernate.exception.ConstraintViolationException: could not execute statement
	at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:109)
	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:113)
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:99)
	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:200)
	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3208)
	at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3722)
	at org.hibernate.action.internal.EntityInsertAction.execute(EntityInsertAction.java:91)
	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:604)
	at org.hibernate.engine.spi.ActionQueue.lambda$executeActions$1(ActionQueue.java:478)
	at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:475)
	at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:348)
	at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:40)
	at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:108)
	at org.hibernate.internal.SessionImpl.doFlush(SessionImpl.java:1344)
	at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1331)
	at org.hibernate.query.internal.NativeQueryImpl.beforeQuery(NativeQueryImpl.java:264)
	at org.hibernate.query.internal.AbstractProducedQuery.executeUpdate(AbstractProducedQuery.java:1603)
	at org.candlepin.model.AbstractHibernateCurator.bulkSQLUpdate(AbstractHibernateCurator.java:1413)
	at org.candlepin.model.OwnerProductCurator.updateOwnerProductReferences(OwnerProductCurator.java:612)
	at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:56)
	at org.candlepin.controller.ProductManager.updateProduct(ProductManager.java:376)
	at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:56)
	at org.candlepin.resource.OwnerResource.addBatchContent(OwnerResource.java:2066)
	at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:56)
	at org.candlepin.resource.OwnerResource.addContent(OwnerResource.java:2077)
	at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:64)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:151)
	at org.jboss.resteasy.core.MethodInjectorImpl.lambda$invoke$3(MethodInjectorImpl.java:122)
	at java.base/java.util.concurrent.CompletableFuture.uniApplyNow(CompletableFuture.java:680)
	at java.base/java.util.concurrent.CompletableFuture.uniApplyStage(CompletableFuture.java:658)
	at java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:2094)
	at java.base/java.util.concurrent.CompletableFuture.thenApply(CompletableFuture.java:143)
	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:122)
	at org.jboss.resteasy.core.ResourceMethodInvoker.internalInvokeOnTarget(ResourceMethodInvoker.java:594)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTargetAfterFilter(ResourceMethodInvoker.java:468)
	at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invokeOnTarget$2(ResourceMethodInvoker.java:421)
	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget(ResourceMethodInvoker.java:423)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:391)
	at org.jboss.resteasy.core.ResourceMethodInvoker.lambda$invoke$1(ResourceMethodInvoker.java:365)
	at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1106)
	at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2235)
	at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:143)
	at org.jboss.resteasy.core.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:365)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:477)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$invoke$4(SynchronousDispatcher.java:252)
	at org.jboss.resteasy.core.SynchronousDispatcher.lambda$preprocess$0(SynchronousDispatcher.java:153)
	at org.jboss.resteasy.core.interception.jaxrs.PreMatchContainerRequestContext.filter(PreMatchContainerRequestContext.java:363)
	at org.jboss.resteasy.core.SynchronousDispatcher.preprocess(SynchronousDispatcher.java:156)
	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:238)
	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:249)
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:60)
	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
	at com.google.inject.servlet.ServletDefinition.doServiceImpl(ServletDefinition.java:290)
	at com.google.inject.servlet.ServletDefinition.doService(ServletDefinition.java:280)
	at com.google.inject.servlet.ServletDefinition.service(ServletDefinition.java:184)
	at com.google.inject.servlet.ManagedServletPipeline.service(ManagedServletPipeline.java:89)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:85)
	at org.candlepin.servlet.filter.EventFilter.doFilter(EventFilter.java:65)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
	at org.candlepin.servlet.filter.logging.LoggingFilter.doFilter(LoggingFilter.java:123)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
	at org.candlepin.servlet.filter.CandlepinPersistFilter.doFilter(CandlepinPersistFilter.java:48)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
	at org.candlepin.servlet.filter.CandlepinScopeFilter.doFilter(CandlepinScopeFilter.java:68)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
	at org.candlepin.servlet.filter.CandlepinContentTypeFilter.doFilter(CandlepinContentTypeFilter.java:67)
	at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:82)
	at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:121)
	at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:498)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "cp2_product_entity_version"
  Detail: Key (product_id, entity_version)=(577537497763, 1775210097) already exists.
	at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2675)
	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2365)
	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:355)
	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:490)
	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:408)
	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:166)
	at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:134)
	at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:410)
	at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197)
	... 88 common frames omitted

product id = 577537497763 is my “c7” Product.

No idea what the entity_version = entity_version is ?

We might need to call some Candlepin experts!

I have a new suggestion that I found from this Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1931027#c80

[root@foreman ~]# sudo -u postgres psql candlepin
candlepin=# UPDATE cp_entitlement SET dirty='t';

Then run subscription-manager refresh on all related hosts.

I’m not certain what that does, so run at your own risk. Maybe take a snapshot / backup first. It sounds like it worked for one party at least.

Thanks @iballou
Looked at the Bugzilla ticket.

# scl enable rh-ruby27 bash

# ruby -v
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux]

# ruby downloads/find_missing_candlepin_product_contents.rb
Content name="cstream-baseos-repo" w/o association; content_uuid="8abd9592826940da01826993e4930095"; content_id="1620230716872"
Content name="cstream-extras-repo" w/o association; content_uuid="8abd9592826940da018269941faf0096"; content_id="1620230729030"
Content name="cstream-powertools-repo" w/o association; content_uuid="8abd9592826940da01826994574a0097"; content_id="1620230734016"
Content name="c7-extras-repo" w/o association; content_uuid="8abd9592826940da018269814286007a"; content_id="1620230179550"

Product "cstream"(cp_id=87644743334) has 4 content in foremanDB, but 1 content in candlepinDB
Product "c7"(cp_id=577537497763) has 3 content in foremanDB, but 2 content in candlepinDB



-- repair missing: ["cstream-baseos-repo"]
INSERT INTO cp2_product_content (id, enabled, product_uuid, content_uuid, created, updated) VALUES (REPLACE(uuid_in((md5((random())::text))::cstring)::text, '-', '' ), true, '8abd9592826940da0182698e3bec008c', '8abd9592826940da01826993e4930095', NOW(), NOW());
UPDATE cp2_products SET entity_version = NULL WHERE uuid = '8abd9592826940da0182698e3bec008c';

-- repair missing: ["cstream-extras-repo"]
INSERT INTO cp2_product_content (id, enabled, product_uuid, content_uuid, created, updated) VALUES (REPLACE(uuid_in((md5((random())::text))::cstring)::text, '-', '' ), true, '8abd9592826940da0182698e3bec008c', '8abd9592826940da018269941faf0096', NOW(), NOW());
UPDATE cp2_products SET entity_version = NULL WHERE uuid = '8abd9592826940da0182698e3bec008c';

-- repair missing: ["cstream-powertools-repo"]
INSERT INTO cp2_product_content (id, enabled, product_uuid, content_uuid, created, updated) VALUES (REPLACE(uuid_in((md5((random())::text))::cstring)::text, '-', '' ), true, '8abd9592826940da0182698e3bec008c', '8abd9592826940da01826994574a0097', NOW(), NOW());
UPDATE cp2_products SET entity_version = NULL WHERE uuid = '8abd9592826940da0182698e3bec008c';

-- repair missing: ["c7-extras-repo"]
INSERT INTO cp2_product_content (id, enabled, product_uuid, content_uuid, created, updated) VALUES (REPLACE(uuid_in((md5((random())::text))::cstring)::text, '-', '' ), true, '8abd959282929bd00182a27a5d6e0360', '8abd9592826940da018269814286007a', NOW(), NOW());
UPDATE cp2_products SET entity_version = NULL WHERE uuid = '8abd959282929bd00182a27a5d6e0360';



# ruby downloads/find_missing_candlepin_product_contents.rb --repair
Content name="cstream-baseos-repo" w/o association; content_uuid="8abd9592826940da01826993e4930095"; content_id="1620230716872"
Content name="cstream-extras-repo" w/o association; content_uuid="8abd9592826940da018269941faf0096"; content_id="1620230729030"
Content name="cstream-powertools-repo" w/o association; content_uuid="8abd9592826940da01826994574a0097"; content_id="1620230734016"
Content name="c7-extras-repo" w/o association; content_uuid="8abd9592826940da018269814286007a"; content_id="1620230179550"

Product "cstream"(cp_id=87644743334) has 4 content in foremanDB, but 1 content in candlepinDB
Product "c7"(cp_id=577537497763) has 3 content in foremanDB, but 2 content in candlepinDB



-- repair missing: ["cstream-baseos-repo"]
INSERT INTO cp2_product_content (id, enabled, product_uuid, content_uuid, created, updated) VALUES (REPLACE(uuid_in((md5((random())::text))::cstring)::text, '-', '' ), true, '8abd9592826940da0182698e3bec008c', '8abd9592826940da01826993e4930095', NOW(), NOW());
UPDATE cp2_products SET entity_version = NULL WHERE uuid = '8abd9592826940da0182698e3bec008c';

-- repair missing: ["cstream-extras-repo"]
INSERT INTO cp2_product_content (id, enabled, product_uuid, content_uuid, created, updated) VALUES (REPLACE(uuid_in((md5((random())::text))::cstring)::text, '-', '' ), true, '8abd9592826940da0182698e3bec008c', '8abd9592826940da018269941faf0096', NOW(), NOW());
UPDATE cp2_products SET entity_version = NULL WHERE uuid = '8abd9592826940da0182698e3bec008c';

-- repair missing: ["cstream-powertools-repo"]
INSERT INTO cp2_product_content (id, enabled, product_uuid, content_uuid, created, updated) VALUES (REPLACE(uuid_in((md5((random())::text))::cstring)::text, '-', '' ), true, '8abd9592826940da0182698e3bec008c', '8abd9592826940da01826994574a0097', NOW(), NOW());
UPDATE cp2_products SET entity_version = NULL WHERE uuid = '8abd9592826940da0182698e3bec008c';

-- repair missing: ["c7-extras-repo"]
INSERT INTO cp2_product_content (id, enabled, product_uuid, content_uuid, created, updated) VALUES (REPLACE(uuid_in((md5((random())::text))::cstring)::text, '-', '' ), true, '8abd959282929bd00182a27a5d6e0360', '8abd9592826940da018269814286007a', NOW(), NOW());
UPDATE cp2_products SET entity_version = NULL WHERE uuid = '8abd959282929bd00182a27a5d6e0360';

Repairing:
[["INSERT 0 1"], ["UPDATE 1"], ["INSERT 0 1"], ["UPDATE 1"], ["INSERT 0 1"], ["UPDATE 1"], ["INSERT 0 1"], ["UPDATE 1"]]

// On the host I am testing with
# subscription-manager refresh --force
-> no change. c7-extras-repo not showing.


# sudo -u postgres psql candlepin
candlepin=# UPDATE cp_entitlement SET dirty='t';


// On the host I am testing with
# subscription-manager refresh --force
-> no change. c7-extras-repo not showing.


// c7-base-repo = 17
// c7-updates-repo = 18
// c7-extras-repo = 19
Re-ran this
# foreman-rake console
'ErbParser' is ignored.
'RubyParser' is ignored.
Loading production environment (Rails 6.0.4.7)
irb(main):001:0> root = Katello::RootRepository.find(19)
=> #<Katello::RootRepository id: 19, name: "c7-extras-repo", created_at: "2021-05-05 15:56:18", updated_at: "2022-08-15 08:44:47", major: nil, minor: nil, gpg_key_id: 7, content_id: "1620230179550", arch: "noarch", label: "c7...
irb(main):002:0> ForemanTasks.async_task(::Actions::Candlepin::Product::ContentAdd, owner: root.product.organization.label, product_id: root.product.cp_id, content_id: root.content_id)
=> #<ForemanTasks::Task::DynflowTask id: "543faec4-1b80-4677-ac6f-c207b3b6e39b", type: "ForemanTasks::Task::DynflowTask", label: "Actions::Candlepin::Product::ContentAdd", started_at: "2022-08-16 09:24:02", ended_at: nil, state: "planned", result: "pending", external_id: "930c0f84-c612-41a5-a60c-534e4c60aead", parent_task_id: nil, start_at: "2022-08-16 09:24:02", start_before: nil, action: "Content add", user_id: 2, state_updated_at: "2022-08-16 09:24:02">
irb(main):003:0> quit

but task still failed with the same error
Runtime Error could not execute statement at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse:2,675

Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "cp2_product_entity_version"
  Detail: Key (product_id, entity_version)=(577537497763, 1775210097) already exists.

I re-published + promoted my “c7-devops-view” and force subscribed my host again with subscription-manager but no change.

Having not changed anything for 24+ hours I tried again a

# subscription-manager refresh --force

on my host and miraculously my 3x CentOS 7 repos (base, extras, updates) showed up in the redhat.repo file…
Happy, amazed and totally confused :smiley:

1 Like

Please let us know if this happens again, but I’m glad that it fixed it self!