Corropted Database


#1

Hi,

I’ve a an issue with my gitlab databases, while trying to backup the current status.

# gitlab-rake gitlab:backup:create
Dumping database ... 
Dumping PostgreSQL database gitlabhq_production ... pg_dump: query to get data of sequence "oauth_access_grants_id_seq" returned 0 rows (expected 1) 
[FAILED]
Backup failed

This occurred after I had to fix corrupted inode on the harddisk.
Is there any way of fix this table without restore an backup?
Since unfortunately the last successful backup is now 2 month old…

Thanks!


#2

I was lucky and able to restore this damn sequence by:

DROP SEQUENCE oauth_access_grants_id_seq CASCADE;
CREATE SEQUENCE public.oauth_access_grants_id_seq   START WITH 1 INCREMENT BY 1  NO MINVALUE   NO MAXVALUE  CACHE 1;
ALTER TABLE ONLY public.oauth_access_grants ALTER COLUMN id SET DEFAULT nextval('public.oauth_access_grants_id_seq'::regclass);
ALTER TABLE public.oauth_access_grants_id_seq OWNER TO gitlab;

Hope that help somebody else.
so long.