Hi,
I am trying to use the postgres function of partitioning tables in the sentry database. To do this, I selected several tables, re-created them by adding a new field ‘day’, and then create partition using this field as the partitioning key:
CREATE TABLE sentry_commit ( id bigint NOT NULL, organization_id integer NOT NULL, repository_id integer NOT NULL, key character varying(64) NOT NULL, date_added timestamp with time zone NOT NULL, author_id bigint, message text, day date not null default now(), primary key (id, day), unique (repository_id, key, day), CONSTRAINT sentry_commit_organization_id_check CHECK ((organization_id >= 0)), CONSTRAINT sentry_commit_repository_id_check CHECK ((repository_id >= 0)) ) PARTITION BY RANGE (day);
CREATE TABLE IF NOT EXISTS sentry_commit_20201006 PARTITION OF sentry_commit (id DEFAULT nextval('sentry_commit_id_seq'::regclass)) FOR VALUES FROM ('2020-10-06') TO ('2020-10-07');
I have a problem with the data insertion that occurs when the sentry application is running. In the logs I see such error:
STATEMENT: INSERT INTO "sentry_commit" ("organization_id", "repository_id", "key", "date_added", "author_id", "message") VALUES (1, 2, '7fcb5e811e45e764a59509a2262d14d70b11fc0a', '2020-10-06 12:15:27+00:00', 20, '(#95411) Add payment methods ') RETURNING "sentry_commit"."id" ERROR: null value in column "id" violates not-null constraint DETAIL: Failing row contains (null, 1, 2, 1076315d3f59ddff64b85da5d374e562b6a121fe, 2020-10-06 12:15:28+00, 20, Merge branch 'f/95411' into 'master'
.
And I understand the occurrence of an error, since the first value of the insert is just null, but how does the insert work with unmodified tables? They also have null constraints.
It occurs to work with the following tables:
- sentry_eventmapping
- sentry_eventtag
- sentry_eventuser
- sentry_activity
- sentry_commit
- sentry_filtervalue
- sentry_message
With other tables like nodestore_node and sentry_messagefiltervalue partitioning works. It would be useful to know what the difference between insertions in different tables is and how can I fix partition creation?
Thank you.