Skip to content

Commit

Permalink
[#2674] fix(jdbc backend): Save millisecond timestamp on mysql soft d…
Browse files Browse the repository at this point in the history
…elete (#2685)

### What changes were proposed in this pull request?

The current way of saving second-level timestamps will cause multiple
deletion operations fails in the same second because of the duplicate
key. This pr will save millisecond timestamp.

### Why are the changes needed?

Fix: #2674

Co-authored-by: xiaojiebao <[email protected]>
  • Loading branch information
xloya and xiaojiebao authored Mar 27, 2024
1 parent ce50754 commit 66addc7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ Integer updateCatalogMeta(
@Update(
"UPDATE "
+ TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE catalog_id = #{catalogId} AND deleted_at = 0")
Integer softDeleteCatalogMetasByCatalogId(@Param("catalogId") Long catalogId);

@Update(
"UPDATE "
+ TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE metalake_id = #{metalakeId} AND deleted_at = 0")
Integer softDeleteCatalogMetasByMetalakeId(@Param("metalakeId") Long metalakeId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,28 +190,28 @@ Integer updateFilesetMeta(
@Update(
"UPDATE "
+ META_TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE metalake_id = #{metalakeId} AND deleted_at = 0")
Integer softDeleteFilesetMetasByMetalakeId(@Param("metalakeId") Long metalakeId);

@Update(
"UPDATE "
+ META_TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE catalog_id = #{catalogId} AND deleted_at = 0")
Integer softDeleteFilesetMetasByCatalogId(@Param("catalogId") Long catalogId);

@Update(
"UPDATE "
+ META_TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE schema_id = #{schemaId} AND deleted_at = 0")
Integer softDeleteFilesetMetasBySchemaId(@Param("schemaId") Long schemaId);

@Update(
"UPDATE "
+ META_TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE fileset_id = #{filesetId} AND deleted_at = 0")
Integer softDeleteFilesetMetasByFilesetId(@Param("filesetId") Long filesetId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,28 @@ void insertFilesetVersionOnDuplicateKeyUpdate(
@Update(
"UPDATE "
+ VERSION_TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE metalake_id = #{metalakeId} AND deleted_at = 0")
Integer softDeleteFilesetVersionsByMetalakeId(@Param("metalakeId") Long metalakeId);

@Update(
"UPDATE "
+ VERSION_TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE catalog_id = #{catalogId} AND deleted_at = 0")
Integer softDeleteFilesetVersionsByCatalogId(@Param("catalogId") Long catalogId);

@Update(
"UPDATE "
+ VERSION_TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE schema_id = #{schemaId} AND deleted_at = 0")
Integer softDeleteFilesetVersionsBySchemaId(@Param("schemaId") Long schemaId);

@Update(
"UPDATE "
+ VERSION_TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE fileset_id = #{filesetId} AND deleted_at = 0")
Integer softDeleteFilesetVersionsByFilesetId(@Param("filesetId") Long filesetId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Integer updateMetalakeMeta(
@Update(
"UPDATE "
+ TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE metalake_id = #{metalakeId} AND deleted_at = 0")
Integer softDeleteMetalakeMetaByMetalakeId(@Param("metalakeId") Long metalakeId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,21 @@ Integer updateSchemaMeta(
@Update(
"UPDATE "
+ TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE schema_id = #{schemaId} AND deleted_at = 0")
Integer softDeleteSchemaMetasBySchemaId(@Param("schemaId") Long schemaId);

@Update(
"UPDATE "
+ TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE metalake_id = #{metalakeId} AND deleted_at = 0")
Integer softDeleteSchemaMetasByMetalakeId(@Param("metalakeId") Long metalakeId);

@Update(
"UPDATE "
+ TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE catalog_id = #{catalogId} AND deleted_at = 0")
Integer softDeleteSchemaMetasByCatalogId(@Param("catalogId") Long catalogId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,28 +127,28 @@ Integer updateTableMeta(
@Update(
"UPDATE "
+ TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE table_id = #{tableId} AND deleted_at = 0")
Integer softDeleteTableMetasByTableId(@Param("tableId") Long tableId);

@Update(
"UPDATE "
+ TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE metalake_id = #{metalakeId} AND deleted_at = 0")
Integer softDeleteTableMetasByMetalakeId(@Param("metalakeId") Long metalakeId);

@Update(
"UPDATE "
+ TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE catalog_id = #{catalogId} AND deleted_at = 0")
Integer softDeleteTableMetasByCatalogId(@Param("catalogId") Long catalogId);

@Update(
"UPDATE "
+ TABLE_NAME
+ " SET deleted_at = UNIX_TIMESTAMP()"
+ " SET deleted_at = UNIX_TIMESTAMP(CURRENT_TIMESTAMP(3)) * 1000.0"
+ " WHERE schema_id = #{schemaId} AND deleted_at = 0")
Integer softDeleteTableMetasBySchemaId(@Param("schemaId") Long schemaId);
}

0 comments on commit 66addc7

Please sign in to comment.