Skip to content

2.25.1.0-b107

tagged this 29 Dec 16:26
Summary:
This diff adds following changes:

- Add string flag **ysql_conn_mgr_sequence_support_mode**. It has 3 values: `pooled_without_curval_lastval`, `pooled_with_curval_lastval` and `session`
  - `pooled_without_curval_lastval` : currval() and lastval() functions are not supported.
  - `pooled_with_curval_lastval` : currval() and lastval() functions are supported.
  - In these both settings, the monotonic order of sequence is not guaranteed if the `ysql_sequence_cache_method` is set to **connection**. To support monotonic order also set this flag to **session**.

- Make backend process sticky to logical connection when nextval()  function is called only if `ysql_conn_mgr_sequence_support_mode` = **session**.

- Error out currval and lastval call only if `ysql_conn_mgr_sequence_support_mode` set to `pooled_without_curval_lastval`.

|ysql_conn_mgr_sequence_support_mode | currval and lastval supported | sticky session |
|  pooled_without_curval_lastval                  |            No                                  |        No            |
|  pooled_with_curval_lastval                        |            Yes                                 |        No             |
|  session                                                          |            Yes                                 |        Yes            |

```
bin/yugabyted destroy && bin/yugabyted start --ui false --tserver_flags "ysql_conn_mgr_superuser_sticky=false,ysql_sequence_cache_method=server,enable_ysql_conn_mgr=true,ysql_conn_mgr_dowarmup=false,allowed_preview_flags_csv={enable_ysql_conn_mgr}"

yugabyte=> CREATE SEQUENCE my_seq;
CREATE SEQUENCE
yugabyte=> SELECT nextval('my_seq');
 nextval
---------
       1
(1 row)

yugabyte=> SELECT currval('my_seq');
ERROR:  currval not supported for session created by connection manager
yugabyte=> \set VERBOSITY verbose
yugabyte=> SELECT currval('my_seq');
ERROR:  55000: currval not supported for session created by connection manager
LOCATION:  currval_oid, sequence.c:1219

```

Test Plan:
Jenkins: enable connection manager, all tests

  ./yb_build.sh release  --enable-ysql-conn-mgr-test --java-test org.yb.pgsql.TestPgSequences
  ./yb_build.sh release  --enable-ysql-conn-mgr-test --java-test org.yb.pgsql.TestPgSequencesWithCacheFlag
  ./yb_build.sh release  --enable-ysql-conn-mgr-test --java-test org.yb.pgsql.TestPgSequencesWithServerCache
  ./yb_build.sh release  --enable-ysql-conn-mgr-test --java-test org.yb.pgsql.TestPgSequencesWithServerCacheFlag
  ./yb_build.sh release --java-test org.yb.ysqlconnmgr.TestMisc#testStickySequence
  ./yb_build.sh release --java-test org.yb.ysqlconnmgr.TestMisc#testCurrvalErrorOut
  ./yb_build.sh release --java-test org.yb.ysqlconnmgr.TestMisc#testLastvalErrorOut

Reviewers: skumar, rbarigidad, stiwary, vpatibandla, mkumar

Reviewed By: rbarigidad

Subscribers: yql, ybase

Differential Revision: https://phorge.dev.yugabyte.com/D40601
Assets 2
Loading