netfishers-onl / Netshot

Network Configuration and Compliance Management
http://www.netfishers.onl/netshot
246 stars 59 forks source link

Purge old entries from database - fails #234

Open pfunkylol opened 2 years ago

pfunkylol commented 2 years ago

Hi,

Upon trying to delete just tasks older than 90 days, it fails with

[INFO] Cleaning up tasks more than 90 days ago...
[ERROR] Database error during the task purge.

2022-09-21 10:37:27,316 WARN [NetshotRunnerScheduler_Worker-1] TaskJob: Running the task 60346 of type onl.netfishers.netshot.work.tasks.PurgeDatabaseTask 2022-09-21 10:37:28,510 ERROR [NetshotRunnerScheduler_Worker-1] PurgeDatabaseTask: Task 60346. Database error while purging the old tasks from the database. org.hibernate.InstantiationException: Cannot instantiate abstract class or interface: : onl.netfishers.netshot.work.Task at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:79) at org.hibernate.tuple.PojoInstantiator.instantiate(PojoInstantiator.java:105) at org.hibernate.tuple.entity.AbstractEntityTuplizer.instantiate(AbstractEntityTuplizer.java:705) at org.hibernate.persister.entity.AbstractEntityPersister.instantiate(AbstractEntityPersister.java:5295) at org.hibernate.internal.SessionImpl.instantiate(SessionImpl.java:1643) at org.hibernate.internal.SessionImpl.instantiate(SessionImpl.java:1627) at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1769) at org.hibernate.loader.Loader.getRow(Loader.java:1624) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:748) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:710) at org.hibernate.loader.Loader.loadSingleRow(Loader.java:396) at org.hibernate.internal.ScrollableResultsImpl.prepareCurrentRow(ScrollableResultsImpl.java:197) at org.hibernate.internal.ScrollableResultsImpl.next(ScrollableResultsImpl.java:102) at onl.netfishers.netshot.work.tasks.PurgeDatabaseTask.run(PurgeDatabaseTask.java:121) at onl.netfishers.netshot.work.TaskJob.execute(TaskJob.java:95) at org.quartz.core.JobRunShell.run(JobRunShell.java:202) at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) 2022-09-21 10:37:28,520 WARN [NetshotRunnerScheduler_Worker-1] TaskJob: End of task 60346.

pfunkylol commented 1 year ago

Hi @SCadilhac ,

Did you get a chance to look at this issue?

Paul

SCadilhac commented 1 year ago

Which version are you running?

pfunkylol commented 1 year ago

I'm running the latest version 0.18.2

pfunkylol commented 1 year ago

if it helps

DEBUG [grizzly-http-server-6] NewPooledConnection: com.mchange.v2.c3p0.impl.NewPooledConnection@2f9c8248 handling a throwable.
org.postgresql.util.PSQLException: The column name "id" was not found in this ResultSet.
    at org.postgresql.jdbc.PgResultSet.findColumn(PgResultSet.java:2901)
    at org.postgresql.jdbc.PgResultSet.getLong(PgResultSet.java:2784)
    at com.mchange.v2.c3p0.impl.NewProxyResultSet.getLong(NewProxyResultSet.java:477)
    at org.hibernate.id.IdentifierGeneratorHelper.extractIdentifier(IdentifierGeneratorHelper.java:159)
    at org.hibernate.id.IdentifierGeneratorHelper.get(IdentifierGeneratorHelper.java:145)
    at org.hibernate.id.IdentifierGeneratorHelper.getGeneratedIdentity(IdentifierGeneratorHelper.java:77)
    at org.hibernate.dialect.identity.GetGeneratedKeysDelegate.executeAndExtract(GetGeneratedKeysDelegate.java:62)
    at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:43)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3279)
    at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3885)
    at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:84)
    at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:645)
    at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:282)
    at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:263)
    at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:317)
    at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:330)
    at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:287)
    at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:193)
    at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:123)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:194)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:179)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:100)
    at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:75)
    at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107)
    at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:652)
    at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:645)
    at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:640)
    at onl.netfishers.netshot.TaskManager.addTaskSingleMode(TaskManager.java:309)
    at onl.netfishers.netshot.TaskManager.addTask(TaskManager.java:392)
    at onl.netfishers.netshot.rest.RestService.addTask(RestService.java:4845)
    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.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124)
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167)
    at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:219)
    at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79)
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:475)
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:397)
    at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81)
    at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:255)
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
    at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
    at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
    at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
    at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:234)
    at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:684)
    at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
    at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:366)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:319)
    at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
    at org.glassfish.grizzly.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:124)
    at org.glassfish.grizzly.servlet.FilterChainImpl.invokeFilterChain(FilterChainImpl.java:83)
    at org.glassfish.grizzly.servlet.ServletHandler.doServletService(ServletHandler.java:202)
    at org.glassfish.grizzly.servlet.ServletHandler.service(ServletHandler.java:149)
    at org.glassfish.grizzly.http.server.HttpHandler$1.run(HttpHandler.java:200)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:569)
    at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:549)
    at java.base/java.lang.Thread.run(Thread.java:829)
pfunkylol commented 1 year ago

Hi,

Since the task doesnt work from the GUI to cleanup the view/db, how can I delete from postgresql these old entries w/o messing up the entire application ? Im interested more in the tables where the config and tasks are stored.

pfunkylol commented 9 months ago

welp ?