Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions ql/src/test/results/clientpositive/llap/resourceplan.q.out
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,12 @@ FAILED: SemanticException Invalid create arguments (tok_create_rp plan_3 (tok_qu
PREHOOK: query: ALTER RESOURCE PLAN plan_1 RENAME TO plan_2
PREHOOK: type: ALTER RESOURCEPLAN
PREHOOK: Output: dummyHostnameForTest
FAILED: Execution Error, return code 40000 from org.apache.hadoop.hive.ql.ddl.DDLTask. AlreadyExistsException(message:Resource plan name should be unique: )
FAILED: Execution Error, return code 40000 from org.apache.hadoop.hive.ql.ddl.DDLTask. MetaException(message:JDODataStoreException: Update of object with id "1[OID]org.apache.hadoop.hive.metastore.model.MWMResourcePlan" using statement "UPDATE WM_RESOURCEPLAN SET "NAME"=? WHERE RP_ID=?" failed : org.apache.derby.shared.common.error.DerbySQLIntegrityConstraintViolationException: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'UNIQUE_WM_RESOURCEPLAN' defined on 'WM_RESOURCEPLAN'.

@dengzhhu653 dengzhhu653 Jun 20, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This diff is due to the time transaction commits, before the change alterResourcePlan throws this DerbySQLIntegrityConstraintViolationException on commitTransaction, and in this method will catch and re-throw Metastore specific exception, as we move the transaction management to TransactionHandler, the time transaction commits happens after the call, so we wont be able to catch the exception in WMStoreImpl and transform the exception as before.

#### A masked pattern was here ####
Caused by: ERROR 23505: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'UNIQUE_WM_RESOURCEPLAN' defined on 'WM_RESOURCEPLAN'.
#### A masked pattern was here ####

Root cause: ERROR 23505: The statement was aborted because it would have caused a duplicate key value in a unique or primary key constraint or unique index identified by 'UNIQUE_WM_RESOURCEPLAN' defined on 'WM_RESOURCEPLAN'.)
Comment on lines +538 to +543
PREHOOK: query: SELECT * FROM SYS.WM_RESOURCEPLANS
PREHOOK: type: QUERY
PREHOOK: Input: sys@wm_resourceplans
Expand Down Expand Up @@ -1991,7 +1996,9 @@ plan_2 default USER user2 def 1
PREHOOK: query: DROP POOL plan_2.def.c1
PREHOOK: type: DROP POOL
PREHOOK: Output: dummyHostnameForTest
FAILED: Execution Error, return code 40000 from org.apache.hadoop.hive.ql.ddl.DDLTask. InvalidOperationException(message:Please remove all mappings for this pool.)
FAILED: Execution Error, return code 40000 from org.apache.hadoop.hive.ql.ddl.DDLTask. MetaException(message:JDODataStoreException: Batched statement "DELETE FROM WM_POOL WHERE POOL_ID=?" failed.
DELETE on table 'WM_POOL' caused a violation of foreign key constraint 'WM_MAPPING_FK2' for key (6). The statement has been rolled back.
Root cause: ERROR 23503: DELETE on table 'WM_POOL' caused a violation of foreign key constraint 'WM_MAPPING_FK2' for key (6). The statement has been rolled back.)
PREHOOK: query: EXPLAIN DROP USER MAPPING "user2" in plan_2
PREHOOK: type: DROP MAPPING
PREHOOK: Output: dummyHostnameForTest
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -2239,38 +2239,6 @@ long getPartsFound() {
return rawStore.cleanupEvents();
}

@Override public boolean addToken(String tokenIdentifier, String delegationToken) {
return rawStore.addToken(tokenIdentifier, delegationToken);
}

@Override public boolean removeToken(String tokenIdentifier) {
return rawStore.removeToken(tokenIdentifier);
}

@Override public String getToken(String tokenIdentifier) {
return rawStore.getToken(tokenIdentifier);
}

@Override public List<String> getAllTokenIdentifiers() {
return rawStore.getAllTokenIdentifiers();
}

@Override public int addMasterKey(String key) throws MetaException {
return rawStore.addMasterKey(key);
}

@Override public void updateMasterKey(Integer seqNo, String key) throws NoSuchObjectException, MetaException {
rawStore.updateMasterKey(seqNo, key);
}

@Override public boolean removeMasterKey(Integer keySeq) {
return rawStore.removeMasterKey(keySeq);
}

@Override public String[] getMasterKeys() {
return rawStore.getMasterKeys();
}

@Override public void verifySchema() throws MetaException {
rawStore.verifySchema();
}
Expand Down Expand Up @@ -2542,11 +2510,6 @@ public List<SQLCheckConstraint> addCheckConstraints(List<SQLCheckConstraint> ccs
rawStore.createISchema(schema);
}

@Override public List<ColStatsObjWithSourceInfo> getPartitionColStatsForDatabase(String catName, String dbName)
throws MetaException, NoSuchObjectException {
return rawStore.getPartitionColStatsForDatabase(catName, dbName);
}

@Override public void alterISchema(ISchemaName schemaName, ISchema newSchema)
throws NoSuchObjectException, MetaException {
rawStore.alterISchema(schemaName, newSchema);
Expand Down Expand Up @@ -2611,99 +2574,10 @@ public RawStore getRawStore() {
return rawStore.getMetastoreDbUuid();
}

@Override public void createResourcePlan(WMResourcePlan resourcePlan, String copyFrom, int defaultPoolSize)
throws AlreadyExistsException, InvalidObjectException, MetaException, NoSuchObjectException {
rawStore.createResourcePlan(resourcePlan, copyFrom, defaultPoolSize);
}

@Override public WMFullResourcePlan getResourcePlan(String name, String ns)
throws NoSuchObjectException, MetaException {
return rawStore.getResourcePlan(name, ns);
}

@Override public List<WMResourcePlan> getAllResourcePlans(String ns) throws MetaException {
return rawStore.getAllResourcePlans(ns);
}

@Override public WMFullResourcePlan alterResourcePlan(String name, String ns, WMNullableResourcePlan resourcePlan,
boolean canActivateDisabled, boolean canDeactivate, boolean isReplace)
throws AlreadyExistsException, NoSuchObjectException, InvalidOperationException, MetaException {
return rawStore.alterResourcePlan(name, ns, resourcePlan, canActivateDisabled, canDeactivate, isReplace);
}

@Override public WMFullResourcePlan getActiveResourcePlan(String ns) throws MetaException {
return rawStore.getActiveResourcePlan(ns);
}

@Override public WMValidateResourcePlanResponse validateResourcePlan(String name, String ns)
throws NoSuchObjectException, InvalidObjectException, MetaException {
return rawStore.validateResourcePlan(name, ns);
}

@Override public void dropResourcePlan(String name, String ns) throws NoSuchObjectException, MetaException {
rawStore.dropResourcePlan(name, ns);
}

@Override public void createWMTrigger(WMTrigger trigger)
throws AlreadyExistsException, MetaException, NoSuchObjectException, InvalidOperationException {
rawStore.createWMTrigger(trigger);
}

@Override public void alterWMTrigger(WMTrigger trigger)
throws NoSuchObjectException, InvalidOperationException, MetaException {
rawStore.alterWMTrigger(trigger);
}

@Override public void dropWMTrigger(String resourcePlanName, String triggerName, String ns)
throws NoSuchObjectException, InvalidOperationException, MetaException {
rawStore.dropWMTrigger(resourcePlanName, triggerName, ns);
}

@Override public List<WMTrigger> getTriggersForResourcePlan(String resourcePlanName, String ns)
throws NoSuchObjectException, MetaException {
return rawStore.getTriggersForResourcePlan(resourcePlanName, ns);
}

@Override public void createPool(WMPool pool)
throws AlreadyExistsException, NoSuchObjectException, InvalidOperationException, MetaException {
rawStore.createPool(pool);
}

@Override public void alterPool(WMNullablePool pool, String poolPath)
throws AlreadyExistsException, NoSuchObjectException, InvalidOperationException, MetaException {
rawStore.alterPool(pool, poolPath);
}

@Override public void dropWMPool(String resourcePlanName, String poolPath, String ns)
throws NoSuchObjectException, InvalidOperationException, MetaException {
rawStore.dropWMPool(resourcePlanName, poolPath, ns);
}

@Override public void createOrUpdateWMMapping(WMMapping mapping, boolean update)
throws AlreadyExistsException, NoSuchObjectException, InvalidOperationException, MetaException {
rawStore.createOrUpdateWMMapping(mapping, update);
}

@Override public void dropWMMapping(WMMapping mapping)
throws NoSuchObjectException, InvalidOperationException, MetaException {
rawStore.dropWMMapping(mapping);
}

@Override public void createWMTriggerToPoolMapping(String resourcePlanName, String triggerName, String poolPath,
String ns) throws AlreadyExistsException, NoSuchObjectException, InvalidOperationException, MetaException {
rawStore.createWMTriggerToPoolMapping(resourcePlanName, triggerName, poolPath, ns);
}

@Override public void dropWMTriggerToPoolMapping(String resourcePlanName, String triggerName, String poolPath,
String ns) throws NoSuchObjectException, InvalidOperationException, MetaException {
rawStore.dropWMTriggerToPoolMapping(resourcePlanName, triggerName, poolPath, ns);
}

public long getCacheUpdateCount() {
return sharedCache.getUpdateCount();
}


static boolean isNotInBlackList(String catName, String dbName, String tblName) {
String str = TableName.getQualified(catName, dbName, tblName);
for (Pattern pattern : blacklistPatterns) {
Expand Down Expand Up @@ -2777,35 +2651,6 @@ static boolean isBlacklistWhitelistEmpty(Configuration conf) {
setCachePrewarmedState(false);
}

@Override public void addRuntimeStat(RuntimeStat stat) throws MetaException {
rawStore.addRuntimeStat(stat);
}

@Override public List<RuntimeStat> getRuntimeStats(int maxEntries, int maxCreateTime) throws MetaException {
return rawStore.getRuntimeStats(maxEntries, maxCreateTime);
}

@Override public int deleteRuntimeStats(int maxRetainSecs) throws MetaException {
return rawStore.deleteRuntimeStats(maxRetainSecs);
}

@Override public List<TableName> getTableNamesWithStats() throws MetaException, NoSuchObjectException {
return rawStore.getTableNamesWithStats();
}

@Override public List<TableName> getAllTableNamesForStats() throws MetaException, NoSuchObjectException {
return rawStore.getAllTableNamesForStats();
}

@Override public Map<String, List<String>> getPartitionColsWithStats(String catName, String dbName, String tableName)
throws MetaException, NoSuchObjectException {
return rawStore.getPartitionColsWithStats(catName, dbName, tableName);
}

@Override public List<String> isPartOfMaterializedView(String catName, String dbName, String tblName) {
return rawStore.isPartOfMaterializedView(catName, dbName, tblName);
}

@Override
public ScheduledQueryPollResponse scheduledQueryPoll(ScheduledQueryPollRequest request) throws MetaException {
return rawStore.scheduledQueryPoll(request);
Expand Down Expand Up @@ -2853,11 +2698,6 @@ public int markScheduledExecutionsTimedOut(int timeoutSecs) throws InvalidOperat
return rawStore.markScheduledExecutionsTimedOut(timeoutSecs);
}

@Override
public void deleteAllPartitionColumnStatistics(TableName tn, String w) {
rawStore.deleteAllPartitionColumnStatistics(tn, w);
}

@Override
public void createOrUpdateStoredProcedure(StoredProcedure proc) throws NoSuchObjectException, MetaException {
rawStore.createOrUpdateStoredProcedure(proc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
@VisibleForTesting
public abstract class GetHelper<A, T> {
private static final Logger LOG = LoggerFactory.getLogger(GetHelper.class);
private static final Counter directSqlErrors = Metrics.getRegistry() != null ?
Metrics.getOrCreateCounter(MetricsConstants.DIRECTSQL_ERRORS) : new Counter();
private static Counter directSqlErrors = setDirectSqlErrors(Metrics.getRegistry() != null ?
Metrics.getOrCreateCounter(MetricsConstants.DIRECTSQL_ERRORS) : new Counter());
private final boolean isInTxn, doTrace, allowJdo;
private boolean doUseDirectSql;
private long start;
Expand All @@ -61,11 +61,11 @@ public abstract class GetHelper<A, T> {
private boolean success = false;
protected T results = null;

public GetHelper(RawStoreAware rsa, A args) throws MetaException {
public GetHelper(RawStoreBundle rsa, A args) throws MetaException {
this(rsa, args, null);
}

public GetHelper(RawStoreAware rsa,
public GetHelper(RawStoreBundle rsa,
A args, List<String> fields) throws MetaException {
this.baseStore = rsa.getBaseStore();
this.partitionFields = fields;
Expand Down Expand Up @@ -195,13 +195,13 @@ private void handleDirectSqlError(Exception ex, String savePoint) throws MetaExc
doUseDirectSql = false;
}

private void setTransactionSavePoint(String savePoint) {
public void setTransactionSavePoint(String savePoint) {
if (savePoint != null) {
((JDOTransaction) pm.currentTransaction()).setSavepoint(savePoint);
}
}

private void rollbackTransactionToSavePoint(String savePoint) {
public void rollbackTransactionToSavePoint(String savePoint) {
if (savePoint != null) {
((JDOTransaction) pm.currentTransaction()).rollbackToSavepoint(savePoint);
}
Expand Down Expand Up @@ -272,4 +272,10 @@ public List<String> getPartitionFields() {
public static long getDirectSqlErrors() {
return directSqlErrors.getCount();
}

@VisibleForTesting
public static Counter setDirectSqlErrors(Counter counter) {
directSqlErrors = counter;
return counter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import org.apache.hadoop.hive.metastore.api.MetaException;

public abstract class GetListHelper<A, T> extends GetHelper<A, List<T>> {
public GetListHelper(RawStoreAware rsa, A args) throws MetaException {
public GetListHelper(RawStoreBundle rsa, A args) throws MetaException {
super(rsa, args, null);
}

public GetListHelper(RawStoreAware rsa,
public GetListHelper(RawStoreBundle rsa,
A args, List<String> fields) throws MetaException {
super(rsa, args, fields);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import org.apache.hadoop.hive.metastore.RawStore;

public abstract class RawStoreAware {
public abstract class RawStoreBundle {
protected RawStore baseStore;
protected PersistenceManager pm;

Expand Down
Loading
Loading