Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YSQL] Extra Secondary Index Writes on Trigger Insert + Foreign Key Check #18822

Closed
1 task done
karthik-ramanathan-3006 opened this issue Aug 23, 2023 · 1 comment
Closed
1 task done
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue

Comments

@karthik-ramanathan-3006
Copy link
Contributor

karthik-ramanathan-3006 commented Aug 23, 2023

Jira Link: DB-7701

Description

Consider the following schema:

CREATE TABLE IF NOT EXISTS trigger_table (
    h integer PRIMARY KEY NOT NULL
);

CREATE FUNCTION trigger_insert() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
  BEGIN
      INSERT INTO trigger_table (h) (SELECT NEW.h);
      RETURN NEW;
  END;
  $$;

CREATE TABLE main_table (
    h integer PRIMARY KEY NOT NULL,
    v1 integer NOT NULL,
    v2 integer NOT NULL,
    v3 integer
);

CREATE INDEX main_table_idx1 ON main_table (v1);
CREATE UNIQUE INDEX main_table_idx2 ON main_table (v2);
ALTER TABLE main_table ADD CONSTRAINT "main_table_fk" FOREIGN KEY (h) REFERENCES trigger_table(h);

CREATE TRIGGER trigger1 BEFORE INSERT ON main_table FOR EACH ROW EXECUTE FUNCTION trigger_insert();

This consists of a main table whose primary key has a foreign key constraint on a secondary table.
Additionally, the main table has a trigger, which inserts a new key into the secondary table.

Inserting a new row into the main table:

INSERT INTO main_table VALUES(0, 0, 0, 0);

When an UPDATE is issued to the non-index column column (v3) of the main table, we see write requests corresponding to DELETEs + INSERTs for each of the secondary indexes.

yugabyte=# EXPLAIN (ANALYZE, DIST) UPDATE main_table SET v3 = 1 WHERE h = 0;
                                                            QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------
 Update on main_table  (cost=0.00..4.11 rows=1 width=88) (actual time=5.575..5.576 rows=0 loops=1)
   ->  Index Scan using main_table_pkey on main_table  (cost=0.00..4.11 rows=1 width=88) (actual time=1.769..1.778 rows=1 loops=1)
         Index Cond: (h = 0)
         Storage Table Read Requests: 1
         Storage Table Read Execution Time: 0.888 ms
         Storage Table Write Requests: 1
         Storage Index Write Requests: 4
         Storage Flush Requests: 1
         Storage Flush Execution Time: 2.427 ms
 Planning Time: 0.192 ms
 Execution Time: 7.172 ms
 Storage Read Requests: 1
 Storage Read Execution Time: 0.888 ms
 Storage Write Requests: 5
 Catalog Read Requests: 1
 Catalog Read Execution Time: 3.390 ms
 Catalog Write Requests: 0
 Storage Flush Requests: 2
 Storage Flush Execution Time: 3.704 ms
 Storage Execution Time: 7.983 ms
 Peak Memory Usage: 24 kB
(21 rows)

This query should ideally have been executed as a single main table write request in a single flush.
Instead we see 4 secondary index writes + 1 main table write across 2 flushes.

Attached is a gist containing the schema:
https://gist.github.com/karthik-ramanathan-3006/8fa30b3d56829e62e228382ada3ae3b3

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.
@karthik-ramanathan-3006 karthik-ramanathan-3006 added kind/enhancement This is an enhancement of an existing feature area/ysql Yugabyte SQL (YSQL) labels Aug 23, 2023
@yugabyte-ci yugabyte-ci added the priority/medium Medium priority issue label Aug 23, 2023
@karthik-ramanathan-3006 karthik-ramanathan-3006 changed the title [YSQL] Extra Secondary Index Lookups on Trigger Insert + Foreign Key Check [YSQL] Extra Secondary Index Writes on Trigger Insert + Foreign Key Check Aug 23, 2023
@karthik-ramanathan-3006
Copy link
Contributor Author

Found a simpler reproduction for this issue. Consider a table test with the following schema:

-- Create test
CREATE TABLE test(k INT PRIMARY KEY, v1 INT, v2 INT);
CREATE INDEX test_v ON test(v1);

-- Create parent table + FK constraint
CREATE TABLE parent(h INT PRIMARY KEY);
INSERT INTO parent VALUES(1);
ALTER TABLE test ADD CONSTRAINT "test_fk" FOREIGN KEY (k) REFERENCES parent(h);

-- Create a simple trigger on test
CREATE FUNCTION trigger_print_notice() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
    BEGIN
        RAISE NOTICE 'Trigger called with new values ("%", "%", "%")', NEW.k, NEW.v1, NEW.v2;
        RETURN NEW;
    END;
    $$;

CREATE TRIGGER trigger_print BEFORE INSERT ON test FOR EACH ROW EXECUTE FUNCTION trigger_print_notice();

The table test now looks as follows:

yugabyte=# \d test
                Table "public.test"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 k      | integer |           | not null |
 v1     | integer |           |          |
 v2     | integer |           |          |
Indexes:
    "test_pkey" PRIMARY KEY, lsm (k HASH)
    "test_v" lsm (v1 HASH)
Foreign-key constraints:
    "test_fk" FOREIGN KEY (k) REFERENCES parent(h)
Triggers:
    trigger_print BEFORE INSERT ON test FOR EACH ROW EXECUTE PROCEDURE trigger_print_notice()

Let us insert a sample row into test to ensure that the BEFORE INSERT trigger fires.

yugabyte=# INSERT INTO test VALUES(1, 1, 1);
NOTICE:  Trigger called with new values ("1", "1", "1")
INSERT 0 1

Performing an update on non-index column v2 leads to unnecessary writes:

yugabyte=# EXPLAIN (ANALYZE, DIST) UPDATE test SET v2 = 3 WHERE k = 1;
                                                      QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------
 Update on test  (cost=0.00..4.11 rows=1 width=80) (actual time=14.941..14.941 rows=0 loops=1)
   ->  Index Scan using test_pkey on test  (cost=0.00..4.11 rows=1 width=80) (actual time=7.278..7.288 rows=1 loops=1)
         Index Cond: (k = 1)
         Storage Table Read Requests: 1
         Storage Table Read Execution Time: 3.676 ms
         Storage Table Write Requests: 1
         Storage Index Write Requests: 2
         Storage Flush Requests: 1
         Storage Flush Execution Time: 5.465 ms
 Planning Time: 0.341 ms
 Execution Time: 18.260 ms
 Storage Read Requests: 1
 Storage Read Execution Time: 3.676 ms
 Storage Write Requests: 3
 Catalog Read Requests: 0
 Catalog Write Requests: 0
 Storage Flush Requests: 2
 Storage Flush Execution Time: 8.343 ms
 Storage Execution Time: 12.019 ms
 Peak Memory Usage: 24 kB
(20 rows)

A similar result on change the WHERE clause:

yugabyte=# EXPLAIN (ANALYZE, DIST) UPDATE test SET v2 = 3 WHERE v2 = 3;
                                                QUERY PLAN
----------------------------------------------------------------------------------------------------------
 Update on test  (cost=0.00..102.50 rows=1000 width=80) (actual time=14.522..14.522 rows=0 loops=1)
   ->  Seq Scan on test  (cost=0.00..102.50 rows=1000 width=80) (actual time=4.518..4.533 rows=1 loops=1)
         Remote Filter: (v2 = 3)
         Storage Table Read Requests: 1
         Storage Table Read Execution Time: 2.782 ms
         Storage Table Write Requests: 1
         Storage Index Write Requests: 2
         Storage Flush Requests: 1
         Storage Flush Execution Time: 8.581 ms
 Planning Time: 0.126 ms
 Execution Time: 17.401 ms
 Storage Read Requests: 1
 Storage Read Execution Time: 2.782 ms
 Storage Write Requests: 3
 Catalog Read Requests: 1
 Catalog Read Execution Time: 6.122 ms
 Catalog Write Requests: 0
 Storage Flush Requests: 2
 Storage Flush Execution Time: 11.013 ms
 Storage Execution Time: 19.917 ms
 Peak Memory Usage: 55 kB
(21 rows)

Summary: A table with a FK constrain and a trigger (which are in no way related to each other) causes writes to all secondary indexes in the table.

karthik-ramanathan-3006 added a commit that referenced this issue Aug 1, 2024
… checks when relevant columns not modified

Summary:
**Background**
Prior to this revision, an UPDATE statement specifying a list of target columns X in its SET clause, **always** performed the necessary work to update each of the target columns in the storage layer, irrespective of whether the values of the columns actually changed. The necessary work could include requiring locks, updating indexes, checking of constraints, firing of triggers etc.

**The Optimization**
This revision introduces an optimization that validates that the values of a column are indeed being modified, before sending (flushing) the updated value of the column to the storage layer.
In particular, the set of columns whose values that are compared are those that can cause extra round trips to the storage layer in the form of:
 - Primary Key Updates
 - Secondary Index Updates
 - Foreign Key Constraints
 - Uniqueness Constraints

The matrix of columns that are marked for update and the objects (indexes, constraints) they impact are computed at planning time.
This is particularly useful when used in conjunction with prepared statements and ORMs, which tend to specify all columns (both modified and non-modified) as part of the target list.
The decision of whether a column is indeed modified is done on a per-tuple basis at execution time.

**Example**
As a concrete example, consider a table with the following schema and data:
```
yugabyte=# CREATE TABLE foo (h INT PRIMARY KEY, v1 INT, v2 INT, v3 INT);
yugabyte=# CREATE INDEX foo_v1_idx ON foo (v1);
yugabyte=# CREATE INDEX foo_v2_idx ON foo (v2);
yugabyte=# INSERT INTO foo (SELECT i, i, i % 10, i % 100 FROM generate_series(1, 10000) AS i);
```

Performing an UPDATE on the first 1000 rows (without the optimization) yields:
```
yugabyte=# SET yb_explain_hide_non_deterministic_fields TO true;
yugabyte=# EXPLAIN (ANALYZE, DIST) UPDATE foo SET h = v1, v1 = v1, v3 = v3 + 1 WHERE v1 <= 1000;
                                        QUERY PLAN
------------------------------------------------------------------------------------------
 Update on foo  (cost=0.00..105.00 rows=1000 width=88) (actual rows=0 loops=1)
   ->  Seq Scan on foo  (cost=0.00..105.00 rows=1000 width=88) (actual rows=1000 loops=1)
         Remote Filter: (v1 <= 1000)
         Storage Table Read Requests: 1
         Storage Table Rows Scanned: 10000
         Storage Table Write Requests: 2000
         Storage Index Write Requests: 4000
         Storage Flush Requests: 2000
 Storage Read Requests: 1
 Storage Rows Scanned: 10000
 Storage Write Requests: 6000
 Storage Flush Requests: 2001
(12 rows)
```

The values of `h` and `v1` are not modified by the query, yet result in multiple write requests to both the main table as well as the secondary indices.
Since updates to key columns (of a table or an index) is executed as a sequence of a DELETE followed by an INSERT, this query requires a large amount of flushes.
This makes the query very expensive in terms of the amount of work to be done.
With the proposed optimization the query is executed as follows:
```
yugabyte=# EXPLAIN (ANALYZE, DIST) UPDATE foo SET h = v1, v1 = v1, v3 = v3 + 1 WHERE v1 <= 1000;
                                        QUERY PLAN
------------------------------------------------------------------------------------------
 Update on foo  (cost=0.00..105.00 rows=1000 width=88) (actual rows=0 loops=1)
   ->  Seq Scan on foo  (cost=0.00..105.00 rows=1000 width=88) (actual rows=1000 loops=1)
         Remote Filter: (v1 <= 1000)
         Storage Table Read Requests: 1
         Storage Rows Scanned: 10000
         Storage Table Write Requests: 1000
 Storage Read Requests: 1
 Storage Rows Scanned: 10000
 Storage Write Requests: 1000
 Storage Flush Requests: 1
(10 rows)
```

**Flags and Feature Status**
This revision introduces the following GUCs to control the behavior of this optimization:
`yb_update_num_cols_to_compare` - The maximum number of columns to be compared. (default: 0)
`yb_update_max_cols_size_to_compare` - The maximum size of an individual column that can be compared. (default: 10240)

This feature is currently turned off as a result of setting `yb_update_num_cols_to_compare` to 0.

**Debuggability**
Turn on postgres debug2 logs via the following command:
```
./bin/yb-ctl restart --ysql_pg_conf_csv='log_min_messages=debug2'
```

This produces the following debug information:
```
-- At planning time
2024-07-31 10:59:07.124 PDT [76120] DEBUG: Update matrix: rows represent OID of entities, columns represent attnum of cols
2024-07-31 10:59:07.124 PDT [76120] DEBUG:  -		10
2024-07-31 10:59:07.124 PDT [76120] DEBUG:  17415	Y

-- At execution time, on a per-tuple basis
2024-07-31 10:59:07.143 PDT [76120] DEBUG:  Index/constraint with oid 17415 requires an update
2024-07-31 10:59:07.143 PDT [76120] DEBUG:  Relation: 17412	Columns that are inspected and modified: 1 (10)
2024-07-31 10:59:07.143 PDT [76120] DEBUG:  No cols in category: Columns that are inspected and unmodified
2024-07-31 10:59:07.143 PDT [76120] DEBUG:  Relation: 17412	Columns that are marked for update: 1 (10) 2 (11)
```

**Future Work**
 1. Introduce auto-flag infrastructure to safely use row-locking. This is in the context of upgrade safety while the cluster is being upgraded.
 2. As a part of the flag infrastructure, ensure that flags/GUC values are immutable during the lifetime of a query.
 3. #22994: PGSQL_UPDATEs with no column references should acquire row locks.
 4. #23348: Add support for partitioned tables with out of order columns.
 5. Support for serializing optimization metadata in plans.
 6. Enhance randgen grammar to support ModifyTable (INSERT/UPDATE/DELETE ) queries
 7. #23350: PG 15 support.

jenkins: urgent
Jira: DB-7701

Test Plan:
Run the associated pg_regress test as follows:
```
# New tests
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressUpdateOptimized#schedule'

# Existing tests
./yb_build.sh --java-test 'org.yb.pgsql.TestPgUpdatePrimaryKey'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgUniqueConstraint'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressTrigger#testPgRegressTrigger'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressDml#testPgRegressDml'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressPushdown#testPgRegressPushdown'
```

Tested scenarios include (but not limited to):
1. Single row and distributed transactions with and without the feature flag turned on.
2. Relations with a primary key and no secondary indexes or triggers (UPDATEs can take the single row path)
3. Relations with combinations of primary key and secondary indexes.
4. Relations with unconditional before-row triggers.
5. UPDATEs in Colocated databases.
6. UPDATEs covering multiple tuples.
7. Hierarchy of relations with foreign keys
8. Relations with self referential foreign keys
9. Relations with overlapping indexes.
10. Relations having columns with uniqueness constraints.
11. Relations having covering indexes.
12. Relations having partial indexes.
13. Relations having index expressions / predicates.
14. Relations with conditional column triggers.
15. Relations having indexes/constraints out of order (ie. order of columns in relation is different from that of entity)
16. Relations having combination of hash and range indexes.
17. UPDATEs with correlated subqueries.
18. INSERT ON CONFLICT DO UPDATE.
19. UPDATE RETURNING.
20. UPDATEs on temp tables.

Reviewers: mihnea, jason, amartsinchyk

Reviewed By: amartsinchyk

Subscribers: pjain, jason, smishra, yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D34040
jasonyb pushed a commit that referenced this issue Aug 2, 2024
Summary:
 66890cb [PLAT-14781] Add runtime config for download metrics as pdf
 b2f24f2 [#9797] YSQL: Stubs for ysql major version upgrade RPCs
 5891faa [#23332] Docdb: Fix yb-admin to handle snapshot_retention correctly
 0614c52 [PLAT-14756] Releases API RBAC cleanup
 2cfb999 [docs] Release notes for 2024.1.1.0-b137 (#23185)
 d868a03 [PLAT-13495] Do not run dual nic steps on systemd upgrade
 10bc447 [PLAT-14798] Adding internal load balancer to devspace
 7296df8 [docs] [2.23] Add pg_cron extension docs (#22546)
 79902ae [PLAT-14678] - feat : Export All Metrics to pdf
 8a0b95c [#23322] YSQL: pg_partman: fix logic of checking existing table
 Excluded: 63f471a [#18822] YSQL: Framework to skip redundant sec index updates and fkey checks when relevant columns not modified
 3040472 [PLAT-14783] [PGParity] After Edit RR cores scale up on PG Parity enabled cluster, the RR node does not have PGP gflags
 e052089 [PLAT-14774] Per process tserver metrics is not working if YSQL is disabled
 0c664a1 [#22370] docdb: Cost Based Optimizer changes to take into account backward scans improvement
 a060877 [PLAT-13712]fix plan info for Azure VMs
 291dd40 Remove 6sense domains from CSP headers (#23354)
 75cb273 [#23330] docdb: fixed static columns handling for CQL operations

Test Plan: Jenkins: rebase: pg15-cherrypicks

Reviewers: jason, tfoucher

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D36984
karthik-ramanathan-3006 added a commit that referenced this issue Aug 20, 2024
… sec index updates and fkey checks when relevant columns not modified

Summary:
**Conflict Resolution for PG15 cherrypick**
- src/postgres/src/include/nodes/plannodes.h:
    - Location: struct ModifyTable definition:
        - My master commit adds two new fields (`yb_update_affected_entities`, `yb_skip_entities`) and subsumes (`no_update_index_list`)
        - YB-PG 15 has added new fields (`ybUseScanTupleInUpdate`, `ybHasWholeRowAttribute`)
        - Merge resolution: Keep newly added fields from both, remove `no_update_index_list`
    - Location: imports
        - My master commit adds the import `nodes/ybbitmatrix.h`
        - YB-PG 15 changes `nodes/relation.h` to `access/relation.h` and adds `nodes/parsenodes.h`, `nodes/pathnodes.h`
        - Merge resolution: Add nodes/ybbitmatrix.h, nodes/parsenodes.h, nodes/pathnodes.h and change nodes/relation.h to access/relation.h
- src/postgres/src/include/executor/executor.h
    - Location: “prototypes from functions in execIndexing.c”
        - My master commit removes the `no_update_index_list` arg from ExecInsertIndexTuples and ExecDeleteIndexTuplesOptimized and removes the function `ContainsIndexRelation`
        - YB-PG 15 has rearranged the location of function definitions, added a `ResultRelInfo` field to the *IndexTuple functions
        - Merge resolution: Keep functions in rearranged locations, add `ResultRelInfo` and remove `no_update_index_list` to ExecInsertIndexTuples, remove ExecDeleteIndexTuplesOptimized altogether, remove `ContainsIndexRelation`
- src/postgres/src/backend/utils/misc/guc.c:
    - Location: integer GUCs
        - My master commit adds new GUCs (`yb_update_num_cols_to_compare`, `yb_update_max_cols_size_to_compare`)
        - This caused an adjacency conflict with YB-PG 15 (41c091a) that changed QUERY_TUNING to QUERY_TUNING_OTHER for `yb_parallel_range_rows`.
        - Merge resolution: Add my new GUCs and change QUERY_TUNING_OTHER for `yb_parallel_range_rows`.
- src/postgres/src/include/utils/relcache.h:
    - Location: “Routines to compute/retrieve additional cached information”
        - My master commit adds a new function `YbComputeIndexExprOrPredicateAttrs`.
        - YB-PG 15 adds new functions `RelationGetIdentityKeyBitmap` (upstream PG commit: e7eea52b2d61917fbbdac7f3f895e4ef636e935b), `RelationGetIndexPredicate` and `RelationGetIndexRawAttOptions` (upstream PG commit: 911e70207703799605f5a0e8aad9f06cff067c63) causing adjacency conflicts. Further, 55782d5 moves down `CheckIndexForUpdate` declaration.
        - Merge resolution: Add all new functions, move down `CheckIndexForUpdate` declaration
- src/postgres/src/backend/utils/cache/relcache.c:
    - Location: IsProjectionFunctionalIndex
        - My master commit adds a new function `YbComputeIndexExprOrPredicateAttrs`
        - YB-PG 15 removed a function in the same area: `IsProjectionFunctionalIndex`
        - Merge resolution: Add `YbComputeIndexExprOrPredicateAttrs`, remove `IsProjectionFunctionalIndex`
    - Location: YbRelationGetFKeyReferencedByList
        - Not a merge conflict. In YB-PG 15, `DeconstructFkConstraintRow` has additional outparams to retrieve ON DELETE SET NULL/DEFAULT cols. This info is not needed, hence the params are set to NULL.
        - Not a merge conflict. Fetch the constraint oid from `Form_pg_constraint` instead of fetching it from the HeapTuple directly.
- src/postgres/src/include/commands/trigger.h:
    - Location: “in utils/adt/ri_triggers.c”
        - My master commit adds a new param `yb_skip_entities` to `RI_FKey_pk_upd_check_required` and `RI_FKey_fk_upd_check_required`
        - YB-PG 15 uses TupleTableSlots instead of HAeapTuples in the function definition + lint changes
        - Resolution: Added new param and replaced HeapTuples with TupleTableSlots
- src/postgres/src/backend/utils/adt/ri_triggers.c:
    - Same as above
- src/postgres/src/backend/commands/trigger.c:
    - Location: AfterTriggerSaveEvent
    - Same context as above
    - Additionally, YB-PG 15 skips foreign key update checks on partitioned tables (upstream PG commit: ba9a7e392171c83eb3332a757279e7088487f9a2). This behavior is retained in the conflict resolution.
- src/postgres/src/backend/optimizer/util/ybcplan.c:
    - Location: imports
        - My master commit moved around the location of `yb/yql/pggate/ybc_pggate.h` (albeit accidentally)
        - YB-PG 15 (55782d5) moves `ybcplan.h` out of the "YB includes" section to under "postgres.h"
        - Merge resolution: Retain locations of “ybc_pggate.h” and “ybcplan.h” that are already present YB-PG 15
- src/postgres/src/backend/optimizer/plan/createplan.c:
    - Location: “create_modifytable_plan”
        - My master commit adds a local variable `yb_is_single_row_update_or_delete`
        - YB-PG 15 has rearranged the location of the variable declarations
        - Merge resolution: Retain PG 15’s rearrangement, add my local variable
- src/postgres/src/backend/executor/execIndexing.c:
    - Location: ExecInsertIndexTuples
        - My master commit updated function definition as per `executor/executor.h`
        - In YB-PG 15, YB introduced function `ExecInsertIndexTuplesOptimized` was deleted during the pg15 initial merge 55782d5, causing a conflict.
        - Merge resolution: Remove `no_update_index_list` arg from ExecInsertIndexTuples and remove `ExecInsertIndexTuplesOptimized`.
    - Location: ExecInsertIndexTuples
        - PG 15 introduced the notion of hints to the storage in case an index is not modified.
        Yugabyte does not require this as this computation is already being done (and enforced).
        - Merge resolution: The indexUnchanged hint will always evaluate to false for Yugabyte relations. Added a comment explaining this decision.
    - Location: ExecDeleteIndexTuples
        - My master commit updated function definition as per `executor/executor.h`
        - In YB-PG 15, an extra parameter `resultRelInfo` is added.
        - Merge resolution: Removed `ExecDeleteIndexTuplesOptimized` and subsumed functionality into `ExecDeleteIndexTuples` as there is no longer a difference between the two implementations from a function signature point of view. Added parameter `resultRelInfo` to ExecDeleteIndexTuples
- src/postgres/src/backend/commands/copyfrom.c
    - Location: CopyFrom, CopyMultiInsertBufferFlush
        - Same context as above.
        - Merge resolution: Remove `no_update_index_list` from all invocations of `ExecInsertIndexTuples`.
- src/postgres/src/backend/executor/execReplication.c
    - Location: ExecSimpleRelationInsert, ExecSimpleRelationUpdate
        - Same context as above.
        - Merge resolution: Remove `no_update_index_list` from all invocations of `ExecInsertIndexTuples`.
- src/postgres/src/backend/executor/nodeModifyTable.c
    - Location: imports
        - My master commit adds `executor/ybOptimizeModifyTable.h`
        - YB-PG 15 moved imports from “YB includes” to “Yugabyte includes” and removed extra/unused imports
        - Merge resolution: Imports moved to “Yugabyte includes” and added `executor/ybOptimizeModifyTable.h`
    - Location: YBEqualDatums and YBBuildExtraUpdatedCols
        - Removed these functions as their functionality has moved to `executor/ybOptimizeModifyTable.h`
    - Location: ExecUpdate
        - My master commit introduces changes to compute a list of columns modified by the query for a given tuple
        - In YB-PG 15, ExecUpdate functionality has been broken into  ExecUpdatePrologue, ExecUpdateAct, ExecUpdate and ExecUpdateEpilogue.
        - Merge resolution: Moved my changes into ExecUpdateAct and ExecUpdateEpilogue.
    - Location: ExecModifyTable
        - My master commit introduces a function to compute if a tuple in an UPDATE or a DELETE query has the “wholerow” junk attribute.
        - In YB-PG 15, this logic is propagated from planning time via `plan->ybHasWholeRowAttribute`.
        - Merge resolution: Use the logic in YB-PG 15.
    - Location: YBCHasWholeRowJunkAttr
        - Same context as above.
        - Merge resolution: Remove this function
    - Location: ExecInsert
        - Merge resolution: Remove `no_update_index_list` from four invocations of `ExecInsertIndexTuples`.
    - Location: YBExecUpdateAct
        - Not a conflict, but use of`ExecMaterializeSlot` has been changed to `ExecFetchSlotHeapTuple`. It is needed to copy the slot out to a HeapTuple in order to if columns are modified by the update query.
- src/postgres/src/backend/rewrite/rewriteHandler.c
    - Location: YbAddWholeRowAttrIfNeeded
        - My master commit adds a new function `YbAddWholeRowAttrIfNeeded`
        - Conflict on PG side is upstream PG 41531e42d34f4aca117d343b5e40f3f757dec5fe and ed4653db8ca7a70ba7a4d329a44812893f8e59c2 adding code at end of rewriteValuesRTE.
        - Merge resolution: Remove all changes from YB master, retain YB-PG 15 changes. This removes functionality which will be re-evaluated and added back in a future diff.
- src/include/executor/ybOptimizeModifyTable.h
    - Location: imports
        - Not a merge conflict, added a new include `nodes/execnodes.h`
    - Location: YbComputeModifiedColumnsAndSkippableEntities
        - Added a new arg `ResultRelInfo *`  to specify the relation whose modified columns are to be computed. Previously, this info was fetched from EState which contained a single relation.
        - In YB-PG 15, Estate has been modified to include a list of relations.
- src/postgres/src/backend/executor/ybOptimizeModifyTable.c
    - Location: YBEqualDatums
        - Not a merge conflict, but initialization of `FunctionCallInfoData` changed in YB-PG 15 for call information to be variable length (reference upstream PG commit `a9c35cf85ca1ff72f16f0f10d7ddee6e582b62b8`).
        - Changed this function to use new initialization.
    - Location: YbComputeModifiedColumnsAndSkippableEntities
        - Added a new arg `ResultRelInfo *`  to specify the relation whose modified columns are to be computed. Previously, this info was fetched from EState which contained a single relation.
        - In YB-PG 15, Estate has been modified to include a list of relations.
- src/postgres/src/backend/nodes/Makefile
    - Location: OBJS
        - My master commit adds `ybbitmatrix.o` object file.
        - In YB-PG 15, the list of objects was reformatted to have one object/file per line
        - Merge resolution: Added `ybbitmatrix.o` to the head of the list, retaining the new format
- src/postgres/src/backend/executor/Makefile
    - Location: OBJS
        - Resolve as in ad2fedc for ybOptimizeModifyTable.o added by YB master

**Background**
Prior to this revision, an UPDATE statement specifying a list of target columns X in its SET clause, **always** performed the necessary work to update each of the target columns in the storage layer, irrespective of whether the values of the columns actually changed. The necessary work could include requiring locks, updating indexes, checking of constraints, firing of triggers etc.

**The Optimization**
This revision introduces an optimization that validates that the values of a column are indeed being modified, before sending (flushing) the updated value of the column to the storage layer.
In particular, the set of columns whose values that are compared are those that can cause extra round trips to the storage layer in the form of:
 - Primary Key Updates
 - Secondary Index Updates
 - Foreign Key Constraints
 - Uniqueness Constraints

The matrix of columns that are marked for update and the objects (indexes, constraints) they impact are computed at planning time.
This is particularly useful when used in conjunction with prepared statements and ORMs, which tend to specify all columns (both modified and non-modified) as part of the target list.
The decision of whether a column is indeed modified is done on a per-tuple basis at execution time.

**Example**
As a concrete example, consider a table with the following schema and data:
```
yugabyte=# CREATE TABLE foo (h INT PRIMARY KEY, v1 INT, v2 INT, v3 INT);
yugabyte=# CREATE INDEX foo_v1_idx ON foo (v1);
yugabyte=# CREATE INDEX foo_v2_idx ON foo (v2);
yugabyte=# INSERT INTO foo (SELECT i, i, i % 10, i % 100 FROM generate_series(1, 10000) AS i);
```

Performing an UPDATE on the first 1000 rows (without the optimization) yields:
```
yugabyte=# SET yb_explain_hide_non_deterministic_fields TO true;
yugabyte=# EXPLAIN (ANALYZE, DIST) UPDATE foo SET h = v1, v1 = v1, v3 = v3 + 1 WHERE v1 <= 1000;
                                        QUERY PLAN
------------------------------------------------------------------------------------------
 Update on foo  (cost=0.00..105.00 rows=1000 width=88) (actual rows=0 loops=1)
   ->  Seq Scan on foo  (cost=0.00..105.00 rows=1000 width=88) (actual rows=1000 loops=1)
         Remote Filter: (v1 <= 1000)
         Storage Table Read Requests: 1
         Storage Table Rows Scanned: 10000
         Storage Table Write Requests: 2000
         Storage Index Write Requests: 4000
         Storage Flush Requests: 2000
 Storage Read Requests: 1
 Storage Rows Scanned: 10000
 Storage Write Requests: 6000
 Storage Flush Requests: 2001
(12 rows)
```

The values of `h` and `v1` are not modified by the query, yet result in multiple write requests to both the main table as well as the secondary indices.
Since updates to key columns (of a table or an index) is executed as a sequence of a DELETE followed by an INSERT, this query requires a large amount of flushes.
This makes the query very expensive in terms of the amount of work to be done.
With the proposed optimization the query is executed as follows:
```
yugabyte=# EXPLAIN (ANALYZE, DIST) UPDATE foo SET h = v1, v1 = v1, v3 = v3 + 1 WHERE v1 <= 1000;
                                        QUERY PLAN
------------------------------------------------------------------------------------------
 Update on foo  (cost=0.00..105.00 rows=1000 width=88) (actual rows=0 loops=1)
   ->  Seq Scan on foo  (cost=0.00..105.00 rows=1000 width=88) (actual rows=1000 loops=1)
         Remote Filter: (v1 <= 1000)
         Storage Table Read Requests: 1
         Storage Rows Scanned: 10000
         Storage Table Write Requests: 1000
 Storage Read Requests: 1
 Storage Rows Scanned: 10000
 Storage Write Requests: 1000
 Storage Flush Requests: 1
(10 rows)
```

**Flags and Feature Status**
This revision introduces the following GUCs to control the behavior of this optimization:
`yb_update_num_cols_to_compare` - The maximum number of columns to be compared. (default: 0)
`yb_update_max_cols_size_to_compare` - The maximum size of an individual column that can be compared. (default: 10240)

This feature is currently turned off as a result of setting `yb_update_num_cols_to_compare` to 0.

**Debuggability**
Turn on postgres debug2 logs via the following command:
```
./bin/yb-ctl restart --ysql_pg_conf_csv='log_min_messages=debug2'
```

This produces the following debug information:
```
-- At planning time
2024-07-31 10:59:07.124 PDT [76120] DEBUG: Update matrix: rows represent OID of entities, columns represent attnum of cols
2024-07-31 10:59:07.124 PDT [76120] DEBUG:  -		10
2024-07-31 10:59:07.124 PDT [76120] DEBUG:  17415	Y

-- At execution time, on a per-tuple basis
2024-07-31 10:59:07.143 PDT [76120] DEBUG:  Index/constraint with oid 17415 requires an update
2024-07-31 10:59:07.143 PDT [76120] DEBUG:  Relation: 17412	Columns that are inspected and modified: 1 (10)
2024-07-31 10:59:07.143 PDT [76120] DEBUG:  No cols in category: Columns that are inspected and unmodified
2024-07-31 10:59:07.143 PDT [76120] DEBUG:  Relation: 17412	Columns that are marked for update: 1 (10) 2 (11)
```

**Future Work**
 1. Introduce auto-flag infrastructure to safely use row-locking. This is in the context of upgrade safety while the cluster is being upgraded.
 2. As a part of the flag infrastructure, ensure that flags/GUC values are immutable during the lifetime of a query.
 3. #22994: PGSQL_UPDATEs with no column references should acquire row locks.
 4. #23348: Add support for partitioned tables with out of order columns.
 5. Support for serializing optimization metadata in plans.
 6. Enhance randgen grammar to support ModifyTable (INSERT/UPDATE/DELETE ) queries
 7. #23350: PG 15 support.

jenkins: urgent
Jira: DB-7701

Original commit: 63f471a / D34040

Test Plan:
Run the associated pg_regress test as follows:
```
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressUpdateOptimized#schedule'

./yb_build.sh --java-test 'org.yb.pgsql.TestPgUpdatePrimaryKey'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgUniqueConstraint'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressTrigger#testPgRegressTrigger'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressDml#testPgRegressDml'
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressPushdown#testPgRegressPushdown'
```

Tested scenarios include (but not limited to):
1. Single row and distributed transactions with and without the feature flag turned on.
2. Relations with a primary key and no secondary indexes or triggers (UPDATEs can take the single row path)
3. Relations with combinations of primary key and secondary indexes.
4. Relations with unconditional before-row triggers.
5. UPDATEs in Colocated databases.
6. UPDATEs covering multiple tuples.
7. Hierarchy of relations with foreign keys
8. Relations with self referential foreign keys
9. Relations with overlapping indexes.
10. Relations having columns with uniqueness constraints.
11. Relations having covering indexes.
12. Relations having partial indexes.
13. Relations having index expressions / predicates.
14. Relations with conditional column triggers.
15. Relations having indexes/constraints out of order (ie. order of columns in relation is different from that of entity)
16. Relations having combination of hash and range indexes.
17. UPDATEs with correlated subqueries.
18. INSERT ON CONFLICT DO UPDATE.
19. UPDATE RETURNING.
20. UPDATEs on temp tables.

Reviewers: jason, tfoucher

Reviewed By: jason

Subscribers: yql, smishra, jason, pjain

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D37350
karthik-ramanathan-3006 added a commit that referenced this issue Sep 3, 2024
…timizations are enabled

Summary:
D34040 introduced a framework to skip redundant secondary index updates and foreign key checks.
As a part of the implementation, this revision skipped writing out unmodified columns to the main table.
For correctness reasons, skipping writes of specific columns to the main table requires the acquisition of row-level locks.
(In the event that no columns are modified, one is still required to acquire a row lock on the affected row)

This created a dependency between the update optimization and the row locking feature.
The latter is controlled by the autoflag `ysql_skip_row_lock_for_update`.
This revision seeks to remove this dependency by continuing to write out unmodified columns to the main table.

There is one notable exception to this behavior: unmodified columns that are a part of the primary key.
If the value of the primary key remains unmodified, its columns are not written out to the main table as this would require an extra round trip to the storage layer.
Jira: DB-7701

Test Plan:
Run the following tests and ensure that there are no regressions:
```
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressUpdateOptimized#schedule'
```

Reviewers: amartsinchyk

Reviewed By: amartsinchyk

Subscribers: smishra, yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D37545
jasonyb pushed a commit that referenced this issue Sep 5, 2024
Summary:
 f8049b8 [doc][xcluster][2024.1.2] Semi-automatic transactional xCluster (#23710)
 f2c8470 [docs][yugabyted][2024.1.2] Add Read Replica and xCluster examples (#23289)
 ea3157c [doc][yba][2024.1.2] Export database audit logs (#23605)
 Excluded: 8bae488 [#18822] YSQL: Write out unmodified cols to main table when update optimizations are enabled
 5012632 [PLAT-15152] Upgrade YBC client and server version to 2.2.0.0-b5
 cccb1e1 Fix YCQL index table workflow in docs (#23774)
 9a3f5f7 [PLAT-15028] yba installer simplify postgres initdb
 a2b5e72 [docs] Release notes for 2024.1.2.0 (#23679)
 9a9690d Fix 2024.1.2 build number (#23779)
 aec361b [doc] Voyager 1.8 (#23764)
 a2540e0 [DEVOPS-3185, DEVOPS-3114] Bump up frozen pip modules to latest versions compatible with py3.8
 88f23dd [docs] [xcluster] Add min version for semi-automatic mode (#23776)
 1d61e67 Revise the entire assessment page (#23784)
 142c04a [PLAT-15089] HA sync immediately after promotion
 315110f [PLAT-15132][PLAT-15153] Allow users to configure logging level for YNP, also minor bug fixes
 82ff8d1 [PLAT-6779] Handle relative paths in yb_platform_backup.sh
 Excluded: 45c9cf8 [#23263] YSQL, ASH: Instrument more wait states
 Excluded: 9f8acff [#22148] YSQL, QueryDiagnostics:  Adding support for Ash data.
 39670e8 download links (#23790)
 2674a79 [#23780] YSQL: Modify catalog version mismatch test assertions with Connection Manager enabled
 3eb31b8 [#23777] yugabyted: update the gflags of pg parity to remove sized based fetching and add bitmap scans.
 fc5accd [docs] Enclose `allowed_preview_flags_csv` CSV parameters in brackets (#23758)

Test Plan: Jenkins: rebase: pg15-cherrypicks

Reviewers: jason, tfoucher

Differential Revision: https://phorge.dev.yugabyte.com/D37772
karthik-ramanathan-3006 added a commit that referenced this issue Sep 6, 2024
…o main table when update optimizations are enabled

Summary:
**Conflict resolution for PG 15 cherrypick**

- src/postgres/src/backend/executor/nodeModifyTable.c
    - Location: ExecUpdate —> around `else if (IsYBRelation(resultRelationDesc))`
        - YB master 8bae4881dc89205c53ee3c62668c41347394af37 updates the comment explaining what `cols_marked_for_update` does.
        - In YB pg15 be8504df264aff0472e7e91264b095a30d068bf2, this code has moved into the function YBExecUpdateAct.
        - Merge resolution: Keep changes from YB pg15, manually update the comment in YBExecUpdateAct.
    - Location: ExecUpdate —> around `if (updateCxt.crossPartUpdate)`
        - YB master 8bae4881dc89205c53ee3c62668c41347394af37 frees the bitmapset `cols_marked_for_update`.
        - In YB pg15 be8504df264aff0472e7e91264b095a30d068bf2, this code has moved into the function YBExecUpdateAct.
        - Merge resolution: Keep changes from YB pg15, manually free the bitmapset in YBExecUpdateAct.

D34040 introduced a framework to skip redundant secondary index updates and foreign key checks.
As a part of the implementation, this revision skipped writing out unmodified columns to the main table.
For correctness reasons, skipping writes of specific columns to the main table requires the acquisition of row-level locks.
(In the event that no columns are modified, one is still required to acquire a row lock on the affected row)

This created a dependency between the update optimization and the row locking feature.
The latter is controlled by the autoflag `ysql_skip_row_lock_for_update`.
This revision seeks to remove this dependency by continuing to write out unmodified columns to the main table.

There is one notable exception to this behavior: unmodified columns that are a part of the primary key.
If the value of the primary key remains unmodified, its columns are not written out to the main table as this would require an extra round trip to the storage layer.
Jira: DB-7701

Original commit: 8bae488 / D37545

Test Plan:
Run the following tests and ensure that there are no regressions:
```
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressUpdateOptimized#schedule'
```

Reviewers: jason, tfoucher

Reviewed By: jason

Subscribers: yql, smishra

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D37812
karthik-ramanathan-3006 added a commit that referenced this issue Sep 12, 2024
… optimization metadata

Summary:
D34040 introduced a framework to skip redundant secondary index updates and foreign key checks.
As a part of this framework, metadata on skippable columns is computed at planning time and cached within the ModifyTable node.
This carries the implication that the metadata may be cached as part of prepared statements and may be subject to serialization/deserialization.
Consequently, this revision:
 - Adds a serialization/deserialization mechanism for update optimization metadata (specifically `YbUpdateAffectedEntities`; `YbSkippableEntities` was already implemented)
 - Adds a mechanism for determining equality for update optimization metadata (both `YbUpdateAffectedEntities`, `YbSkippableEntities`)
 - Adds tests around prepared statements with update optimizations enabled
Jira: DB-7701

Test Plan:
Run the following tests:
```
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressUpdateOptimized#schedule'
```

Additionally, the above test was run manually after adding the following line to test end-to-end serializability/deserializability:
```lang=diff
--- a/src/postgres/src/backend/optimizer/plan/createplan.c
+++ b/src/postgres/src/backend/optimizer/plan/createplan.c

       	if (YbIsUpdateOptimizationEnabled() &&
		((!yb_is_single_row_update_or_delete && plan->operation == CMD_UPDATE) ||
		 (plan->operation == CMD_INSERT && plan->onConflictAction == ONCONFLICT_UPDATE)))
        {
@@ -3491,6 +3492,7 @@ create_modifytable_plan(PlannerInfo *root, ModifyTablePath *best_path)
                RelationClose(rel);
        }

+       plan = stringToNode(nodeToString(plan));
        return plan;
 }
```

Reviewers: amartsinchyk, telgersma

Reviewed By: telgersma

Subscribers: smishra, yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D37601
jasonyb pushed a commit that referenced this issue Sep 12, 2024
Summary:
 aec9a66 [doc][xcluster] Truncate limitation (#23833)
 fe8890d [PLAT-13984] Change default metric graph points count from 100 to 250 + make runtime configurable.
 7d9b57b [#23869] YSQL: Fix one type of ddl atomicity stress test flakiness
 7c1bca8 [PLAT-14052][PLAT-15237] :Add advanced date-time option,Restrict CP for K8s
 afce6ad [PLAT-14158] Support multiple transactional xCluster configs per universe on YBA UI
 33342b3 [PLAT-15101] Add runtime config to turn on/off rollN for k8s
 361a99a [#23809] CDCSDK: Filter out records corresponding to index tables in colocated DBs
 8bbdf66 [docs] changed date (#23885)
 ee639f4 [#22104,#23506] YSQL: auto analyze service collects mutation counts from DDL and skips indexes
 3dbf6da Delete architecture/design/multi-region-xcluster-async-replication.md
 e013578 [#23864] DocDB: Move cluster_uuid to server common flags
 2b6a2d3 [PLAT-15062][PLAT-15071] Support DB scoped on UI and display schema change mode information
 8260075 [PLAT-15079] Treat dropped on target tables as unconfigured but preselected
 f5169ca DocDB: Follow redirects for callhome, and fix URL
 eb61ef6 [PLAT-15228] Update package installation command for YBA
 e791c40 [#18822] YSQL: Add serialization/deserialization mechanism for update optimization metadata
 e69d8cb [doc] Backups and DDLs (#23840)
 e72ae64 [PLAT-14552]filter support bundle core files by date
 8796c83 [PLAT-15274]: BackFill Pitr params for DR config and add not-null constraints in DB.
 dc9cc67 Fixed NPM test:ci build error
 2e5ebef [PLAT-15287]: Add PITR Column and Restore Window Information to Backup List
 d053e45 [#238989]yugabyted: Node doesn't join using `--join` flag
 da4da45 [#23399] DocDB: Fix StopActiveTxnsPriorTo from using local variables in the call back

Test Plan: Jenkins: rebase: pg15-cherrypicks

Reviewers: jason, tfoucher

Differential Revision: https://phorge.dev.yugabyte.com/D38008
karthik-ramanathan-3006 added a commit that referenced this issue Sep 20, 2024
Summary:
D34040 introduced a framework to skip redundant secondary index updates and foreign key checks.
This revision adds a PG preview flag `ysql_yb_update_optimization_infra` that keeps the feature turned OFF by default.
Additionally, this revision restricts lookup to this flag to the following locations:.
 - Once, during query rewriting to determine to set the wholerow junk attribute
 - Once, at planning time to determine if optimization metadata needs to be computed
 - Once, at the beginning of query execution (`ExecInitModifyTable`) to determine if we should go ahead with the optimization. This has three possibilities:
    - The feature was enabled at planning time and disabled now (during query execution). In this case optimization is not performed.
    - The feature was disabled at planning time and enabled now. In this case, there is no metadata to perform the optimization and so the optimization is skipped.
    - The features was enabled at planning time and enabled now. In this case, metadata is available and the optimization is performed.

To turn on the update optimization feature, do the following:
 - Append `ysql_yb_update_optimization_infra` to the list of flags in `allowed_preview_flags_csv`
 - Set the tserver gflag `ysql_yb_update_optimization_infra` to true.
Jira: DB-7701

Test Plan:
Run the following tests:
```
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressUpdateOptimized#schedule'
```

Reviewers: amartsinchyk

Reviewed By: amartsinchyk

Subscribers: ybase, smishra, yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D37746
foucher pushed a commit that referenced this issue Sep 24, 2024
Summary:
 5d3e83e [PLAT-15199] Change TP API URLs according to latest refactoring
 a50a730 [doc][yba] YBDB compatibility (#23984)
 0c84dbe [#24029] Update the callhome diagnostics  not to send gflags details.
 b53ed3a [PLAT-15379][Fix PLAT-12510] Option to use UTC when dealing with cron exp. in backup schedule
 f0eab8f [PLAT-15278]: Fix DB Scoped XCluster replication restart
 344bc76 Revert "[PLAT-15379][Fix PLAT-12510] Option to use UTC when dealing with cron exp. in backup schedule"
 3628ba7 [PLAT-14459] Swagger fix
 bb93ebe [#24021] YSQL: Add --TEST_check_catalog_version_overflow
 9ab7806 [#23927] docdb: Add gflag for minimum thread stack size
 Excluded: 8c8adc0 [#18822] YSQL: Gate update optimizations behind preview flag
 5e86515 [#23768] YSQL: Fix table rewrite DDL before slot creation
 123d496 [PLAT-14682] Universe task should only unlock itself and make unlock aware of the lock config
 de9d4ad [doc][yba] CIS hardened OS support (#23789)
 e131b20 [#23998] DocDB: Update usearch and other header-only third-party dependencies
 1665662 Automatic commit by thirdparty_tool: update usearch to commit 240fe9c298100f9e37a2d7377b1595be6ba1f412.
 3adbdae Automatic commit by thirdparty_tool: update fp16 to commit 98b0a46bce017382a6351a19577ec43a715b6835.
 9a819f7 Automatic commit by thirdparty_tool: update hnswlib to commit 2142dc6f4dd08e64ab727a7bbd93be7f732e80b0.
 2dc58f4 Automatic commit by thirdparty_tool: update simsimd to tag v5.1.0.
 9a03432 [doc][ybm] Azure private link host (#24086)
 039c9a2 [#17378] YSQL: Testing for histogram_bounds in pg_stats
 09f7a0f [#24085] DocDB: Refactor HNSW wrappers
 555af7d [#24000] DocDB: Shutting down shared exchange could cause TServer to hang
 5743a03 [PLAT-15317]Alert emails are not in the correct format.
 8642555 [PLAT-15379][Fix PLAT-12510] Option to use UTC when dealing with cron exp. in backup schedule
 253ab07 [PLAT-15400][PLAT-15401][PLAT-13051] - Connection pooling ui issues and other ui issues
 57576ae [#16487] YSQL: Fix flakey TestPostgresPid test
 bc8ae45 Update ports for CIS hardened (#24098)
 6fa33e6 [#18152, #18729] Docdb: Fix test TestPgIndexSelectiveUpdate
 cc6d2d1 [docs] added and updated cves (#24046)
 Excluded: ed153dc [#24055] YSQL: fix pg_hint_plan regression with executing prepared statement

Test Plan: Jenkins: rebase: pg15-cherrypicks

Reviewers: jason, jenkins-bot

Differential Revision: https://phorge.dev.yugabyte.com/D38322
karthik-ramanathan-3006 added a commit that referenced this issue Sep 25, 2024
…ehind preview flag

Summary:
**Conflict Resolution for PG15 cherrypick**
- src/postgres/src/include/executor/ybOptimizeModifyTable.h:
    - Location: declaration of function`YbComputeModifiedColumnsAndSkippableEntities`
        - My master commit removes the param `ModifyTable *plan`, and adds the param `ModifyTableState *mtstate`
        - YB-PG 15 (commit df51270) adds the param `ResultRelInfo *`
        - Merge resolution: Remove param `ModifyTable *plan`, add params `ModifyTableState *mtstate`, `ResultRelInfo *`. Lint appropriately.
- src/postgres/src/backend/executor/ybOptimizeModifyTable.c:
    - Location: definition of function function`YbComputeModifiedColumnsAndSkippableEntities`
        - Same conflict, resolution as above.
- src/postgres/src/backend/executor/nodeModifyTable.c:
    - Location: ExecInitModifyTable
        - My master commit adds logic to compute the field `mtstate->yb_is_update_optimization_enabled`
        - This causes an adjacency conflict with YB-PG 15 (55782d5**)**
        - Merge resolution: Keep YB-PG 15 side of changes, add a newline, add logic + comment to compute the field `mtstate->yb_is_update_optimization_enabled` from master commit, remove the rest of the master commit hunk.
    - Location: ExecModifyTable around `else if (relkind == RELKIND_RELATION ...`
        - My master commit changes the params to function `YBCHasWholeRowJunkAttr`.
        - This causes a conflict with YB-PG 15 because this function call no longer exists. Refer resolution notes in df51270
        - Merge resolution: Keep YB-PG 15 side of changes.
    - Location: declaration of YBCHasWholeRowJunkAttr
        - Same context as above.
        - Merge resolution: Keep YB-PG 15 side of changes.
    - Location: ExecUpdate
        - My master commit has changed the params to function`YbComputeModifiedColumnsAndSkippableEntities`. Refer above.
        - In YB-PG 15, this function call has moved to function `YBExecUpdateAct`.
        - Merge resolution:
            - Keep YB-PG 15 side of changes.
            - In `YBExecUpdateAct`, change param `plan` to `context->mtstate` in function call to `YbComputeModifiedColumnsAndSkippableEntities`.

D34040 introduced a framework to skip redundant secondary index updates and foreign key checks.
This revision adds a PG preview flag `ysql_yb_update_optimization_infra` that keeps the feature turned OFF by default.
Additionally, this revision restricts lookup to this flag to the following locations:.
 - Once, during query rewriting to determine to set the wholerow junk attribute
 - Once, at planning time to determine if optimization metadata needs to be computed
 - Once, at the beginning of query execution (`ExecInitModifyTable`) to determine if we should go ahead with the optimization. This has three possibilities:
    - The feature was enabled at planning time and disabled now (during query execution). In this case optimization is not performed.
    - The feature was disabled at planning time and enabled now. In this case, there is no metadata to perform the optimization and so the optimization is skipped.
    - The features was enabled at planning time and enabled now. In this case, metadata is available and the optimization is performed.

To turn on the update optimization feature, do the following:
 - Append `ysql_yb_update_optimization_infra` to the list of flags in `allowed_preview_flags_csv`
 - Set the tserver gflag `ysql_yb_update_optimization_infra` to true.
Jira: DB-7701

Original commit: 8c8adc0 / D37746

Test Plan:
Run the following tests:
```
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressUpdateOptimized#schedule'
```

Reviewers: jason, tfoucher, telgersma

Reviewed By: telgersma

Subscribers: yql, smishra, ybase

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D38388
karthik-ramanathan-3006 added a commit that referenced this issue Sep 27, 2024
…iew flag

Summary:
D34040 introduced a framework to skip redundant secondary index updates and foreign key checks.
This revision adds a PG preview flag `ysql_yb_update_optimization_infra` that keeps the feature turned OFF by default.
Additionally, this revision restricts lookup to this flag to the following locations:.
 - Once, during query rewriting to determine to set the wholerow junk attribute
 - Once, at planning time to determine if optimization metadata needs to be computed
 - Once, at the beginning of query execution (`ExecInitModifyTable`) to determine if we should go ahead with the optimization. This has three possibilities:
    - The feature was enabled at planning time and disabled now (during query execution). In this case optimization is not performed.
    - The feature was disabled at planning time and enabled now. In this case, there is no metadata to perform the optimization and so the optimization is skipped.
    - The features was enabled at planning time and enabled now. In this case, metadata is available and the optimization is performed.

To turn on the update optimization feature, do the following:
 - Append `ysql_yb_update_optimization_infra` to the list of flags in `allowed_preview_flags_csv`
 - Set the tserver gflag `ysql_yb_update_optimization_infra` to true.
Jira: DB-7701

Original commit: 8c8adc0 / D37746

Test Plan:
Run the following tests:
```
./yb_build.sh --java-test 'org.yb.pgsql.TestPgRegressUpdateOptimized#schedule'
```

Reviewers: amartsinchyk

Reviewed By: amartsinchyk

Subscribers: yql, smishra, ybase

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D38289
karthik-ramanathan-3006 added a commit that referenced this issue Oct 1, 2024
Summary:
D34040 introduced an optimization to skip redundant index updates and foreign key checks.
D37746 gated this feature behind a preview flag (feature is OFF by default) named `yb_update_optimization_infra`.

This revision:
 - Promotes the preview flag to an auto flag of the same name. The auto flag is tagged as kLocalVolatile (has no impact on on-disk data).
 - Introduces an additional gflag `ysql_yb_skip_redundant_update_ops` to allow the feature to be enabled/disabled.

The feature will be enabled by default when:
 - (brownfield) The cluster is upgraded to a version that has the above autoflag promoted.
 - (greenfield) The cluster is of a version that has this change.

The feature can be disabled:
 - Clusterwide by setting the gflag `ysql_yb_skip_redundant_update_ops` to false.
 - On a per-session basis by the setting postgres GUC `yb_skip_redundant_update_ops` to false.
Jira: DB-7701

Test Plan: Run Jenkins

Reviewers: smishra, amartsinchyk

Reviewed By: smishra

Subscribers: ybase, yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D37749
timothy-e pushed a commit that referenced this issue Oct 2, 2024
Summary:
 79a00fd [PLAT-15307]fix sensitive info leaks via Gflags
 cd26c93 [DOC-487] Voyager 1.8.2 changes (#24177)
 fa91de7 [docs] Apache Hudi integration with YSQL  (#23888)
 586d337 Updating DynamoDB comparison (#24216)
 aad5695 [#18822] YSQL: Promote autoflag to skip redundant update operations
 fa38152 Fix UBI image: Add -y option to install of hostname
 6baf188 [#23998] Update third-party dependencies and enable SimSIMD in Usearch
 d57db29 Automatic commit by thirdparty_tool: update usearch to commit 191d9bb46fe5e2a44d1505ce7563ed51c7e55868.
 aab1a8b Automatic commit by thirdparty_tool: update simsimd to tag v5.4.3-yb-1.
 161c0c8 [PLAT-15279] Adding unix timestamp to the core dump
 17c45ff [#24217] YSQL: fill definition of a shell type requires catalog version increment
 037fac0 [DB-13062] yugabyted: added banner and get started component
 2eedabd [doc] Read replica connection load balancing support in JDBC Smart driver (#24006)
 62a6a32 [#21467, #24153] Docdb: Add Read sequences as of time - sequences support for clone part 2
 12de78e [PLAT-14954] added support for systemd-timesyncd
 4a07eb8 [#23988] YSQL: Skip a table for schema comparison if its schema does not change
 d3fd39f [doc][ybm] Add reasoning behind no access to yugabyte user #21105 (#23930)
 556ba8a [PLAT-15074] Install node agents on nodes for the marked universes for on-prem providers
 9beb6dc [#22710][#22707] yugabyted: Update voyager migrations list landing page. (#22834)
 6128137 [PLAT-15545] Simplify the frozen universe message for end user in YBA
 4e36b78 JDBC Driver version update to 42.3.5-yb-8 (#24241)
 254c979 [PLAT-15519]: Update xCluster sync to remove tables from YBA DB

Test Plan: Jenkins: rebase: pg15-cherrypicks

Reviewers: tfoucher, fizaa, telgersma

Differential Revision: https://phorge.dev.yugabyte.com/D38624
karthik-ramanathan-3006 added a commit that referenced this issue Oct 3, 2024
…date operations

Summary:
**Note for 2024.2: The optimization to skip redundant index updates and foreign key checks is turned OFF by default is 2024.2.**
This has been accomplished by setting the gflag `ysql_yb_skip_redundant_update_ops` to false.
To enable this optimization, set the gflag to true.

**Original Summary**
D34040 introduced an optimization to skip redundant index updates and foreign key checks.
D37746 gated this feature behind a preview flag (feature is OFF by default) named `yb_update_optimization_infra`.

This revision:
 - Promotes the preview flag to an auto flag of the same name. The auto flag is tagged as kLocalVolatile (has no impact on on-disk data).
 - Introduces an additional gflag `ysql_yb_skip_redundant_update_ops` to allow the feature to be enabled/disabled.

The feature will be enabled by default when:
 - (brownfield) The cluster is upgraded to a version that has the above autoflag promoted.
 - (greenfield) The cluster is of a version that has this change.

The feature can be disabled:
 - Clusterwide by setting the gflag `ysql_yb_skip_redundant_update_ops` to false.
 - On a per-session basis by the setting postgres GUC `yb_skip_redundant_update_ops` to false.
Jira: DB-7701

Original commit: aad5695 / D37749

Test Plan: Run Jenkins

Reviewers: smishra, amartsinchyk

Reviewed By: smishra

Subscribers: yql, ybase

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D38598
karthik-ramanathan-3006 added a commit that referenced this issue Oct 11, 2024
…s in 2024.2 by default

Summary:
Timeline:
  - D34040 introduced an optimization to skip redundant index updates and foreign key checks.
  - D37746 gated this feature behind a preview flag (feature is OFF by default) named `yb_update_optimization_infra`.
  - D37749 introduced a feature enablement flag `ysql_yb_skip_redundant_update_ops`, and promoted the above preview flag to an auto flag.
  - D38598 backported the changes of D37749 to 2024.2, while keeping the feature enablement flag turned OFF (the flag is on in master, by default)

This revision turns on the feature by default in 2024.2 by turning ON the feature enablement flag `ysql_yb_skip_redundant_update_ops`.

Jira: DB-7701

Test Plan: Run Jenkins

Reviewers: smishra, amartsinchyk

Reviewed By: smishra

Subscribers: yql, ybase

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D38936
andrei-mart added a commit that referenced this issue Nov 27, 2024
Summary:
We figured out that INSERT .. ON CONFLICT UPDATE failed to properly
update a secondary index. It looks like the problem is because of index
update optimization, which is enabled by default. To mitigate the
problem we disable the optimization by default.

Revert "[#18822] YSQL: Enable optimization to skip redundant update operations in 2024.2 by default"

This reverts commit 92e026f.
Jira: DB-14205

Test Plan: Jenkins: urgent

Reviewers: kramanathan, smishra

Reviewed By: smishra

Subscribers: ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D40300
andrei-mart added a commit that referenced this issue Nov 27, 2024
…index

Summary:
Original commit: 0529391 / D40300
We figured out that INSERT .. ON CONFLICT UPDATE failed to properly
update a secondary index. It looks like the problem is because of index
update optimization, which is enabled by default. To mitigate the
problem we disable the optimization by default.

Revert "[#18822] YSQL: Enable optimization to skip redundant update operations in 2024.2 by default"

This reverts commit 92e026f.
Jira: DB-14205

Test Plan: Jenkins: urgent

Reviewers: kramanathan, smishra

Reviewed By: smishra

Subscribers: yql, ybase

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D40304
andrei-mart added a commit that referenced this issue Nov 27, 2024
…e index

Summary:
Original commit: 0529391 / D40300
We figured out that INSERT .. ON CONFLICT UPDATE failed to properly
update a secondary index. It looks like the problem is because of index
update optimization, which is enabled by default. To mitigate the
problem we disable the optimization by default.

Revert "[#18822] YSQL: Enable optimization to skip redundant update operations in 2024.2 by default"

This reverts commit 92e026f.
Jira: DB-14205

Test Plan: Jenkins: urgent

Reviewers: kramanathan, smishra

Reviewed By: smishra

Subscribers: yql, ybase

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D40305
vaibhav-yb pushed a commit to vaibhav-yb/yugabyte-db that referenced this issue Dec 10, 2024
Summary:
We figured out that INSERT .. ON CONFLICT UPDATE failed to properly
update a secondary index. It looks like the problem is because of index
update optimization, which is enabled by default. To mitigate the
problem we disable the optimization by default.

Revert "[yugabyte#18822] YSQL: Enable optimization to skip redundant update operations in 2024.2 by default"

This reverts commit 92e026f.
Jira: DB-14205

Test Plan: Jenkins: urgent

Reviewers: kramanathan, smishra

Reviewed By: smishra

Subscribers: ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D40300
ddhodge added a commit that referenced this issue Dec 12, 2024
…#25112)

* changes to add transaction ordering deprecation

* doc update for CDC

* add missing content

* added note

* addressed review comments

* addressed review comments

* changed note type to warning

* made edits and removed 2024.2 changes

* reverted change for 2024.2

* Apply suggestions from code review

Co-authored-by: Dwight Hodge <79169168+ddhodge@users.noreply.github.com>

* [PLAT-16160]Add runtime conf flag for Off-cluster PITR AcceptedPublic

Summary:
Converted the feature flag to runtime flag.

Show New scheduled Policy UI when 'yb.ui.feature_flags.off_cluster_pitr_enabled' is enabled and hide the old one.
Show PITR column in backup list when 'yb.ui.feature_flags.off_cluster_pitr_enabled' is enabled and hide the old one.

Test Plan: Tested manually

Reviewers: lsangappa

Reviewed By: lsangappa

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D40136

* [#24876] CDC: Cleanup metrics for deleted state table entries

Summary:
Currently we do not remove metrics corresponding to the deleted state table entries, for example, on deleting a CDC stream. These metrics hang around until there's a tserver restart. This might cause any external applications to read false values for metric objects which do not exist.

This diff introduces code changes which address the above issue by deleting the metric entity when the corresponding CDC stream is deleted.
Jira: DB-13995

Test Plan:
The following tests have been introduced:

```
./yb_build.sh --cxx-test cdcsdk_ysql-test --gtest_filter CDCSDKYsqlTest.TestCDCMetricRemovalUponStreamDeletion
./yb_build.sh --cxx-test cdcsdk_ysql-test --gtest_filter CDCSDKYsqlTest.TestCDCMetricRemovalUponSlotDeletionForLogicalReplication
./yb_build.sh --cxx-test cdcsdk_ysql-test --gtest_filter CDCSDKYsqlTest.TestMetricObjectRemovalAfterStreamExpiration
```

Reviewers: skumar, sumukh.phalgaonkar, siddharth.shah

Reviewed By: sumukh.phalgaonkar

Subscribers: ycdcxcluster

Differential Revision: https://phorge.dev.yugabyte.com/D40055

* [#25057] YSQL,QueryDiagnostics: Fix testYbQueryDiagnosticsStatus

Summary:
testYbQueryDiagnosticsStatus has been failing due to a bug within pg_mkdir_p function. Current diff handles the bug and formats the test.
Jira: DB-14188

Test Plan: ./yb_build.sh --java-tests 'org.yb.pgsql.TestYbQueryDiagnostics#testYbQueryDiagnosticsStatus'

Reviewers: asaha

Reviewed By: asaha

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D40209

* [#25111] CDC: Fix cleanup tests flakiness

Summary:
The test utility method CDCSDKYsqlTest::CheckTabletsInCDCStateTable() tries to get all the
state table entries with non-max checkpoint and compare their equality with the expected set of
entries. However when this method tries to filter out max checkpoint entries it incorrectly handles
the optional checkpoint field in state table row entry. Because of this the filtering logic does not
work and leads to test flakiness.

This diff fixes the incorrect handling of the optional field.
Jira: DB-14258

Test Plan: Jenkins: test regex: .*CDC.*

Reviewers: skumar, siddharth.shah

Reviewed By: siddharth.shah

Subscribers: ycdcxcluster

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D40311

* Fix swaggerGen on master

Summary: UTs are broken on master due to missing swagger Gen run.

Test Plan: N/A

Reviewers: skurapati

Reviewed By: skurapati

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D40326

* [#24886] YSQL: Fix major catalog upgrade for colocated tables

Summary:
Upgrade of colocated tables was failing because
 1) The OID for the tablegroup for the table wasn't being properly restored.
 2) YB properties including the colocation ID weren't being dumped by ysql_dump.

Fix both issues, and add a test.
Jira: DB-14006

Test Plan:
Jenkins

  ./yb_build.sh release --cxx-test pg15_upgrade-test --gtest_filter Pg15UpgradeTest.ColocatedTables --with_tests

Reviewers: telgersma, fizaa

Reviewed By: telgersma

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D40260

* [#25075] YSQL: ON CONFLICT fails to properly update index

Summary:
We figured out that INSERT .. ON CONFLICT UPDATE failed to properly
update a secondary index. It looks like the problem is because of index
update optimization, which is enabled by default. To mitigate the
problem we disable the optimization by default.

Revert "[#18822] YSQL: Enable optimization to skip redundant update operations in 2024.2 by default"

This reverts commit 92e026f33cd3215d348449d070b1c90f0916d063.
Jira: DB-14205

Test Plan: Jenkins: urgent

Reviewers: kramanathan, smishra

Reviewed By: smishra

Subscribers: ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D40300

* [PLAT-13992] Remove forbidden to override flags (GflagsUtil.java) from gflags UI

Summary: Removing gflags that are forbidden to override from UI (The request will fail anyway if the user attempts to set them)

Test Plan: check if UI shows flags

Reviewers: vbansal

Reviewed By: vbansal

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D40252

* [#25043] YSQL: Fix flakey YbGinIndex upgrade test

Summary:
https://github.com/yugabyte/yugabyte-db/issues/20959 describes what is basically an expected race
condition for DDLs.

The test consistently fails if I increase the number of times we drop / create the indexes:
```lang=diff
--- src/yb/integration-tests/upgrade-tests/pg15_upgrade-test.cc
+++ src/yb/integration-tests/upgrade-tests/pg15_upgrade-test.cc
@@ -1296,12 +1296,14 @@ TEST_F(Pg15UpgradeTest, YbGinIndex) {
     auto conn = ASSERT_RESULT(cluster_->ConnectToDB());
     ASSERT_NO_FATALS(check_and_insert_rows(conn, num_rows));

-    // test dropping and recreating the indexes, to validate that these DDLs
-    // still work as expected in pg15
-    for (const auto &index : kGinIndexes) {
-      ASSERT_OK(conn.ExecuteFormat("DROP INDEX $0", index.first));
+    for (int i = 0; i < 10; i++) {
+      // test dropping and recreating the indexes, to validate that these DDLs
+      // still work as expected in pg15
+      for (const auto &index : kGinIndexes) {
+        ASSERT_OK(conn.ExecuteFormat("DROP INDEX $0", index.first));
+      }
+      ASSERT_NO_FATALS(create_indexes_with_retry());
     }
-    ASSERT_NO_FATALS(create_indexes_with_retry());

     ASSERT_NO_FATALS(check_and_insert_rows(conn, num_rows));
   }
```

Randomly, when creating an index, the test would fail with the error
```
[Not found (yb/master/catalog_manager.cc:11601): LookupByIdRpc(tablet: a70099ab24ae47c79b8b41f879536f01, num_attempts: 1) failed: Tablet deleted: Table deleted at 2024-11-25 09:17:36 EST (split child tablet IDs [])] (pgsql error XX000) (aux msg ERROR:  ERROR:  [Not found (yb/master/catalog_manager.cc:11601): LookupByIdRpc(tablet: a70099ab24ae47c79b8b41f879536f01, num_attempts: 1) failed: Tablet deleted: Table deleted at 2024-11-25 09:17:36 EST (split child tablet IDs [])])
```

Retrying the `CREATE INDEX` statements when they fail avoids this error.
Jira: DB-14177

Test Plan:
On mac and my devserver:
```
./yb_build.sh release --cxx-test pg15_upgrade-test --gtest_filter Pg15UpgradeTest.YbGinIndex -n 60
```

Jenkins: test regex .*YbGinIndex.*

Reviewers: fizaa

Reviewed By: fizaa

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D40255

* [#25000] xCluster: Fix xcluster_upgrade-test

Summary:
When AutoFlags are promoted or demoted, the tservers are notified only on the next heartbeats.
The xCluster tets wait for xCluster to receive and process these AutoFlags configs, but do not wait for the source tservers to even receive them.
This fix addresses this issue by reducing the heartbeat time, and forcing a sleep after every AutoFlags change.

Fixes #25000
Jira: DB-14144

Test Plan: xcluster_upgrade-test

Reviewers: jhe, slingam, xCluster

Reviewed By: jhe

Subscribers: ybase

Differential Revision: https://phorge.dev.yugabyte.com/D40189

* [PLAT-16198] Ansible error parsing in shell process handler does not work

Summary: It was parsing the wrong input to find the ansible task error. Ansible task errors are in stderr. Python error is in stdout.

Test Plan:
Manually tested by failing the ansible tasks. Screenshots attached. Also tested by copying the tmp output files locally.

Before this fix:
{F313328}

With this fix:
{F313329}

Reviewers: amalyshev, cwang, nbhatia, muthu, svarshney

Reviewed By: svarshney

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D40310

* [#24829] CDC: Fix GetChanges WAL segment reading and computation of safe hybrid time for GetChanges resposne

Summary:
During a CDC QA run, we encountered a data loss scenario caused by an interaction between transaction commit timing and WAL segment rollover.

WAL segment 'X' was active when transaction 'T' was still a running transaction. Due to concurrent segment rollover, the transaction's APPLY operation was appended in the subsequent segment 'X+1'. The following sequence of events led to data loss:
1. Initial GetChanges Request:
  - Requested opid index present in segment 'X'
  - No CDC related WAL OPs were found in segment 'X' between [requested op id index, last index in 'X']
  - `committed_op_id_index` (pointed to last index of segment 'X') lagged behind `majority_replicated_op_id_index`, hence we did not scan segment 'X+1'.
  - Finally, we returned empty response with incorrect safe hybrid time (=tablet leader safe time)

2. Subsequent GetChanges Request:
  - Successfully read segment 'X+1' ( as committed_op_id_index had advanced to segment 'X+1')
  - UPDATE_TXN_OP of transaction 'T' was read but CDC filtered it out as we do not ship WAL OPs having commit_time < previously returned safe hybrid time
  - Resulted in transaction 'T' never being shipped.

Root Cause:
We violated a critical invariant: the tablet leader safe time should only be returned in GetChanges responses after reading the entire WAL. But in the 1st Getchanges call, we returned the tablet leader safe time having only read till segment 'X', leading to improper transaction filtering and subsequent data loss.

This diff makes the following changes to fix the above mentioned data loss issue:
1. When reading the WAL segment by segment, we will now wait for the `committed_op_id_index` to be >= last index in the segment. If the deadline is reached while waiting, we will return 0 WAL ops and indicate to wait for WAL update.

2. Identification of active segment in GetConsistentWALRecords has been changed. Earlier, we were inferring active segment by the value of `consistent_stream_safe_time_footer`. If it was kInvalid, then we concluded its an active segment. But because of changes in 1), that conclusion no longer holds true. If we reach the deadline while waiting for `committed_op_id_index` to be >= last index in segment, then the value of `consistent_stream_safe_time_footer` will still be invalid. Hence, we are now using a dedicated variable (`read_entire_wal`) that will notify if we actually read the active segment in `ReadReplicatedMessagesInSegmentForCDC()`.

3. Value of `safe_hybrid_time` returned in GetChanges response. We have the following scenarios which will decide the safe_hybrid_time sent in the response:
    - **Case-1**: Read the active segment -> return the last record's commit_time if valid records are found. Else, return tablet leader safe time (existing logic).
    - **Case-2**: Deadline reached while waiting for `committed_op_id_index` to be >= last index in the WAL segment. There are 2 ways in which we can reach deadline. For both these ways, we want to wait for WAL to be updated.
         - Deadline reached after reading multiple segments -> return request safe hybrid time.
         - Deadline reached on the 1st segment read in GetChanges call -> return request safe hybrid time.
    - **Case-3:** requested index (from_op_id_index) >= `committed_op_id_index`
        - If all RAFT replicated Ops are not yet APPLIED (i.e. `committed_op_id_index` != `majority_replicated_op_id_index`), then we indicate to wait for WAL update and return request safe hybrid time.
        - If all RAFT replicated OPs are also APPLIED (i.e. `committed_op_id_index` == `majority_replicated_op_id_index`), then we have following scenarios:
	         - If the condition in case-3 was hit after reading multiple segments, then return footer value (`min_start_time_running_txns`) of last read segment.
	         - If the condition in case-3 was hit on the 1st segment read in GetChanges call, then return tablet leader safe time as this particular case implies we have read the entire WAL.

Additionally, we have added a WARNING log when the invariant for response safe time is broken.
Jira: DB-13935

Test Plan: Jenkins

Reviewers: skumar, sumukh.phalgaonkar

Reviewed By: skumar

Subscribers: ybase, ycdcxcluster

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D39925

* [PLAT-16194] Adding preflight check for python3.10/3.11

Summary: With recent changes to upgrade Ansible D32451 we now require python 3.10 or 3.11 on the node to run YBA. This diff updates the python check to only accept 3.10 or 3.11. We also can move the openSSL check to its own check as we don't need to conditionally perform it based on the python version, it is part of the base requirements (as it was only relevant for python 3.10+ anyways).

Test Plan: run check on node without python3.10 or 3.11, install python3.11 and ensure check passes

Reviewers: dshubin, sanketh

Reviewed By: dshubin

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D40298

* [#25107] xCluster: RemoveNamespaceWhenSourceIsDown: Skip health checks when source is down

Summary:
When source is down the health check will fail, so disable it during validation.

Fix DropAllTables to wait for safe time to be healthy before checking row counts.

Fixes #25107
Jira: DB-14253

Test Plan:
XClusterDBScopedTest.RemoveNamespaceWhenSourceIsDown
XClusterDBScopedTest.DropAllTables

Reviewers: jhe, xCluster

Reviewed By: jhe

Subscribers: ybase

Differential Revision: https://phorge.dev.yugabyte.com/D40306

* [#25103] DocDB: Handle multiple splits, PITR restores and drop table correctly

Summary:
This change fixes one scenario that https://github.com/yugabyte/yugabyte-db/commit/79a69958177d did not handle completely resulting in a FATAL after multiple splits and PITR restores in the following sequence:

  # t0 - Only tablet T11 exists.
  # t1 - T11 splits into T12, T13.
  # t2 - PITR restore is performed to t0 which brings back T11 and hides T12, T13 with hide time - t2.
  # t3 - T11 again splits into T14, T15 at the same partition key boundaries as T12,T13. T11 is marked as hidden with hide time - t3
  # t4 - Table gets dropped hiding - T14, T15 with hide time - t4.
  # t5 - PITR is performed to t4+ which reloads the syscatalog.
  # At this point the following tablets exist in hidden state with different hide times: T11(t3), [T12(t2),T13(t2)], [T14(t4),T15(t4)]. Attempts to load [T12(t2),T13(t2)] and [T14(t4),T15(t4)] which have the same key ranges and split depth results in the following fatal:

```
Failed to load sys catalog: Illegal state (yb/master/catalog_entity_info.cc:654): Failed while visiting tablets in sys catalog: System catalog snapshot is corrupted or built using different build type: TabletInfo object freed during load: Two tablets with the same partition key start and split depth: committed_consensus_state
```

Added a unit-test for this and it fails without the fix.

**Fix: **

The fix is to avoid adding any tablets that were marked hidden even before the table is dropped to the partitions_ structure. This ensures that on a drop table, only the set of tablets that were active are added to the partitions_ structure.
Jira: DB-14249

Test Plan: ybt yb-admin-snapshot-schedule-test YbAdminSnapshotScheduleTest.ReadsWithMultipleSplitsPitrsAndDrop

Reviewers: zdrudi, asrivastava

Reviewed By: zdrudi

Subscribers: tfoucher, ybase

Differential Revision: https://phorge.dev.yugabyte.com/D40314

* [#25072] DocDB: Fix false corruption detection during colocated index read

Summary:
When index is colocated to the indexed table we perform index read using single query.
At the first step the index table is read, to fetch row keys from the indexed table.
On the second step indexed table is read using those keys.
If row key does not exist on the second step, the corruption is being reported.

It could happen that transaction apply happens in parallel to read and this row was just removed by recently committed transaction.
So read finds this row on the first step, but does not see it on the second step raising the corruption error.
Actually read restart mechanism detects that read is not consistent and should be restarted.
But this particular corruption detection logic ignores read restart.

The failure message looks like this one:
```
ERROR: ybctid DocKey([], [16754]) not found in indexed table. index table id is 00004007000030008000000000000a76
```

Fixed by checking read restart before reporting such corruption.

Updated param naming in PgDdlAtomicityStressTest to be more used friendly.
Also fixed the following issues found by this test:
1) Potential crash because of head use after free if AbortTransaction response is received during tablet shutdown.
2) TServer could wait until OpenTable timeout (2min) during shutdown.
3) TServer could wait tablet validation timeout (2min) during shutdown.
Jira: DB-14202

Test Plan: ./yb_build.sh fastdebug --gcc11 --gtest_filter PgDdlAtomicityStressTest.Main/colocated -n 20

Reviewers: myang, dmitry

Reviewed By: myang

Subscribers: dmitry, yql, ybase

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D40235

* [PLAT-16203]Skip running prechecks if Node2Node certs have expired

Summary: We should skip running prechecks if certificates have expired. This will otherwise block rotate certs tasks on a univers e

Test Plan:
Tested locally by rotating certificates on a universe with expired certs

Reviewers: svarshney, nsingh, nbhatia

Reviewed By: svarshney, nbhatia

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D40331

* [PLAT-16202] Use the tmp_directory configured in ynp config file

Summary: Use the tmp_directory configured in ynp config file

Test Plan: Manually tested script files are generated at the specified directory

Reviewers: nbhatia, skhilar

Reviewed By: nbhatia

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D40324

* [#23331] yugabyted: Add pg_isready check to start and status command.

Summary:
* Added the check pg_isready for each node during start and status command.
* Added the field `YSQL Status` in the status string displayed during start and status command.
* During the restart of a cluster if a node is in Bootstrapping step, yugabyted status will return the same status for `YSQL Status`
* Added a new `Output.ANIMATION_STOP` status for Output.update_animation() function.
* Giving `Output.ANIMATION_STOP` and empty msg string to Output.update_animation() will remove the spinner that was started with Output.init_animation().
Jira: DB-12256

Test Plan: Manual Testing

Reviewers: nikhil

Reviewed By: nikhil

Subscribers: sgarg-yb

Differential Revision: https://phorge.dev.yugabyte.com/D34597

* [PLAT-13112]Block deletion of in use-releases

Summary:
Adding finalizers in ReleaseReconciller.onAdd() to block deletion of in-use releases.
Removing finalizers in ReleaseReconciller.onDelete() and after ybuniverse gets deleted.

Test Plan:
Tested following scenarios -

  - Created a release -> check finalizers present in cr -> Delete release
  - Created a release -> Create universe -> delete release (blocked) -> Delete universe -> Release gets GC'ed
  - Created a release -> Create universe -> Delete universe -> Release stays active

Reviewers: anijhawan, vkumar

Reviewed By: vkumar

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D37451

* [#24293] YSQL, QueryDiagnostics: Fix PgssReset test

Summary:
D39523 revision enabled ASH by default, which started raising extra warning messages for `testPgssResetBetweenDiagnostics` test, thereby failing assertions.
Current diff disables ASH for certain tests.
Jira: DB-13182

Test Plan: ./yb_build.sh --java-test 'org.yb.pgsql.TestYbQueryDiagnostics#testPgssResetBetweenDiagnostics'

Reviewers: asaha

Reviewed By: asaha

Differential Revision: https://phorge.dev.yugabyte.com/D40126

* [#25004] YSQL: Fix the backend type of the physical connection in ysql conn mgr

Summary:
Post pg15 merge into the master, the type/name of backends created for physical connections in transaction pool are coming to be client backend instead of yb-conn-mgr worker connection. This diff fixes this issue.

Fix
Based on value of the guc variable `yb_is_client_ysqlconnmgr`, the type of backend is set to yb-conn-mgr worker connection or client backend. While parsing the startup packet of the transactional backend process, the guc variables coming in the startup packet are not yet processed (they are processed in later stage of initialization of the backend). Therefore, in this diff during parsing of the startup packet itself, `yb_is_client_ysqlconnmgr` guc variable is been set and based on it's correct value the type of backend is assigned.

This diff also fixes one of implementation gap while making the connections sticky when client executes SET stmt to set "session_authorization" and "role" guc variables.
Jira: DB-14148

Test Plan: Jenkins: enable connection manager, all tests

Reviewers: skumar, rbarigidad, vpatibandla, stiwary

Reviewed By: stiwary

Subscribers: svc_phabricator, yql

Differential Revision: https://phorge.dev.yugabyte.com/D40323

* [#25094] yugabyted: Fix yugabyted UI slow queries page due to pg15 pg_stat_statements changes

Summary:
The query used to get slow queries in the yugabyted UI API server queries `pg_stat_statements`. Some of the column names were changed from `total_time, min_time, max_time, mean_time, stddev_time` to `total_exec_time, min_exec_time, max_exec_time, mean_exec_time, stddev_exec_time` in pg15 and need to be changed in the query as well.
Jira: DB-14240

Test Plan: manual tests

Reviewers: sgarg-yb, nikhil

Reviewed By: sgarg-yb

Subscribers: yugabyted-dev, djiang

Differential Revision: https://phorge.dev.yugabyte.com/D40303

* [#25118] DocDB: Fix org.yb.pgsql.TestPgRegressThirdPartyExtensionsPgvector#schedule

Summary:
Commit bbf8c1288a87a15be2913fb1a665c0740b9de85c/D40131 contains debug leftover with CHECK, that is causing ybdummyann tests to fail.

Fixed by removed this check and adjusting logic in PgsqlReadOperation::ExecuteVectorSearch.
Jira: DB-14263

Test Plan: org.yb.pgsql.TestPgRegressThirdPartyExtensionsPgvector#schedule

Reviewers: slingam, arybochkin

Reviewed By: slingam, arybochkin

Subscribers: svc_phabricator, ybase, yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D40336

* [#24647] YSQL: In major catalog upgrade, avoid reading current version catalog before it's valid

Summary:
During normal operation of a YB universe, the YB master itself sometimes references PG catalog tables. For example, both during CreateTable and as a periodic refresh, it references pg_tablespace, and as a periodic task it reads from pg_database. In the existing code, during a ysql major catalog upgrade, the master will generate table UUIDs for the current ysql major catalog version for these tables, even though they may not exist or be fully populated yet.

Modify the YB master code to read from prior ysql major catalog version tables until the current ysql major catalog version tables are valid. Note that as a side effect, this allows us to consolidate and simplify the logic to read from the correct table to retrieve the current per-db catalog versions (not to be confused with "ysql major catalog version," our terminology for PG11 or PG15) during the upgrade.

After this commit, you may need to reinitdb, if you haven't done so in a while, to pick up a catalog snapshot that correctly holds the current version in ysql_major_catalog_upgrade_info.catalog_version.
Jira: DB-13711

Test Plan:
Jenkins

On MacOS 14 arm64:
  ./yb_build.sh release --cxx-test integration-tests_basic_upgrade-test --gtest_filter UpgradeFrom_2_25_0_0/BasicUpgradeTest.TestUpgrade/0 --with_tests
  ./yb_build.sh fastdebug --cxx-test integration-tests_basic_upgrade-test --gtest_filter UpgradeFrom_2_25_0_0/BasicUpgradeTest.TestUpgrade/0 --with_tests
(to test builds.xml builds for Mac debug, primarily, because that build flavor isn't exercised by the automated tests right now)

Reviewers: hsunder

Reviewed By: hsunder

Subscribers: hsunder, smishra, ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D39813

* [#25129] DocDB: Increase PgPartmanTest test timeout in ASAN mode

Summary:
PgPartmanTest performs hundreds of table modification tasks, it takes significant amount of time especially in ASAN mode.
So those tests does not fit into default timeout:

PgPartmanTest.TestIdTimeSubpartNative
PgPartmanTest.TestIdTimeSubpartCustomStartNative

Increased timeout to 1200 seconds in ASAN mode
Jira: DB-14279

Test Plan:
./yb_build.sh asan --gtest_filter PgPartmanTest.TestIdTimeSubpartNative
./yb_build.sh asan --gtest_filter PgPartmanTest.TestIdTimeSubpartCustomStartNative

Reviewers: devansh.saxena, skumar

Reviewed By: devansh.saxena

Subscribers: yql, ybase

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D40356

* [#23901] YSQL, ASH: Sample background workers

Summary:
This diff adds support for sampling YSQL background workers.

Summary of changes -
- Add a new const query id for YSQL background workers
- While deciding whether to consider a backend for sampling or not, we now only check for `MyProc->yb_is_ash_metadata_set`
- The CPU wait event name in YSQL is changed from `QueryProcessing` to `OnCpu_Active` because now we also have background workers which may not be executing queries
- We no longer take locks while setting root_request_id, client_node_ip, pid, more details in code comments
- We don't sample the ASH collector itself because it will always show CPU events
- kQueryIdForCatalogRequests is renamed to kQueryIdForUncomputedQueryId as this is more accurate name
- Two sync RPCs CronGetLastMinute and CronSetLastMinute called from the pg_cron background worker are now also instrumented

**Upgrade/Rollback safety:** Safe to upgrade/rollback, if ASH metadata
is not found in the PB, then metadata in the threadlocal wait state object
is not updated.

If ASH metadata is sent, and the other tserver is still on old version, it will
simply ignore and continue doing it's work
Jira: DB-12805

Test Plan:
./yb_build.sh --cxx-test pg_ash-test --gtest_filter PgBgWorkersTest.ValidateBgWorkers
./yb_build.sh --cxx-test pg_ash-test --gtest_filter PgWaitEventAuxTest.PgCronRPCs

Reviewers: hsunder

Reviewed By: hsunder

Subscribers: smishra, yql, ybase

Differential Revision: https://phorge.dev.yugabyte.com/D39062

* [DOCS] python Smart Driver (psycopg2) docs update for RR support (#25074)

* [#25119] Revert `yb_amiscoveredbymaintable` related changes

Summary:
This reverts changes related to `yb_amiscoveredbymaintable` in b4ef0c523359e3572c2bc3f619780cacf6edbbde and .b9b57c6f791cb9f28d8bec9372e9a433a903980c in line with the most up to date requirements for index co-partitioning. In the previous design, co-partitioned indexes were meant to share almost all metadata and storage with the main table.

The currently implemented design for co-partitioning in docdb creates such indexes a different way. Co-partitioned indexes on creation create new data storage but get colocated with their respective main tables in a mechanism similar to the existing colocation index creation.

This change reverts any remnants of the previous design on the query layer to allow for this redesign.

b9b57c6f791cb9f28d8bec9372e9a433a903980c had a few conflicts with this change that modified some call-sites of `YBIsCoveredByMainTable`.

Test Plan: Jenkins

Reviewers: telgersma, jason, fizaa

Reviewed By: telgersma

Subscribers: yql, ybase

Differential Revision: https://phorge.dev.yugabyte.com/D40340

* Revert "[PLAT-13112]Block deletion of in use-releases"

Summary:
This reverts commit af1bdd97294f8bda926ae38c1a08186b0d419d24/D37451 since it broke UTs.
Will be fixed by @anabaria once he is back from PTO.

Test Plan: N/A

Reviewers: anabaria

Reviewed By: anabaria

Subscribers: anabaria, yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D40373

* [DOC-566] TA-23476 Update Tech advisory (#25091)

* update existing  ta-23476

* add shortcode for versions

* Apply suggestions from review

Co-authored-by: Aishwarya Chakravarthy  <achakravarthy@yugabyte.com>

* use bullet points

* update TA 23476 on TA landing page.

* add timestamp example
---------

Co-authored-by: Aishwarya Chakravarthy <achakravarthy@yugabyte.com>

* [#22518] xCluster: Fix XClusterSafeTimeTest.ConsumerHistoryCutoff

Summary:
Fixed a couple of bug in VerifyHistoryCutoffTime to make test pass.
Jira: DB-11444

Test Plan: ./yb_build.sh fastdebug --gcc11 --cxx-test xcluster_safe_time-itest --gtest_filter XClusterSafeTimeTest.ConsumerHistoryCutoff -n 400 -- -p 8

Reviewers: hsunder, xCluster

Reviewed By: hsunder

Subscribers: ybase

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D40375

* [#25130] DocDB: Preventing altering table that is being prepared

Summary:
Alter table request could arrive while table is being prepared.
It could ruin table states transition logic.

Fixed by rejecting alter table while table is being prepared.

Also removed explicit vmodule setup in tests.
If it is necessary to execute test with vmodule settings we could always use `--test-args --vmodule=...` way.
Which is blocked by explicit value for vmodule flag.
Jira: DB-14280

Test Plan: ./yb_build.sh fastdebug --gcc11 --gtest_filter CDCSDKYsqlTest.TestAddManyColocatedTablesOnNamesapceWithStream -n 40

Reviewers: zdrudi, xCluster, hsunder

Reviewed By: zdrudi

Subscribers: ybase, yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D40367

* [#17898] DocDB: Fixed bug with retaining DelayedTask during shutdown

Summary:
DelayedTask::Run checks whether Reactor started shutdown and just exit.
Because of this this task does not invoke callback and hangs forever in messenger.
Actually we don't need this check, since there are a more robust checks in our code to detect whether task should be aborted.
So removed this check.
Jira: DB-6980

Test Plan: ./yb_build.sh fastdebug --gcc11 --gtest_filter MasterTest.TestRegisterDistBroadcastDupPrivateUsePrivateIpNeverCheckUsed -n 400

Reviewers: hsunder

Reviewed By: hsunder

Subscribers: ybase

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D40364

* [DOC-554][CLOUDGA-24513][ybm] VictoriaMetrics GA (#25056)

* YBM VictoriaMetrics GA

* edit

* review comments

* [doc][ybm] Change log for Victoriametrics ga (#25134)

* change log for victoriametrics ga

* format

* [#24324][conn-mgr] Add logical client version matching to select backends

Summary:
This diff adds the logic of selecting transactional backends based on matching the logical client version of the server to that of the logical client.

**This feature is guarded by preview flag** `ysql_conn_mgr_version_matching`. There is one more preview flag is added named `ysql_conn_mgr_version_matching_connect_higher_version` . Use case of this flag is discussed later in algorithm.

Algorithm description in chronological order.

1.) When a backend spawns, it reads the current_version from pg_yb_logical_client_version table added as part of D38335 and sends it to frontend as parameter status packet.

2.) At frontend, `od_backend_startup` in backend.c, this parameter status packet is parsed and stored in server->logical_client_version.

3.) When a new logical client comes up, it is authenticated by auth backend. After successful authentication, it stores it's logical_client_version from auth backend's logical client version.

4.) After authentication , during routing of the client for getting transactional backend, we first check the `logical_client_version` of the client to that of route's `max_logical_client_version`.
 - If former is greater than later, then we
   - update the route's `max_logical_client_version`
   - mark all sever's in active and idle pool's `marked_for_close`  as true.

- If the logical_client_version of client is less than route's max_logical_client_version then we return `OD_ROUTER_ERROR` leading to disconnect of the server.
- After that we select a backend from idle pool having these two things:

5.) Now there would be two cases for the server selection algorithm. Either we get a server or we get NULL.
   -  If we get a server , we simply attach
   -  If not, we spawn a new server and check the logical_client_version of that sever to the client's logical client version. There could be a case where attached server's version is greater than client's logical client version.
 In this case there if `ysql_conn_mgr_version_matching_connect_higher_version` is:

        - Set to false: return `OD_ESERVER_CONNECT`
        - Set to true: return `OD_OK`;

Test Plan:
Jenkins: enable connection manager, all tests

  ./yb_build.sh release --java-test org.yb.ysqlconnmgr.TestLogicalClientVersion

Reviewers: skumar, stiwary, mkumar, rbarigidad

Reviewed By: rbarigidad

Subscribers: svc_phabricator, yql

Differential Revision: https://phorge.dev.yugabyte.com/D38749

* [#25030] YCQL: Replace autoflag ycql_suppress_group_by_error with a regular gFlag

Summary:
In commit 80def06f8c19ad7cbc52f41b4be48d158157a418, an autoflag `ycql_suppress_group_by_error` was introduced to suppress the error raised when using the `GROUP BY` clause.

 1. This should not have been an autoflag because we want users to decide this behavior.
  - A new regular gFlag, `ycql_ignore_group_by_error`, has been introduced for future use since autoflags cannot be demoted or removed.
  - When set to true(default), no error is raised, and the `GROUP BY` clause is ignored. When set to false, the error is raised as usual.
 2. The autoflag definition was previously in pt_select.cc. Its definition has now been moved to server_common_flags.cc because, due to differences in the linking scheme for various build types, this flag was not available in master flags for certain build types.
  - The flag does not determine/change any behaviour.
Jira: DB-14168

Test Plan:
./yb_build.sh --java-test org.yb.cql.TestCreateTable#testCreateTableWithColumnNamedGroup
./yb_build.sh --java-test org.yb.cql.TestSelect#testGroupBy

Reviewers: stiwary, hsunder, skumar

Reviewed By: stiwary, hsunder

Subscribers: yql, ybase

Differential Revision: https://phorge.dev.yugabyte.com/D40327

* [#25136] YSQL: Decrease number of iteration in PgLibPqTest.MasterRestartReadPastGlobalLimit TSAN mode

Summary:
The test performs 10k iterations, in TSAN mode it takes 0.1s to perform single iteration in TSAN mode.
So test just times out because 15 minutes is required to complete such number of iterations.

Decreased number of iterations to 1k for sanitizers.
Jira: DB-14286

Test Plan: ./yb_build.sh tsan --gtest_filter PgLibPqTest.MasterRestartReadPastGlobalLimit -n 40

Reviewers: jason, patnaik.balivada

Reviewed By: patnaik.balivada

Subscribers: ybase, yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D40381

* [#23331] yugabyted: Fixing yugabyted tests broken with pg_isready diff D34597.

Summary:
On Jenkins pipelines `pg_isready` binary is not available in the paths configured in yugabyted. Adding required changes to find the `pg_isready` on Jenkins VMs.
Jira: DB-12256

Test Plan: ./yb_build.sh --java-test 'org.yb.yugabyted.TestYugabytedSingleNode'

Reviewers: sgarg-yb

Reviewed By: sgarg-yb

Subscribers: yugabyted-dev

Differential Revision: https://phorge.dev.yugabyte.com/D40379

* [DB-13952]yugabyted: Fixing the count of automatic, manual refactoring.

Summary:
Schema analysis API data usage -

  - data for `AUTOMATIC DDL IMPORT`  `MANUAL REFACTORING` `TOTAL ANALYZED` is being read from `current_analysis_report.recommended_refactoring.refactor_details.manual/automatic`

  - For the summary table, values are being read from  `current_analysis_report.recommended_refactoring.refactor_details` list.

  - For both UI sections, using `refactor_details.automatic` value requires an API change. Automatic value is being calculated by subtracting the count of conversion issues instead of subtracting the count of `sql_objects.invalidCount`.
Jira: DB-13952

Test Plan: Manual Test

Reviewers: sgarg-yb

Reviewed By: sgarg-yb

Differential Revision: https://phorge.dev.yugabyte.com/D40328

* [#24697] Docdb: Table locks - support releasing locks for a session/host

Summary:
 Api to allow releasing locks for a session/host when either
 a) The session ends, or
 b) The tserver loses its lease/restarts.

 The TServer should detect when a session ends, and may call
 the API to release all locks held by a particular session.

 Once YSQL lease is implemented, the master may realize that
 a TServer has lost it's lease, or
 may discover that the TServer has had a restart when a TServer
 shows up with a new instance_seqno. A new incarnation-id may
 be generated, and then a background task clears out the locks
 held by previous incarnations.

 Other changes:
 - Try to make Unlock/Lock apis take a callback instead
Jira: DB-13773

Test Plan: yb_build.sh --cxx-test object_lock-test

Reviewers: zdrudi, bkolagani

Reviewed By: zdrudi

Subscribers: ybase

Differential Revision: https://phorge.dev.yugabyte.com/D39749

* [PLAT-15959]: Update PDB policy in case of pods change in K8s universe

Summary:
This diff is in continuation of PDB support: D39864
Added changes to update PDB policy in case of edit universe or edit read-replica cluster.

Test Plan: Tested manually by performing actions like pod change and create/delete read-replica.

Reviewers: sneelakantan, anijhawan, vkumar

Reviewed By: vkumar

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D40315

* [DB-13952]yugabyted: Fixing the ui changes after the addition of invalid obj count.

Summary:
Addition of invalid object count column on assessment and analysis voyager page.
Jira: DB-13952

Test Plan: Manual testing

Reviewers: nikhil

Reviewed By: nikhil

Subscribers: yugabyted-dev, krishna.tripathi

Differential Revision: https://phorge.dev.yugabyte.com/D40387

* [docs] Release notes for 2.20.8.0-b53 (#25079)

* rn for 2.20.8.0

* changed date

* [#25089] build: Allow building with artifacts from thirdparty PR

Summary:
This diff makes the following changes to improve workflow of making thirdparty changes:
- Allow specifying GitHub artifact IDs for thirdparty builds and their checksums in thirdparty_archives.yml instead of tags, e.g.
```
  - os_type: ubuntu22.04
    architecture: x86_64
    compiler_type: gcc11
    release_artifact_id: 1234567890
    checksum_artifact_id: 1234567891
```

Artifact downloads are structured as a zip file containing archive.tar.gz/archive.tar.gz.sha256. We cache only the
extracted archive.tar.gz/archive.tar.gz.sha256, renamed as
github-artifact-RELEASE_ARTIFACT_ID.tar.gz/github-artifact-RELEASE_ARTIFACT_ID.tar.gz.sha256.

The build is extracted to /opt/yb-build/thirdparty/RELEASE_ARTIFACT_ID, and a symlink is created at
/opt/yb-build/thirdparty/yugabyte-db-thirdparty-v.... pointing to /opt/yb-build/thirdparty/RELEASE_ARTIFACT_ID
(this is needed because thirdparty binaries used in the build have this path hardcoded in rpath).

- Make thirdparty_tool be able to pull thirdparty builds from a thirdparty PR instead of scanning release tags, e.g.
```
./build-support/thirdparty_tool -u --thirdparty-pr 12345678
```
will generate thirdparty_archives.yml using artifacts from the latest version of PR #12345678 on the thirdparty repo.

Accessing artifacts requires a GitHub token to be set (either via the GITHUB_TOKEN environmental variable, or
in a file specified in the YB_GITHUB_TOKEN_FILE_PATH environmental variable); one of the two must be set when
building with artifacts from a thirdparty PR.

Some old linuxbrew handling code was also removed.
Jira: DB-14217

Test Plan:
Jenkins: compile only

Tested thirdparty_tool with and without the new `--thirdparty-pr` option, and tested local builds in both setups.

Reviewers: steve.varnau

Reviewed By: steve.varnau

Subscribers: ybase

Differential Revision: https://phorge.dev.yugabyte.com/D40118

* [#25053] YSQL: Fix TestPgDdlConcurrency for TSAN build

Summary:
Similar fix already made for ASAN build. The test still used 50 thread for TSAN
build. It was reported that 50 threads in TSAN build caused other CPU intensive
tests on the same test VM to fail. Reduced to 10 threads for TSAN build as well.

The test runs more flaky under TSAN build with this change, I will look into how
to get rid of the flakiness separately.
Jira: DB-14184

Test Plan: ./yb_build.sh tsan --java-test 'org.yb.pgsql.TestPgDdlConcurrency#testModifiedTableWrite' -n 20 --tp 1

Reviewers: kfranz, mihnea

Reviewed By: kfranz

Subscribers: yql

Differential Revision: https://phorge.dev.yugabyte.com/D40398

* [#24707] YSQL: pg_cron: Kill inflight jobs when leader changes

Summary:
Kill jobs if we are no longer leader.
If there is a long running job when the cron leader moved due to load balance or upgrade activities,
this will ensure that there is only one occurrence of the job running at any given time.

Fixes #24707
Jira: DB-13784

Test Plan: PgCronTest.CancelJobOnLeaderChange

Reviewers: tnayak, fizaa

Reviewed By: tnayak

Subscribers: ybase, yql

Differential Revision: https://phorge.dev.yugabyte.com/D40335

* [#25145] DocDB: Fix MasterTabletServer::GetServingTablet

Summary:
Missing null check. `CatalogManager` is yb-masters `tserver::TabletPeerLookupIf`, so moving the inheritance to `CatalogManagerIf` and using it in `MasterTabletServer`.
The `CatalogManager` performs all the required checks correctly.

Fixes #25145
Jira: DB-14305

Test Plan: Jenkins

Reviewers: bkolagani

Reviewed By: bkolagani

Subscribers: ybase

Differential Revision: https://phorge.dev.yugabyte.com/D40405

* [PLAT-16129][YBA CLI] RBAC APIs - 1

Summary:
Add commands corresponding to RBAC APIs.

RBAC Command
```
yba rbac
Manage YugabyteDB Anywhere RBAC (Role-Based Access Control)

Usage:
  yba rbac [flags]
  yba rbac [command]

Available Commands:
  permission  Manage YugabyteDB Anywhere RBAC permissions
  role        Manage YugabyteDB Anywhere RBAC roles

Flags:
  -h, --help   help for rbac

Global Flags:
  -a, --apiToken string    YugabyteDB Anywhere api token.
      --config string      Config file, defaults to $HOME/.yba-cli.yaml
      --debug              Use debug mode, same as --logLevel debug.
      --disable-color      Disable colors in output. (default false)
  -H, --host string        YugabyteDB Anywhere Host (default "http://localhost:9000")
  -l, --logLevel string    Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
  -o, --output string      Select the desired output format. Allowed values: table, json, pretty. (default "table")
      --timeout duration   Wait command timeout, example: 5m, 1h. (default 168h0m0s)
      --wait               Wait until the task is completed, otherwise it will exit immediately. (default true)
```

Permission command

```
yba rbac permission
Manage YugabyteDB Anywhere RBAC permissions

Usage:
  yba rbac permission [flags]
  yba rbac permission [command]

Available Commands:
  describe    Describe a YugabyteDB Anywhere RBAC permission
  list        List YugabyteDB Anywhere permissions

Flags:
  -h, --help   help for permission

Global Flags:
  -a, --apiToken string    YugabyteDB Anywhere api token.
      --config string      Config file, defaults to $HOME/.yba-cli.yaml
      --debug              Use debug mode, same as --logLevel debug.
      --disable-color      Disable colors in output. (default false)
  -H, --host string        YugabyteDB Anywhere Host (default "http://localhost:9000")
  -l, --logLevel string    Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
  -o, --output string      Select the desired output format. Allowed values: table, json, pretty. (default "table")
      --timeout duration   Wait command timeout, example: 5m, 1h. (default 168h0m0s)
      --wait               Wait until the task is completed, otherwise it will exit immediately. (default true)

Use "yba rbac permission [command] --help" for more information about a command.
```

List Permission
```
 yba rbac permission list
List YugabyteDB Anywhere permissions

Usage:
  yba rbac permission list [flags]

Aliases:
  list, ls

Examples:
yba rbac permission list

Flags:
  -n, --name string            [Optional] Name of the permission. Quote name if it contains space.
      --resource-type string   [Optional] Resource type of the permission. Allowed values: universe, role, user, other. If not specified, all resource types are returned.
  -h, --help                   help for list

Global Flags:
  -a, --apiToken string    YugabyteDB Anywhere api token.
      --config string      Config file, defaults to $HOME/.yba-cli.yaml
      --debug              Use debug mode, same as --logLevel debug.
      --disable-color      Disable colors in output. (default false)
  -H, --host string        YugabyteDB Anywhere Host (default "http://localhost:9000")
  -l, --logLevel string    Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
  -o, --output string      Select the desired output format. Allowed values: table, json, pretty. (default "table")
      --timeout duration   Wait command timeout, example: 5m, 1h. (default 168h0m0s)
      --wait               Wait until the task is completed, otherwise it will exit immediately. (default true)
```

Describe Persmiison
```
yba rbac permission describe -h
Describe a RBAC permission in YugabyteDB Anywhere

Usage:
  yba rbac permission describe [flags]

Aliases:
  describe, get

Examples:
yba rbac permission describe --name <permission-name>

Flags:
  -n, --name string   [Required] Name of the permission. Quote name if it contains space.
  -h, --help          help for describe

Global Flags:
  -a, --apiToken string    YugabyteDB Anywhere api token.
      --config string      Config file, defaults to $HOME/.yba-cli.yaml
      --debug              Use debug mode, same as --logLevel debug.
      --disable-color      Disable colors in output. (default false)
  -H, --host string        YugabyteDB Anywhere Host (default "http://localhost:9000")
  -l, --logLevel string    Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
  -o, --output string      Select the desired output format. Allowed values: table, json, pretty. (default "table")
      --timeout duration   Wait command timeout, example: 5m, 1h. (default 168h0m0s)
      --wait               Wait until the task is completed, otherwise it will exit immediately. (default true)
```

Role command
```
yba rbac role
Manage YugabyteDB Anywhere RBAC roles

Usage:
  yba rbac role [flags]
  yba rbac role [command]

Available Commands:
  create      Create YugabyteDB Anywhere RBAC roles
  delete      Delete a YugabyteDB Anywhere role
  describe    Describe a YugabyteDB Anywhere RBAC role
  list        List YugabyteDB Anywhere roles
  update      Update a YugabyteDB Anywhere role

Flags:
  -h, --help   help for role

Global Flags:
  -a, --apiToken string    YugabyteDB Anywhere api token.
      --config string      Config file, defaults to $HOME/.yba-cli.yaml
      --debug              Use debug mode, same as --logLevel debug.
      --disable-color      Disable colors in output. (default false)
  -H, --host string        YugabyteDB Anywhere Host (default "http://localhost:9000")
  -l, --logLevel string    Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
  -o, --output string      Select the desired output format. Allowed values: table, json, pretty. (default "table")
      --timeout duration   Wait command timeout, example: 5m, 1h. (default 168h0m0s)
      --wait               Wait until the task is completed, otherwise it will exit immediately. (default true)

```

List Role command
```
yba rbac role list
List YugabyteDB Anywhere roles

Usage:
  yba rbac role list [flags]

Aliases:
  list, ls

Examples:
yba rbac role list

Flags:
  -n, --name string   [Optional] Name of the role. Quote name if it contains space.
      --type string   [Optional] Role type. Allowed values: system, custom. If not specified, all role types are returned.
  -h, --help          help for list

Global Flags:
  -a, --apiToken string    YugabyteDB Anywhere api token.
      --config string      Config file, defaults to $HOME/.yba-cli.yaml
      --debug              Use debug mode, same as --logLevel debug.
      --disable-color      Disable colors in output. (default false)
  -H, --host string        YugabyteDB Anywhere Host (default "http://localhost:9000")
  -l, --logLevel string    Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
  -o, --output string      Select the desired output format. Allowed values: table, json, pretty. (default "table")
      --timeout duration   Wait command timeout, example: 5m, 1h. (default 168h0m0s)
      --wait               Wait until the task is completed, otherwise it will exit immediately. (default true)
```

Describe role:
```
 yba rbac role  describe -h
Describe a RBAC role in YugabyteDB Anywhere

Usage:
  yba rbac role describe [flags]

Aliases:
  describe, get

Examples:
yba rbac role describe --name <role-name>

Flags:
  -n, --name string   [Required] Name of the role. Quote name if it contains space.
  -h, --help          help for describe

Global Flags:
  -a, --apiToken string    YugabyteDB Anywhere api token.
      --config string      Config file, defaults to $HOME/.yba-cli.yaml
      --debug              Use debug mode, same as --logLevel debug.
      --disable-color      Disable colors in output. (default false)
  -H, --host string        YugabyteDB Anywhere Host (default "http://localhost:9000")
  -l, --logLevel string    Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
  -o, --output string      Select the desired output format. Allowed values: table, json, pretty. (default "table")
      --timeout duration   Wait command timeout, example: 5m, 1h. (default 168h0m0s)
      --wait               Wait until the task is completed, otherwise it will exit immediately. (default true)
```

Delete role
```
 yba rbac role  delete -h
Delete a role in YugabyteDB Anywhere

Usage:
  yba rbac role delete [flags]

Aliases:
  delete, remove, rm

Examples:
yba role delete --name <role-name>

Flags:
  -n, --name string   [Required] The name of the role to be deleted.
  -f, --force         [Optional] Bypass the prompt for non-interactive usage.
  -h, --help          help for delete

Global Flags:
  -a, --apiToken string    YugabyteDB Anywhere api token.
      --config string      Config file, defaults to $HOME/.yba-cli.yaml
      --debug              Use debug mode, same as --logLevel debug.
      --disable-color      Disable colors in output. (default false)
  -H, --host string        YugabyteDB Anywhere Host (default "http://localhost:9000")
  -l, --logLevel string    Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
  -o, --output string      Select the desired output format. Allowed values: table, json, pretty. (default "table")
      --timeout duration   Wait command timeout, example: 5m, 1h. (default 168h0m0s)
      --wait               Wait until the task is completed, otherwise it will exit immediately. (default true)

Create role
```
yba rbac role create -h
Create YugabyteDB Anywhere RBAC roles

Usage:
  yba rbac role create [flags]

Aliases:
  create, add

Examples:
yba rbac role create --name <role-name> \
        --permission resource-type=other::action=read \
        --description <description>

Flags:
  -n, --name string              [Required] Name of the role. Quote name if it contains space.
      --description string       [Optional] Description of the role. Quote description if it contains space.
      --permission stringArray   [Required] Permissions associated with the role. Minimum number of required permissions = 1. Provide the following double colon (::) separated fields as key-value pairs: "resource-type=<resource-type>::action=<action>". Both are requires key-values. Allowed resource types are universe, role, user, other. Allowed actions are create, read, update, delete, pause_resume, backup_restore, update_role_bindings, update_profile, super_admin_actions, xcluster. Each permission needs to be added using a separate --permission flag. Example: --permission resource-type=other::action=delete --permission resource-type=universe::action=write
  -h, --help                     help for create

Global Flags:
  -a, --apiToken string    YugabyteDB Anywhere api token.
      --config string      Config file, defaults to $HOME/.yba-cli.yaml
      --debug              Use debug mode, same as --logLevel debug.
      --disable-color      Disable colors in output. (default false)
  -H, --host string        YugabyteDB Anywhere Host (default "http://localhost:9000")
  -l, --logLevel string    Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
  -o, --output string      Select the desired output format. Allowed values: table, json, pretty. (default "table")
      --timeout duration   Wait command timeout, example: 5m, 1h. (default 168h0m0s)
      --wait               Wait until the task is completed, otherwise it will exit immediately. (default true)
```

Update role command:
```
yba rbac role update -h
Update a role in YugabyteDB Anywhere

Usage:
  yba rbac role update [flags]

Aliases:
  update, edit

Examples:
yba rbac role update --name <role-name> \
        --add-permission resource-type=other::action=create

Flags:
  -n, --name string                     [Required] Role name to be updated.
      --add-permission stringArray      [Optional] Add permissions to the role. Provide the following double colon (::) separated fields as key-value pairs: "resource-type=<resource-type>::action=<action>". Both are requires key-values. Allowed resource types are: universe, role, user, other. Allowed actions are: create, read, update, delete, pause_resume, backup_restore, update_role_bindings, update_profile, super_admin_actions, xcluster.Quote action if it contains space. Each permission needs to be added using a separate --add-permission flag.
      --remove-permission stringArray   [Optional] Remove permissions from the role. Provide the following double colon (::) separated fields as key-value pairs: "resource-type=<resource-type>::action=<action>". Both are requires key-values. Allowed resource types are: universe, role, user, other. Allowed actions are: create, read, update, delete, pause_resume, backup_restore, update_role_bindings, update_profile, super_admin_actions, xcluster.Quote action if it contains space. Each permission needs to be removed using a separate --remove-permission flag.
  -h, --help                            help for update

Global Flags:
  -a, --apiToken string    YugabyteDB Anywhere api token.
      --config string      Config file, defaults to $HOME/.yba-cli.yaml
      --debug              Use debug mode, same as --logLevel debug.
      --disable-color      Disable colors in output. (default false)
  -H, --host string        YugabyteDB Anywhere Host (default "http://localhost:9000")
  -l, --logLevel string    Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
  -o, --output string      Select the desired output format. Allowed values: table, json, pretty. (default "table")
      --timeout duration   Wait command timeout, example: 5m, 1h. (default 168h0m0s)
      --wait               Wait until the task is completed, otherwise it will exit immediately. (default true)
```

Test Plan:
`yba rbac permission list`
```
Name                      Resource Type   Action                 Permission Valid On Resource
Update Role               ROLE            UPDATE                 false
Create Role               ROLE            CREATE                 false
View Role                 ROLE            READ                   false
Delete Role               ROLE            DELETE                 false
Delete User               USER            DELETE                 false
Update Role Bindings      USER            UPDATE_ROLE_BINDINGS   false
Create User               USER            CREATE                 false
Update User Profile       USER            UPDATE_PROFILE         false
View User                 USER            READ                   false
View Universe             UNIVERSE        READ                   true
Manage XCluster           UNIVERSE        XCLUSTER               true
Update Universe           UNIVERSE        UPDATE                 true
Create Universe           UNIVERSE        CREATE                 false
Backup/Restore Universe   UNIVERSE        BACKUP_RESTORE         true
Pause/Resume Universe     UNIVERSE        PAUSE_RESUME           true
Delete Universe           UNIVERSE        DELETE                 true
View Resource             OTHER           READ                   false
Create Resource           OTHER           CREATE                 false
Update Resource           OTHER           UPDATE                 false
Delete Resource           OTHER           DELETE                 false
Super Admin Actions       OTHER           SUPER_ADMIN_ACTIONS    false
```
`yba rbac permission describe --name "View Universe"`
```
General
Name            Resource Type   Action    Permission Valid On Resource
View Universe   UNIVERSE        READ      true

Permission Details
Description
Allows user to view a universe.

Prerequisite Permissions
Permission 1: Details
Action    Resource Type
READ      OTHER
```

`yba rbac role list`
```
Name           UUID                                   Role Type
ReadOnly       a392c6cc-a57d-4a04-acb8-0e1d4d1f1205   System
BackupAdmin    f201e3fc-845a-4b5f-9f84-052b6c24d1a3   System
ConnectOnly    7b10ff16-5ac0-4cfe-b1ee-0a0673a5f86b   System
Admin          1c4f107e-a2a4-4b45-916b-3ea6a936e85e   System
SuperAdmin     5853e7a7-0a89-4472-a354-d473de7c21ae   System
Developer L2   bef2eb73-020a-45f1-a9c2-23a5877714d5   Custom
Software L1    019e26b0-0ee2-476c-bb86-b85c20c26412   Custom
```

`yba rbac role get -n "Developer L2"`
```
General
Name           UUID                                   Role Type
Developer L2   bef2eb73-020a-45f1-a9c2-23a5877714d5   Custom

Role Details
Description
Access to selected universes

Created On                        Updated On
Thu, 08 Feb 2024 03:12:41 +0000   Mon, 05 Aug 2024 05:49:24 +0000

Permissions
Permission 1: Details
Action           Resource Type
BACKUP_RESTORE   UNIVERSE

Permission 2: Details
Action    Resource Type
READ      UNIVERSE

Permission 3: Details
Action         Resource Type
PAUSE_RESUME   UNIVERSE

Permission 4: Details
Action    Resource Type
READ      OTHER

Permission 5: Details
Action    Resource Type
DELETE    UNIVERSE

Permission 6: Details
Action     Resource Type
XCLUSTER   UNIVERSE

Permission 7: Details
Action    Resource Type
UPDATE    UNIVERSE
```

`yba rbac role create -n test-cli --permission resource-type=universe::action=delete --permission resource-type=universe::action=read --permission resource-type=other::action=read`
```
Name       UUID                                   Role Type
test-cli   f323efd8-90ea-4090-9b41-00922866aea0   Custom
```

`yba rbac role update -n test-cli --add-permission resource-type=universe::action=read`
```
Name       UUID                                   Role Type
test-cli   f323efd8-90ea-4090-9b41-00922866aea0   Custom
```

Reviewers: skurapati

Reviewed By: skurapati

Subscribers: yugaware

Differential Revision: https://phorge.dev.yugabyte.com/D40222

* [#23331] yugabyted: Update directory location of pg_isready binary in Development Environemnt.

Summary:
Updating the directory location of pg_isready binary from `build/clang17-dynamic-ninja` to `build/latest`.
Jira: DB-12256

Test Plan: Manual Tests

Reviewers: sgarg-yb, djiang

Reviewed By: djiang

Subscribers: yugabyted-dev

Differential Revision: https://phorge.dev.yugabyte.com/D40396

* [PLAT-16128]User management commands - update profile, reset password

Summary:
Password reset for logged in user:
```
 yba user reset-password -h
Reset password of currently logged in user in YugabyteDB Anywhere

Usage:
  yba user reset-password [flags]

Aliases:
  reset-password, reset

Examples:
yba user reset-password \
         --current-password <current-password> --new-password <new-password>

Flags:
      --current-password string   [Required] The current password of the user.
      --new-password string       [Required] The new password of the user.
  -h, --help                      help for reset-password

Global Flags:
  -a, --apiToken string    YugabyteDB Anywhere api token.
      --config string      Config file, defaults to $HOME/.yba-cli.yaml
      --debug              Use debug mode, same as --logLevel debug.
      --disable-color      Disable colors in output. (default false)
  -H, --host string        YugabyteDB Anywhere Host (default "http://localhost:9000")
  -l, --logLevel string    Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
  -o, --output string      Select the desired output format. Allowed values: table, json, pretty. (default "table")
      --timeout duration   Wait command timeout, example: 5m, 1h. (default 168h0m0s)
      --wait               Wait until the task is completed, otherwise it will exit immediately. (default true)
```

Update user
```
 yba user update
Update a user in YugabyteDB Anywhere

Usage:
  yba user update [flags]

Aliases:
  update, edit

Examples:
yba user update --email <user-email> --timezone "America/Los_Angeles"

Flags:
  -e, --email string      [Required] The email of the user to be updated.
      --timezone string   [Optional] The timezone of the user to be updated.
  -h, --help              help for update

Global Flags:
  -a, --apiToken string    YugabyteDB Anywhere api token.
      --config string      Config file, defaults to $HOME/.yba-cli.yaml
      --debug              Use debug mode, same as --logLevel debug.
      --disable-color      Disable colors in output. (default false)
  -H, --host string        YugabyteDB Anywhere Host (default "http://localhost:9000")
  -l, --logLevel string    Select the desired log level format. Allowed values: debug, info, warn, error, fatal. (default "info")
  -o, --output string      Select the desired output format. Allowed values: table, json, pretty. (default "table")
      --timeout duration   Wait command timeout, example: 5m, 1h. (default 168h0m0s)
      --wait               Wait until the task is completed, otherwise it will exit immediately. (default true)
```

Test Plan:
`yba user reset-password --current-password Password#123 --new-password Password#1234`
```
Email               UUID      …
karthik-ramanathan-3006 added a commit that referenced this issue Dec 16, 2024
Summary:
Timeline:

D34040 introduced an optimization to skip redundant index updates and foreign key checks.
D37746 gated this feature behind a preview flag (feature is OFF by default) named yb_update_optimization_infra.
D37749 introduced a feature enablement flag ysql_yb_skip_redundant_update_ops, and promoted the above preview flag to an auto flag.
D40300 turned OFF the feature via the enablement flag ysql_yb_skip_redundant_update_ops due to the bug GH-25075.
D40404 fixed the above bug.

This revision turns ON the feature by default by turning ON the feature enablement flag ysql_yb_skip_redundant_update_ops.
This reverts commit 0529391 (D40300).
Jira: DB-7701

Test Plan: Run Jenkins

Reviewers: amartsinchyk, smishra

Reviewed By: amartsinchyk

Subscribers: ybase, yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D40649
karthik-ramanathan-3006 added a commit that referenced this issue Dec 19, 2024
…ndex updates

Summary:
Timeline:

D34040 introduced an optimization to skip redundant index updates and foreign key checks.
D37746 gated this feature behind a preview flag (feature is OFF by default) named yb_update_optimization_infra.
D37749 introduced a feature enablement flag ysql_yb_skip_redundant_update_ops, and promoted the above preview flag to an auto flag.
D40300 turned OFF the feature via the enablement flag ysql_yb_skip_redundant_update_ops due to the bug GH-25075.
D40404 fixed the above bug.

This revision turns ON the feature by default by turning ON the feature enablement flag ysql_yb_skip_redundant_update_ops.
This reverts commit 0529391 (D40300).
Jira: DB-7701

Original commit: 3c8a0c5 / D40649

Test Plan: Run Jenkins

Reviewers: amartsinchyk, smishra

Reviewed By: amartsinchyk

Subscribers: yql, ybase

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D40774
karthik-ramanathan-3006 added a commit that referenced this issue Dec 23, 2024
…ndex updates

Summary:
Timeline:

D34040 introduced an optimization to skip redundant index updates and foreign key checks.
D37746 gated this feature behind a preview flag (feature is OFF by default) named yb_update_optimization_infra.
D37749 introduced a feature enablement flag ysql_yb_skip_redundant_update_ops, and promoted the above preview flag to an auto flag.
D38598 backported the changes of D37749 to 2024.2, while keeping the feature enablement flag turned OFF (the flag is on in master, by default).
D38936 turned ON the feature in 2024.2 via the enablement flag ysql_yb_skip_redundant_update_ops.
D40300 (and its backports) turned OFF the feature via the enablement flag ysql_yb_skip_redundant_update_ops due to the bug GH-25075.
D40404 (and its backports) fixed the above bug.

This revision turns ON the feature by default by turning ON the feature enablement flag ysql_yb_skip_redundant_update_ops.
This reverts commit 0529391 (D40300).
Jira: DB-7701

Original commit: 3c8a0c5 / D40649

Test Plan: Run Jenkins

Reviewers: amartsinchyk, smishra

Reviewed By: smishra

Subscribers: yql, ybase

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D40830
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) kind/enhancement This is an enhancement of an existing feature priority/medium Medium priority issue
Projects
None yet
Development

No branches or pull requests

3 participants