Skip to content

Commit

Permalink
Issue #2195 - Update after review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Troy Biesterfeld <tbieste@us.ibm.com>
  • Loading branch information
tbieste committed Jun 28, 2021
1 parent 7dde6f4 commit 8db098e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ public class ReindexResourceDAO extends ResourceDAOImpl {

private final ParameterDAO parameterDao;

// Note that currently the global logical_resources table does not carry
// the is_deleted flag. Until it does, the queries will return deleted
// resources, which can be skipped for reindex. (issue-2055)
private static final String PICK_SINGLE_LOGICAL_RESOURCE = ""
+ " SELECT lr.logical_resource_id, lr.resource_type_id, lr.logical_id, lr.reindex_txid "
+ " FROM logical_resources lr "
+ " WHERE lr.logical_resource_id = ? "
+ " AND lr.is_deleted = 'N' "
+ " AND lr.reindex_tstamp < ? "
;

Expand All @@ -63,21 +61,24 @@ public class ReindexResourceDAO extends ResourceDAOImpl {
+ " FROM logical_resources lr "
+ " WHERE lr.resource_type_id = ? "
+ " AND lr.logical_id = ? "
+ " AND lr.is_deleted = 'N' "
+ " AND lr.reindex_tstamp < ? "
;

private static final String PICK_SINGLE_RESOURCE_TYPE = ""
+ " SELECT lr.logical_resource_id, lr.resource_type_id, lr.logical_id, lr.reindex_txid "
+ " FROM logical_resources lr "
+ " WHERE lr.resource_type_id = ? "
+ " AND lr.is_deleted = 'N' "
+ " AND lr.reindex_tstamp < ? "
+ "OFFSET ? ROWS FETCH FIRST 1 ROWS ONLY "
;

private static final String PICK_ANY_RESOURCE = ""
+ " SELECT lr.logical_resource_id, lr.resource_type_id, lr.logical_id, lr.reindex_txid "
+ " FROM logical_resources lr "
+ " WHERE lr.reindex_tstamp < ? "
+ " WHERE lr.is_deleted = 'N' "
+ " AND lr.reindex_tstamp < ? "
+ "OFFSET ? ROWS FETCH FIRST 1 ROWS ONLY "
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
public class PostgresReindexResourceDAO extends ReindexResourceDAO {
private static final Logger logger = Logger.getLogger(PostgresReindexResourceDAO.class.getName());

// Note that currently the global logical_resources table does not carry
// the is_deleted flag. Until it does, the queries will return deleted
// resources, which can be skipped for reindex. (issue-2055)
private static final String PICK_SINGLE_RESOURCE = ""
+ " UPDATE logical_resources "
+ " SET reindex_tstamp = ?,"
Expand All @@ -45,6 +42,7 @@ public class PostgresReindexResourceDAO extends ReindexResourceDAO {
+ " FROM logical_resources lr "
+ " WHERE lr.resource_type_id = ? "
+ " AND lr.logical_id = ? "
+ " AND lr.is_deleted = 'N' "
+ " AND lr.reindex_tstamp < ? "
+ " ORDER BY lr.reindex_tstamp "
+ " FOR UPDATE SKIP LOCKED LIMIT 1) "
Expand All @@ -59,6 +57,7 @@ public class PostgresReindexResourceDAO extends ReindexResourceDAO {
+ " SELECT lr.logical_resource_id "
+ " FROM logical_resources lr "
+ " WHERE lr.resource_type_id = ? "
+ " AND lr.is_deleted = 'N' "
+ " AND lr.reindex_tstamp < ? "
+ " ORDER BY lr.reindex_tstamp "
+ " FOR UPDATE SKIP LOCKED LIMIT 1) "
Expand All @@ -72,7 +71,8 @@ public class PostgresReindexResourceDAO extends ReindexResourceDAO {
+ " WHERE logical_resource_id = ( "
+ " SELECT lr.logical_resource_id "
+ " FROM logical_resources lr "
+ " WHERE lr.reindex_tstamp < ? "
+ " WHERE lr.is_deleted = 'N' "
+ " AND lr.reindex_tstamp < ? "
+ " ORDER BY lr.reindex_tstamp "
+ " FOR UPDATE SKIP LOCKED LIMIT 1) "
+ "RETURNING logical_resource_id, resource_type_id, logical_id, reindex_txid "
Expand Down

0 comments on commit 8db098e

Please sign in to comment.