NetXMS Support Forum

English Support => General Support => Topic started by: luccosen on December 29, 2023, 01:21:45 AM

Title: error on export db
Post by: luccosen on December 29, 2023, 01:21:45 AM
Hi to all.,

 I receive this error when exporting the db, do you know a way to resolve it? .

ERROR: SQLite query failed: UNIQUE constraint failed: config.var_name
  Query: INSERT INTO config (var_name,var_value,default_value,is_visible,need_server_restart,data_type,is_public,description,units) VALUES ('DBConnectionPool.MaxLifetime','14400','14400','1','1','I','N','Maximum lifetime (in seconds) for a database connection.','seconds')
Database export failed.

Thank you
Title: Re: error on export db
Post by: Filipp Sudanov on December 29, 2023, 10:50:11 AM
If you open Configuration->Server Configuration in management client and search for 
DBConnectionPool.MaxLifetime

 how many entries with such name are there? If two, delete one of them. 

What DB are you using, what is NetXMS version?
Title: Re: error on export db
Post by: luccosen on December 29, 2023, 03:19:21 PM
I'm using postgres, and netxms 4.4.5.

thanks.
Title: Re: error on export db
Post by: Filipp Sudanov on December 29, 2023, 03:20:38 PM
So how many entries are there in Configuration->Server Configuration ?
Title: Re: error on export db
Post by: luccosen on December 29, 2023, 03:40:06 PM
only one  :(.


Title: Re: error on export db
Post by: Filipp Sudanov on December 29, 2023, 04:16:17 PM
Ok, and if you connect to your DB using postgres tools and run
select * from config where var_name = 'DBConnectionPool.MaxLifetime';

how many lines this query will produce?
Title: Re: error on export db
Post by: luccosen on December 29, 2023, 05:09:52 PM
ok, I see 3 lines... Have I to delete 2? 
Title: Re: error on export db
Post by: luccosen on December 29, 2023, 05:19:10 PM
wich is the correct command to delete only 2 row? 

thanks
Title: Re: error on export db
Post by: Filipp Sudanov on December 29, 2023, 07:09:11 PM
This can be accomplished by copying only one row to a temporary table:

create temp table saved as select * from config where var_name = 'DBConnectionPool.MaxLifetime' limit 1;

delete from config where var_name = 'DBConnectionPool.MaxLifetime';

insert into config select * from saved;
Title: Re: error on export db
Post by: luccosen on December 31, 2023, 06:25:24 PM
many thanks, but I found more row duplicate  :-\ ... then I adopted the query below...

delete from config a using config b where a=b and a.ctid < b.ctid;

it works well... also for all duplicate on db. 

I resolved.