dengzhhu653 commented on code in PR #3905:
URL: https://github.com/apache/hive/pull/3905#discussion_r1065569766
##########
standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java:
##########
@@ -2615,30 +2625,60 @@ public boolean addPartitions(String catName, String
dbName, String tblName, List
MPartition mpart = convertToMPart(part, table, true);
toPersist.add(mpart);
+ mParts.add(mpart);
int now = (int) (System.currentTimeMillis() / 1000);
+ List<MPartitionPrivilege> mPartPrivileges = new ArrayList<>();
if (tabGrants != null) {
for (MTablePrivilege tab: tabGrants) {
- toPersist.add(new MPartitionPrivilege(tab.getPrincipalName(),
- tab.getPrincipalType(), mpart, tab.getPrivilege(), now,
- tab.getGrantor(), tab.getGrantorType(), tab.getGrantOption(),
- tab.getAuthorizer()));
+ MPartitionPrivilege mPartPrivilege = new
MPartitionPrivilege(tab.getPrincipalName(), tab.getPrincipalType(),
+ mpart, tab.getPrivilege(), now, tab.getGrantor(),
tab.getGrantorType(), tab.getGrantOption(),
+ tab.getAuthorizer());
+ toPersist.add(mPartPrivilege);
+ mPartPrivileges.add(mPartPrivilege);
}
}
+ List<MPartitionColumnPrivilege> mPartColumnPrivileges = new
ArrayList<>();
if (tabColumnGrants != null) {
for (MTableColumnPrivilege col : tabColumnGrants) {
- toPersist.add(new MPartitionColumnPrivilege(col.getPrincipalName(),
- col.getPrincipalType(), mpart, col.getColumnName(),
col.getPrivilege(),
- now, col.getGrantor(), col.getGrantorType(),
col.getGrantOption(),
- col.getAuthorizer()));
+ MPartitionColumnPrivilege mPartColumnPrivilege = new
MPartitionColumnPrivilege(col.getPrincipalName(),
+ col.getPrincipalType(), mpart, col.getColumnName(),
col.getPrivilege(), now, col.getGrantor(),
+ col.getGrantorType(), col.getGrantOption(),
col.getAuthorizer());
+ toPersist.add(mPartColumnPrivilege);
+ mPartColumnPrivileges.add(mPartColumnPrivilege);
}
}
+ mPartPrivilegesList.add(mPartPrivileges);
+ mPartColPrivilegesList.add(mPartColumnPrivileges);
}
if (CollectionUtils.isNotEmpty(toPersist)) {
- pm.makePersistentAll(toPersist);
- pm.flush();
- }
+ GetHelper<Void> helper = new GetHelper<Void>(null, null, null, true,
+ true) {
+ @Override
+ protected Void getSqlResult(GetHelper<Void> ctx) throws
MetaException {
+ directSql.addPartitions(mParts, mPartPrivilegesList,
mPartColPrivilegesList);
+ return null;
+ }
+
+ @Override
+ protected Void getJdoResult(GetHelper<Void> ctx) {
+ reInstateTransaction();
Review Comment:
We have rolled back the transaction if `getSqlResult` in GetHelper#run:
https://github.com/apache/hive/blob/master/standalone-metastore/metastore-server/src/main/java/org/apache/hadoop/hive/metastore/ObjectStore.java#L4375
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]