# Error while inserting into newly created table

**URL:** <https://forum.yugabyte.com/t/error-while-inserting-into-newly-created-table/1549>\
**Category:** General\
**Created:** [March 30, 2022, 12:17pm UTC](https://forum.yugabyte.com/t/error-while-inserting-into-newly-created-table/1549 "2022-03-30T12:17:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vlst](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@vlst](https://forum.yugabyte.com/u/vlst)\
**Post date:** [March 30, 2022, 12:17pm UTC](https://forum.yugabyte.com/t/error-while-inserting-into-newly-created-table/1549/1 "2022-03-30T12:17:22Z")

</div>

Hello, I am running Yugabyte 2.12.1.0 on single node, and I am executing via ysqlsh an SQL script on a “fresh” database that creates the database schema and inserts data into some of the newly created tables. The SQL script therefore contains both DDL and DML statements, and these are interspersed (for example, a table is created, then there may be some INSERT statements for this table, then another table is created, and so forth).

I have seen the following happen once, after the following SQL was executed:  
CREATE TABLE ptcraneregion  
(  
id integer,  
region CHARACTER VARYING,  
pc numeric,  
rc numeric,  
pd numeric,  
rd numeric,  
sd numeric,  
CONSTRAINT pk\_pt\_crane\_region PRIMARY KEY(id)  
);

insert into ptcraneregion values (1,‘A’,0.000088,3.45,2.27,0.205,1.49);

with the following appearing in the ~/var/logs/tserver/postgresql-2022-03-30\_000000.log file:  
I0330 09:49:57.246927 297368 ybccmds.c:482] Creating Table my\_database.public.ptcraneregion  
2022-03-30 09:49:57.383 UTC [297368] **ERROR: could not open relation with OID 66783 at character 13**  
2022-03-30 09:49:57.383 UTC [297368] STATEMENT: insert into ptcraneregion values (1,‘A’,0.000088,3.45,2.27,0.205,1.49);

Is there anything we can do to avoid such error? For example, do we need to wait for some time period to elapse before inserting data into a newly created table?

Your input is greatly appreciated.

Thank you

---

<div class="post-metadata">

**Author:** ![yogi](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/yogi/32/384_2.png) [@yogi](https://forum.yugabyte.com/u/yogi)\
**Post date:** [March 30, 2022, 1:44pm UTC](https://forum.yugabyte.com/t/error-while-inserting-into-newly-created-table/1549/2 "2022-03-30T13:44:22Z")

</div>

What is the command you used for creating the cluster?

Can you describe the table to check the definition?

What do you see in the ui for table? Are there any tablet present?

Normally completion of create table should suffice and making the table ready for insertion unles there is some issue with storage. Since thisnis a single node cluster its unlikely to be a network related issue.

---

<div class="post-metadata">

**Author:** ![dorian\_yugabyte](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.yugabyte.com/dorian_yugabyte/32/206_2.png) [@dorian\_yugabyte](https://forum.yugabyte.com/u/dorian_yugabyte)\
**Post date:** [March 30, 2022, 2:47pm UTC](https://forum.yugabyte.com/t/error-while-inserting-into-newly-created-table/1549/3 "2022-03-30T14:47:32Z")

</div>

Can you also describe your cluster hardware? And were there any error logs when you ran the script on the yb-tserver/yb-master? You can do `./bin/yugabyted collect_logs` if you used `yugabyted` cli to start the node.

---

<div class="post-metadata">

**Author:** ![vlst](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@vlst](https://forum.yugabyte.com/u/vlst)\
**Post date:** [March 30, 2022, 3:34pm UTC](https://forum.yugabyte.com/t/error-while-inserting-into-newly-created-table/1549/4 "2022-03-30T15:34:34Z")

</div>

Thank you for your input. Unfortunately I no longer have the database with the problem. If this issue occurs again I will perform the checks you suggested.

My setup is a single-node cluster running on my development PC, which is a Dell Optiplex 790 with 16 GB RAM and 8 CPUs (= 4 cores \* 2 threads/core).

I started the single-node cluster using the command:  
yugabyted start --tserver\_flags=“pg\_yb\_session\_timeout\_ms=900000”

I checked and there were no error logs from yb-tserver nor from yb-master when I ran the script.

---

<div class="post-metadata">

**Author:** ![vlst](https://avatars.discourse-cdn.com/v4/letter/v/57b2e6/32.png) [@vlst](https://forum.yugabyte.com/u/vlst)\
**Post date:** [July 20, 2022, 2:50pm UTC](https://forum.yugabyte.com/t/error-while-inserting-into-newly-created-table/1549/5 "2022-07-20T14:50:40Z")

</div>

I am now running yugabyte-2.14.0.0 on 3 VMs, and on each VM there is 1 yb-master and 1 yb-tserver running. Each VM has 8 CPUs and 16 GB RAM. I have just been able to reproduce the issue, but this time for a different table, as seen from the following excerpt from the logs of the PostgreSQL server brought up by the yb-tserver on one of the nodes:

2022-07-20 13:49:27.882 UTC [340693] LOG: statement: CREATE TABLE ptnodedisplaysettings  
(  
id integer NOT NULL,  
color CHARACTER VARYING,  
stroke\_color CHARACTER VARYING,  
stroke\_width integer,  
size integer,  
solid\_nofill CHARACTER VARYING,  
font\_size integer,  
label\_y\_offset integer,  
font\_weight CHARACTER VARYING,  
label\_attributes CHARACTER VARYING,  
pt\_site\_name CHARACTER VARYING,  
pt\_project\_name CHARACTER VARYING,  
CONSTRAINT pk\_pt\_node\_display\_settings PRIMARY KEY (id),  
CONSTRAINT pt\_node\_display\_settings\_foreign\_key\_pt\_site\_constr FOREIGN KEY (pt\_site\_name, pt\_project\_name) REFERENCES ptsite(name, pt\_project\_name) ON DELETE CASCADE  
);  
I0720 13:49:27.980901 340693 ybccmds.c:483] Creating Table unims.public.ptnodedisplaysettings  
2022-07-20 13:49:32.677 UTC [340693] LOG: statement: INSERT INTO ptnodedisplaysettings (id, color, stroke\_color, stroke\_width, size, solid\_nofill, font\_size, label\_y\_offset, font\_weight, l  
abel\_attributes) VALUES (1, ‘#ff8000’, ‘#ff0000’, 2, 6, ‘Solid’, 11, -34, ‘bold’, ‘name’);  
2022-07-20 13:49:32.702 UTC [340693] ERROR: could not open relation with OID 17527 at character 13

After this failure, as I expected I was able to describe the table:

```auto
mydb=# \d ptnodedisplaysettings
                 Table "public.ptnodedisplaysettings"
      Column | Type | Collation | Nullable | Default
------------------+-------------------+-----------+----------+---------
 id | integer | | not null |
 color | character varying | | |
 stroke_color | character varying | | |
 stroke_width | integer | | |
 size | integer | | |
 solid_nofill | character varying | | |
 font_size | integer | | |
 label_y_offset | integer | | |
 font_weight | character varying | | |
 label_attributes | character varying | | |
 pt_site_name | character varying | | |
 pt_project_name | character varying | | |
Indexes:
    "pk_pt_node_display_settings" PRIMARY KEY, lsm (id HASH)
Foreign-key constraints:
    "pt_node_display_settings_foreign_key_pt_site_constr" FOREIGN KEY (pt_site_name, pt_project_name) REFERENCES ptsite(name, pt_project_name) ON DELETE CASCADE

```

In the table UI I saw that the ptnodedisplaysettings table had 1 tablet.  
Finally, there were no errors logged for yb-master nor yb-tserver on any of the 3 VMs at the time this happened.

The yb-master was started on each node using a command of the following form:  
yb-master --master\_addresses :7100,:7100,:7100 --rpc\_bind\_addresses :7100 --fs\_data\_dirs /data/vlst/yugabyte/yugabyte-2.14.0.0/data

and the yb-tserver was brought up on each VM with a command of this format:  
yb-tserver --tserver\_master\_addrs :7100,:7100,:7100 \  
–rpc\_bind\_addresses :9100 \  
–fs\_data\_dirs /data/vlst/yugabyte/yugabyte-installed/data \  
–start\_pgsql\_proxy \  
–pgsql\_proxy\_bind\_address :5433 \  
–ysql\_log\_statement all \  
–ysql\_timezone XXXXX \  
–pg\_yb\_session\_timeout\_ms 900000 \  
–cql\_proxy\_bind\_address :9042

Your input is greatly appreciated.  
Thank you
