lokiore opened a new pull request, #2661: URL: https://github.com/apache/phoenix/pull/2661
JIRA: https://issues.apache.org/jira/browse/PHOENIX-8047 ### What changes were proposed in this pull request? - Add `ScanUtil.setScanAttributeForHA(Scan, PhoenixConnection)`. It sets `_HAGroupName` on the scan when the connection has an HA group. `setScanAttributeForHAForPointLookups` now calls it. - Call it in `DeleteCompiler.ServerSelectDeleteMutationPlan.execute` and `UpsertCompiler.ServerUpsertSelectMutationPlan.execute`. - This is a client-only change. ### Why are the changes needed? A server-side DELETE and an auto-commit UPSERT SELECT make their mutations in `UngroupedAggregateRegionScanner`. `annotateDataMutations` copies `_HAGroupName` from the scan onto each mutation. Before this change, the client set the attribute only on point-lookup scans. Thus these mutations got to `IndexRegionObserver.preBatchMutate` without the attribute, and it classified them as `CLIENT_NON_HA`. For these mutations on an HA connection: - They were not written to the replication log, so the standby cluster did not get them. - They did not get the stale cluster role record check. - They did not get the ACTIVE_TO_STANDBY mutation block, so they could write during a failover. - Each batch incremented the bypass counter, and one WARN was logged for each table. These statement shapes have the problem: - Range or full-table DELETE with auto-commit (plan `DELETE ROWS SERVER SELECT`). - Same-table UPSERT SELECT with auto-commit (plan `UPSERT ROWS`). - Cross-table UPSERT SELECT with auto-commit when `phoenix.client.enable.server.upsert.select=true`. - Single-row `DELETE ... RETURNING *`. A pure primary-key point DELETE, and a cross-table UPSERT SELECT with the default config, run on the client and were already correct. ### Does this PR introduce _any_ user-facing change? Yes, only for HA (consistent failover) connections. Server-side DELETE and UPSERT SELECT mutations are now replicated, and the server applies the stale cluster role record check and the ACTIVE_TO_STANDBY mutation block to them. Thus during ACTIVE_TO_STANDBY, these statements now fail with the mutation-blocked error. Before, they wrote to the cluster. The server-side DML scan also gets the stale cluster role record check when the scanner opens, the same as a point-lookup scan. Connections without an HA group do not change. ### How was this patch tested? New ITs: - `ReplicationLogGroupIT`: `testServerSideDeleteReplicates`, `testServerSideUpsertSelectReplicates`, `testServerSideCrossTableUpsertSelectReplicates`, `testServerSideSingleRowDeleteReturningReplicates`. Each test checks the explain plan, checks that the bypass counter does not change, and replays the replication log to the peer cluster, then compares the two clusters. - `IndexRegionObserverMutationBlockingIT#testServerSideDmlBlockedDuringActiveToStandby`: in ACTIVE_TO_STANDBY, an auto-commit DELETE and a same-table UPSERT SELECT fail with the mutation-blocked error, and the rows do not change. Results (on the current `PHOENIX-7562-feature-new` head): - With this change: all 5 new tests pass. - Without the fix: all 5 new tests fail (run on the earlier base c9ea66c177). For example, the replication log had only 20 of 40 mutations for the DELETE and UPSERT SELECT cases, and the DELETE in ACTIVE_TO_STANDBY was accepted. - Regression run of `ReplicationLogGroupIT`, `ReplicationLogGroupParallelIT`, `IndexRegionObserverMutationBlockingIT`, `BypassedMutationBlockMetricsIT`, `FailoverPhoenixConnectionIT`, `FailoverPhoenixConnection2IT` and `PhoenixRegionServerEndpointWithConsistentFailoverIT`: 77 tests, 0 failures, 0 errors, 1 skipped. Not in this change (the same gap can occur, to examine in a follow-up): `PostDDLCompiler` row deletes, `ServerBuildIndexCompiler`, `ServerBuildTransformingTableCompiler`, local-index mutations from `UngroupedAggregateRegionScanner`, and the DESC row key order upgrade path. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 5.5) 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
