Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1157: Fix for S3BlobStore bulk delete (without listeners) #1162

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public String parametersMetadataPrefix(final String layerName) {
* @return the key prefix up to the coordinates (i.e. {@code
* "<prefix>/<layer>/<gridset>/<format>/<parametersId>"})
*/
public String coordinatesPrefix(TileRange obj, boolean endWithSlah) {
public String coordinatesPrefix(TileRange obj, boolean endWithSlash) {
checkNotNull(obj.getLayerName());
checkNotNull(obj.getGridSetId());
checkNotNull(obj.getMimeType());
Expand All @@ -215,7 +215,7 @@ public String coordinatesPrefix(TileRange obj, boolean endWithSlah) {
}
String shortFormat = mimeType.getFileExtension(); // png, png8, png24, etc

String key = join(endWithSlah, prefix, layer, gridset, shortFormat, parametersId);
String key = join(endWithSlash, prefix, layer, gridset, shortFormat, parametersId);
return key;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public KeyVersion apply(long[] loc) {
@Override
public boolean delete(final TileRange tileRange) throws StorageException {

final String coordsPrefix = keyBuilder.coordinatesPrefix(tileRange, false);
final String coordsPrefix = keyBuilder.coordinatesPrefix(tileRange, true);
Copy link
Member

Choose a reason for hiding this comment

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

The change looks legit, not sure why it was working with the listener thought?
Also, can you add a test to cover this issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Andrea, thanks for your review.

It was working with the listener because the coordsPrefix is not used there (see lines 349 and on).
if (listeners.isEmpty()) { <not working, because of coordsPrefix without ending slash> } else { <working, not using coordsPrefix> }

https://github.com/geowebcache/geowebcache/blob/a1a70d33facd19445e16abab6f12b35995b62d41/geowebcache/s3storage/src/main/java/org/geowebcache/s3/S3BlobStore.java#L349-L364

The test exists, but has been ignored by 855ed09.

public void testTruncateOptimizationIfNoListeners() throws StorageException, MimeException {

It effectively fails before the change above, and succeeds after the change.

Maybe you want to try to un-ignore this test?

Copy link
Member

Choose a reason for hiding this comment

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

You should un-ignore the test with this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

if (!s3Ops.prefixExists(coordsPrefix)) {
return false;
}
Expand Down