pgjdbc / r2dbc-postgresql

Postgresql R2DBC Driver
https://r2dbc.io
Apache License 2.0
1.01k stars 177 forks source link

Always execute some SQL #540

Closed zhuangzibin closed 2 years ago

zhuangzibin commented 2 years ago

Bug Report

Versions

Current Behavior

When i executed my sql once time,the server executed some sql multiple times.It can be repeated every time.

// your stack trace here
2022-08-09 11:11:12.435-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SHOW TRANSACTION ISOLATION LEVEL
2022-08-09 11:11:12.465-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SELECT oid, typname FROM pg_catalog.pg_type WHERE typname IN ('hstore','geometry')
2022-08-09 11:11:12.496-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: select 1
2022-08-09 11:11:12.525-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.PARAM [Loggers.java:250] - Bind parameter [0] to: adipisicing eu reprehenderit nisi
2022-08-09 11:11:12.530-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: select id from equipment_factory_user_record where account = $1 and deleted = false
2022-08-09 11:11:13.553-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SHOW TRANSACTION ISOLATION LEVEL
2022-08-09 11:11:13.557-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SHOW TRANSACTION ISOLATION LEVEL
2022-08-09 11:11:13.559-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SHOW TRANSACTION ISOLATION LEVEL
2022-08-09 11:11:13.570-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SHOW TRANSACTION ISOLATION LEVEL
2022-08-09 11:11:13.572-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SHOW TRANSACTION ISOLATION LEVEL
2022-08-09 11:11:13.574-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SHOW TRANSACTION ISOLATION LEVEL
2022-08-09 11:11:13.577-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SHOW TRANSACTION ISOLATION LEVEL
2022-08-09 11:11:13.580-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SHOW TRANSACTION ISOLATION LEVEL
2022-08-09 11:11:13.582-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SHOW TRANSACTION ISOLATION LEVEL
2022-08-09 11:11:13.583-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SELECT oid, typname FROM pg_catalog.pg_type WHERE typname IN ('hstore','geometry')
2022-08-09 11:11:13.584-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SELECT oid, typname FROM pg_catalog.pg_type WHERE typname IN ('hstore','geometry')
2022-08-09 11:11:13.585-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SELECT oid, typname FROM pg_catalog.pg_type WHERE typname IN ('hstore','geometry')
2022-08-09 11:11:13.594-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SELECT oid, typname FROM pg_catalog.pg_type WHERE typname IN ('hstore','geometry')
2022-08-09 11:11:13.595-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SELECT oid, typname FROM pg_catalog.pg_type WHERE typname IN ('hstore','geometry')
2022-08-09 11:11:13.596-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SELECT oid, typname FROM pg_catalog.pg_type WHERE typname IN ('hstore','geometry')
2022-08-09 11:11:13.597-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SELECT oid, typname FROM pg_catalog.pg_type WHERE typname IN ('hstore','geometry')
2022-08-09 11:11:13.598-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SELECT oid, typname FROM pg_catalog.pg_type WHERE typname IN ('hstore','geometry')
2022-08-09 11:11:13.599-19177-[[019fc610e53cea0b],[019fc610e53cea0b],[]]-[reactor-tcp-kqueue-3] DEBUG io.r2dbc.postgresql.QUERY [Loggers.java:250] - Executing query: SELECT oid, typname FROM pg_catalog.pg_type WHERE typname IN ('hstore','geometry')

Table schema

Input Code ```sql -- your SQL here; create table equipment_factory_user_record ( id bigserial constraint equipment_factory_user_record_pk primary key, account varchar(19) not null, created timestamp not null, created_by bigint not null, updated timestamp, updated_by bigint, organization_id bigint, deleted boolean default false not null ); ```

Steps to reproduce

post -> controller -> server -> repository -> database

Input Code ```java // your code here; @Data @ToString @NoArgsConstructor @AllArgsConstructor @Accessors(chain = true) @EqualsAndHashCode(callSuper = true) @Table("equipment_factory_user_record") public class EquipmentFactoryUserRecord extends BaseEntity { public static final String COLUMN_ID = "id"; public static final String COLUMN_ACCOUNT = "account"; @Id @Column(COLUMN_ID) private Long id; @Column(COLUMN_ACCOUNT) private String account; } ```

Expected behavior/code

do not execute this sql everyTime

Possible Solution

Additional context

ccwxl commented 2 years ago

check spring.r2dbc.pool.max-life-time: 30m default -1

Squiry commented 2 years ago

It looks like pool just allocating new connections when you start your application. 10 of them. And it's just an initialization log for every connection in a pool.

zhuangzibin commented 2 years ago

看起来池只是在您启动应用程序时分配新连接。其中10个。它只是池中每个连接的初始化日志。

Yes.r2dbc-pool 0.8.9 bug,0.9.0 fixed.