Skip to content

Commit 8139125

Browse files
craig[bot]dtyuzefovich
committed
143069: cloud/amazon: add option to skip checksums r=dt a=dt Our files (SSTs) often have internal checksums anyway, and we have ecplicit checksum files for those that don't that are cloud agnostic, so we do not generally need the extra checksums in s3-specific metadata. Computing them has non-zero cost as well, so users may wish to disable them. Indeed, we almost did so by default a couple years ago before realizing that they are required by the S3 API if certain other features, like object locking, are enabled. So while some users may not be able to or want to disable them, e.g. if they're using object locking, we can provide the option to do so to those who would want it. This may also be useful to users of certain s3-like storage services that have different compatibility with different checksums. Release note: none. Epic: none. 143691: roachtest/pg_regress: update diffs r=yuzefovich a=yuzefovich Fixes: #143683. Release note: None Co-authored-by: David Taylor <[email protected]> Co-authored-by: Yahor Yuzefovich <[email protected]>
3 parents f2906ea + c3c4364 + 3787d78 commit 8139125

File tree

13 files changed

+454
-610
lines changed

13 files changed

+454
-610
lines changed

pkg/cloud/amazon/s3_storage.go

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ const (
5757
AWSEndpointParam = "AWS_ENDPOINT"
5858
// AWSEndpointParam is the query parameter for UsePathStyle in S3 options.
5959
AWSUsePathStyle = "AWS_USE_PATH_STYLE"
60+
// AWSSkipChecksumParam is the query parameter for SkipChecksum in S3 options.
61+
AWSSkipChecksumParam = "AWS_SKIP_CHECKSUM"
6062

6163
// AWSServerSideEncryptionMode is the query parameter in an AWS URI, for the
6264
// mode to be used for server side encryption. It can either be AES256 or
@@ -200,6 +202,7 @@ type s3ClientConfig struct {
200202
assumeRoleProvider roleProvider
201203
delegateRoleProviders []roleProvider
202204

205+
skipChecksum bool
203206
// log.V(2) decides session init params so include it in key.
204207
verbose bool
205208
}
@@ -232,6 +235,7 @@ func clientConfig(conf *cloudpb.ExternalStorage_S3) s3ClientConfig {
232235
return s3ClientConfig{
233236
endpoint: conf.Endpoint,
234237
usePathStyle: conf.UsePathStyle,
238+
skipChecksum: conf.SkipChecksum,
235239
region: conf.Region,
236240
bucket: conf.Bucket,
237241
accessKey: conf.AccessKey,
@@ -280,6 +284,9 @@ func S3URI(bucket, path string, conf *cloudpb.ExternalStorage_S3) string {
280284
if conf.UsePathStyle {
281285
q.Set(AWSUsePathStyle, "true")
282286
}
287+
if conf.SkipChecksum {
288+
q.Set(AWSSkipChecksumParam, "true")
289+
}
283290
if conf.AssumeRoleProvider.Role != "" {
284291
roleProviderStrings := make([]string, 0, len(conf.DelegateRoleProviders)+1)
285292
for _, p := range conf.DelegateRoleProviders {
@@ -325,6 +332,15 @@ func parseS3URL(uri *url.URL) (cloudpb.ExternalStorage, error) {
325332
return cloudpb.ExternalStorage{}, errors.Wrapf(err, "cannot parse %s as bool", AWSUsePathStyle)
326333
}
327334
}
335+
skipChecksumStr := s3URL.ConsumeParam(AWSSkipChecksumParam)
336+
skipChecksumBool := false
337+
if skipChecksumStr != "" {
338+
var err error
339+
skipChecksumBool, err = strconv.ParseBool(skipChecksumStr)
340+
if err != nil {
341+
return cloudpb.ExternalStorage{}, errors.Wrapf(err, "cannot parse %s as bool", AWSSkipChecksumParam)
342+
}
343+
}
328344

329345
conf.S3Config = &cloudpb.ExternalStorage_S3{
330346
Bucket: s3URL.Host,
@@ -334,6 +350,7 @@ func parseS3URL(uri *url.URL) (cloudpb.ExternalStorage, error) {
334350
TempToken: s3URL.ConsumeParam(AWSTempTokenParam),
335351
Endpoint: s3URL.ConsumeParam(AWSEndpointParam),
336352
UsePathStyle: pathStyleBool,
353+
SkipChecksum: skipChecksumBool,
337354
Region: s3URL.ConsumeParam(S3RegionParam),
338355
Auth: s3URL.ConsumeParam(cloud.AuthParam),
339356
ServerEncMode: s3URL.ConsumeParam(AWSServerSideEncryptionMode),
@@ -590,6 +607,11 @@ func (s *s3Storage) newClient(ctx context.Context) (s3Client, string, error) {
590607
return s3Client{}, "", errors.Wrap(err, "could not initialize an aws config")
591608
}
592609

610+
if s.opts.skipChecksum {
611+
cfg.ResponseChecksumValidation = aws.ResponseChecksumValidationWhenRequired
612+
cfg.RequestChecksumCalculation = aws.RequestChecksumCalculationWhenRequired
613+
}
614+
593615
var endpointURI string
594616
if s.opts.endpoint != "" {
595617
var err error
@@ -728,7 +750,7 @@ func (s *s3Storage) putUploader(ctx context.Context, basename string) (io.WriteC
728750

729751
buf := bytes.NewBuffer(make([]byte, 0, 4<<20))
730752

731-
return &putUploader{
753+
uploader := &putUploader{
732754
b: buf,
733755
input: &s3.PutObjectInput{
734756
Bucket: s.bucket,
@@ -739,7 +761,11 @@ func (s *s3Storage) putUploader(ctx context.Context, basename string) (io.WriteC
739761
ChecksumAlgorithm: checksumAlgorithm,
740762
},
741763
client: client,
742-
}, nil
764+
}
765+
if s.conf.SkipChecksum {
766+
uploader.input.ChecksumAlgorithm = ""
767+
}
768+
return uploader, nil
743769
}
744770

745771
func (s *s3Storage) Writer(ctx context.Context, basename string) (io.WriteCloser, error) {
@@ -757,16 +783,21 @@ func (s *s3Storage) Writer(ctx context.Context, basename string) (io.WriteCloser
757783
return cloud.BackgroundPipe(ctx, func(ctx context.Context, r io.Reader) error {
758784
defer sp.Finish()
759785
// Upload the file to S3.
760-
// TODO(dt): test and tune the uploader parameters.
761-
_, err := uploader.Upload(ctx, &s3.PutObjectInput{
786+
input := &s3.PutObjectInput{
762787
Bucket: s.bucket,
763788
Key: aws.String(path.Join(s.prefix, basename)),
764789
Body: r,
765790
ServerSideEncryption: types.ServerSideEncryption(s.conf.ServerEncMode),
766791
SSEKMSKeyId: nilIfEmpty(s.conf.ServerKMSID),
767792
StorageClass: types.StorageClass(s.conf.StorageClass),
768793
ChecksumAlgorithm: checksumAlgorithm,
769-
})
794+
}
795+
796+
if s.conf.SkipChecksum {
797+
input.ChecksumAlgorithm = ""
798+
}
799+
800+
_, err := uploader.Upload(ctx, input)
770801
err = interpretAWSError(err)
771802
err = errors.Wrap(err, "upload failed")
772803
// Mark with ctx's error for upstream code to not interpret this as
@@ -787,7 +818,9 @@ func (s *s3Storage) openStreamAt(
787818
if err != nil {
788819
return nil, err
789820
}
790-
req := &s3.GetObjectInput{Bucket: s.bucket, Key: aws.String(path.Join(s.prefix, basename))}
821+
req := &s3.GetObjectInput{
822+
Bucket: s.bucket, Key: aws.String(path.Join(s.prefix, basename)),
823+
}
791824
if endPos != 0 {
792825
if pos >= endPos {
793826
return nil, io.EOF

pkg/cloud/amazon/s3_storage_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,22 @@ func TestPutS3(t *testing.T) {
167167
cloudtestutils.CheckExportStore(t, info)
168168
})
169169

170+
t.Run("skip-checksums", func(t *testing.T) {
171+
if locked {
172+
skip.IgnoreLint(t, "object-locked buckets do not support skipping checksums")
173+
}
174+
skipIfNoDefaultConfig(t, ctx)
175+
info := cloudtestutils.StoreInfo{
176+
URI: fmt.Sprintf(
177+
"s3://%s/%s-%d?%s=%s&%s=true",
178+
bucket, "backup-test-skip-checksums", testID,
179+
cloud.AuthParam, cloud.AuthParamImplicit, AWSSkipChecksumParam,
180+
),
181+
User: user,
182+
}
183+
cloudtestutils.CheckExportStore(t, info)
184+
})
185+
170186
t.Run("server-side-encryption-invalid-params", func(t *testing.T) {
171187
skipIfNoDefaultConfig(t, ctx)
172188
// Unsupported server side encryption option.
@@ -357,6 +373,7 @@ func TestPutS3Endpoint(t *testing.T) {
357373
}
358374
cloudtestutils.CheckExportStore(t, info)
359375
})
376+
360377
t.Run("use-path-style", func(t *testing.T) {
361378
// EngFlow machines have no internet access, and queries even to localhost will time out.
362379
// So this test is skipped above.

pkg/cloud/cloudpb/external_storage.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ message ExternalStorage {
6363
string temp_token = 5;
6464
string endpoint = 6;
6565
bool use_path_style=16;
66+
bool skip_checksum=17;
6667
string region = 7;
6768
string auth = 8;
6869
string server_enc_mode = 9;
@@ -91,7 +92,10 @@ message ExternalStorage {
9192
// role chain. These roles will be assumed in the order they appear in the
9293
// list so that the role specified in AssumeRoleProvider can be assumed.
9394
repeated AssumeRoleProvider delegate_role_providers = 15 [(gogoproto.nullable) = false];
95+
96+
// Next ID: 18;
9497
}
98+
9599
message GCS {
96100
string bucket = 1;
97101
string prefix = 2;

pkg/cmd/roachtest/testdata/pg_regress/alter_table.diffs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/alter_table.out -
16301630
-ERROR: column "test" is in a primary key
16311631
+ERROR: column "test" is in a primary index
16321632
alter table atacc1 drop constraint "atacc1_pkey";
1633-
+ERROR: relation "atacc1" (1956): unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
1633+
+ERROR: relation "atacc1" (1984): unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
16341634
+HINT: You have attempted to use a feature that is not yet implemented.
16351635
+See: https://go.crdb.dev/issue-v/48026/_version_
16361636
alter table atacc1 alter column test drop not null;
@@ -5216,13 +5216,13 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/alter_table.out -
52165216
+ERROR: index with name "tt9_c_key" already exists
52175217
ALTER TABLE tt9 ADD CONSTRAINT foo UNIQUE(c); -- fail, dup name
52185218
-ERROR: constraint "foo" for relation "tt9" already exists
5219-
+ERROR: error executing StatementPhase stage 1 of 1 with 7 MutationType ops: relation "tt9" (2051): duplicate constraint name: "foo"
5219+
+ERROR: error executing StatementPhase stage 1 of 1 with 7 MutationType ops: relation "tt9" (2079): duplicate constraint name: "foo"
52205220
ALTER TABLE tt9 ADD CONSTRAINT tt9_c_key CHECK(c > 5); -- fail, dup name
52215221
-ERROR: constraint "tt9_c_key" for relation "tt9" already exists
5222-
+ERROR: error executing StatementPhase stage 1 of 1 with 2 MutationType ops: relation "tt9" (2051): duplicate constraint name: "tt9_c_key"
5222+
+ERROR: error executing StatementPhase stage 1 of 1 with 2 MutationType ops: relation "tt9" (2079): duplicate constraint name: "tt9_c_key"
52235223
ALTER TABLE tt9 ADD CONSTRAINT tt9_c_key2 CHECK(c > 6);
52245224
ALTER TABLE tt9 ADD UNIQUE(c); -- picks nonconflicting name
5225-
+ERROR: error executing StatementPhase stage 1 of 1 with 7 MutationType ops: relation "tt9" (2051): duplicate constraint name: "tt9_c_key2"
5225+
+ERROR: error executing StatementPhase stage 1 of 1 with 7 MutationType ops: relation "tt9" (2079): duplicate constraint name: "tt9_c_key2"
52265226
\d tt9
52275227
- Table "public.tt9"
52285228
- Column | Type | Collation | Nullable | Default
@@ -5404,7 +5404,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/alter_table.out -
54045404
DELETE FROM old_system_table WHERE othercol = 'somedata';
54055405
TRUNCATE old_system_table;
54065406
ALTER TABLE old_system_table DROP CONSTRAINT new_system_table_pkey;
5407-
+ERROR: relation "old_system_table" (2054): unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
5407+
+ERROR: relation "old_system_table" (2082): unimplemented: primary key dropped without subsequent addition of new primary key in same transaction
54085408
+HINT: You have attempted to use a feature that is not yet implemented.
54095409
+See: https://go.crdb.dev/issue-v/48026/_version_
54105410
ALTER TABLE old_system_table DROP COLUMN othercol;

pkg/cmd/roachtest/testdata/pg_regress/create_table_like.diffs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/create_table_like
5454

5555
CREATE TABLE inhf (LIKE inhx, LIKE inhx); /* Throw error */
5656
-ERROR: column "xx" specified more than once
57-
+ERROR: relation "inhf" (1332): duplicate column name: "xx"
57+
+ERROR: relation "inhf" (1360): duplicate column name: "xx"
5858
CREATE TABLE inhf (LIKE inhx INCLUDING DEFAULTS INCLUDING CONSTRAINTS);
5959
INSERT INTO inhf DEFAULT VALUES;
6060
SELECT * FROM inhf; /* Single entry with value 'text' */

pkg/cmd/roachtest/testdata/pg_regress/float8.diffs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/float8.out --labe
191191
SELECT power(float8 '-inf', float8 'inf');
192192
power
193193
----------
194-
@@ -631,29 +592,60 @@
194+
@@ -631,9 +592,25 @@
195195
SET f1 = FLOAT8_TBL.f1 * '-1'
196196
WHERE FLOAT8_TBL.f1 > '0.0';
197197
SELECT f.f1 * '1e200' from FLOAT8_TBL f;
@@ -207,20 +207,21 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/float8.out --labe
207207
+
208208
SELECT f.f1 ^ '1e200' from FLOAT8_TBL f;
209209
-ERROR: value out of range: overflow
210-
-SELECT 0 ^ 0 + 0 ^ 1 + 0 ^ 0.0 + 0 ^ 0.5;
211-
?column?
212-
----------
213-
- 2
214-
-(1 row)
210+
+ ?column?
211+
+----------
215212
+ 0
216213
+ Infinity
217214
+ Infinity
218215
+ Infinity
219216
+ 0
220217
+(5 rows)
218+
+
219+
SELECT 0 ^ 0 + 0 ^ 1 + 0 ^ 0.0 + 0 ^ 0.5;
220+
?column?
221+
----------
222+
@@ -641,19 +618,38 @@
223+
(1 row)
221224

222-
+SELECT 0 ^ 0 + 0 ^ 1 + 0 ^ 0.0 + 0 ^ 0.5;
223-
+ERROR: integer out of range
224225
SELECT ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' ;
225226
-ERROR: cannot take logarithm of zero
226227
+ ln
@@ -261,7 +262,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/float8.out --labe
261262
-1.2345678901234e+200
262263
-1.2345678901234e-200
263264
(5 rows)
264-
@@ -773,7 +765,11 @@
265+
@@ -773,7 +769,11 @@
265266
-- acosh(Inf) should be Inf, but some mingw versions produce NaN, so skip test
266267
-- SELECT acosh(float8 'infinity');
267268
SELECT acosh(float8 '-infinity');
@@ -274,7 +275,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/float8.out --labe
274275
SELECT acosh(float8 'nan');
275276
acosh
276277
-------
277-
@@ -781,9 +777,17 @@
278+
@@ -781,9 +781,17 @@
278279
(1 row)
279280

280281
SELECT atanh(float8 'infinity');
@@ -294,7 +295,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/float8.out --labe
294295
SELECT atanh(float8 'nan');
295296
atanh
296297
-------
297-
@@ -803,50 +807,15 @@
298+
@@ -803,50 +811,15 @@
298299
(1.2e-17), (2.3e-13), (1.2e-9),
299300
(0.45), (1.1), (2.1), (3.4), (6), (28),
300301
(float8 'infinity'), (float8 'nan')) AS t(x);
@@ -348,7 +349,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/float8.out --labe
348349
DROP TABLE FLOAT8_TBL;
349350
-- Check the float8 values exported for use by other tests
350351
SELECT * FROM FLOAT8_TBL;
351-
@@ -867,7 +836,7 @@
352+
@@ -867,7 +840,7 @@
352353
(1 row)
353354

354355
SELECT '32767.6'::float8::int2;
@@ -357,7 +358,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/float8.out --labe
357358
SELECT '-32768.4'::float8::int2;
358359
int2
359360
--------
360-
@@ -875,7 +844,7 @@
361+
@@ -875,7 +848,7 @@
361362
(1 row)
362363

363364
SELECT '-32768.6'::float8::int2;
@@ -366,7 +367,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/float8.out --labe
366367
SELECT '2147483647.4'::float8::int4;
367368
int4
368369
------------
369-
@@ -883,7 +852,7 @@
370+
@@ -883,7 +856,7 @@
370371
(1 row)
371372

372373
SELECT '2147483647.6'::float8::int4;
@@ -375,7 +376,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/float8.out --labe
375376
SELECT '-2147483648.4'::float8::int4;
376377
int4
377378
-------------
378-
@@ -891,7 +860,7 @@
379+
@@ -891,7 +864,7 @@
379380
(1 row)
380381

381382
SELECT '-2147483648.6'::float8::int4;
@@ -384,7 +385,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/float8.out --labe
384385
SELECT '9223372036854773760'::float8::int8;
385386
int8
386387
---------------------
387-
@@ -899,52 +868,26 @@
388+
@@ -899,52 +872,26 @@
388389
(1 row)
389390

390391
SELECT '9223372036854775807'::float8::int8;
@@ -444,7 +445,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/float8.out --labe
444445
SELECT x,
445446
tand(x),
446447
tand(x) IN ('-Infinity'::float8,-1,0,
447-
@@ -954,79 +897,117 @@
448+
@@ -954,79 +901,117 @@
448449
1,'Infinity'::float8) AS cotd_exact
449450
FROM (VALUES (0), (45), (90), (135), (180),
450451
(225), (270), (315), (360)) AS t(x);
@@ -604,7 +605,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/float8.out --labe
604605
-- float8: seeeeeee eeeeeeee eeeeeeee mmmmmmmm mmmmmmmm(x4)
605606
-- we don't care to assume the platform's strtod() handles subnormals
606607
-- correctly; those are "use at your own risk". However we do test
607-
@@ -1051,28 +1032,7 @@
608+
@@ -1051,28 +1036,7 @@
608609
from (select bits::bigint::xfloat8::float8 as flt
609610
from testdata
610611
offset 0) s;
@@ -634,7 +635,7 @@ diff -U3 --label=/mnt/data1/postgres/src/test/regress/expected/float8.out --labe
634635
-- round-trip tests
635636
with testdata(bits) as (values
636637
(x'0000000000000000'),
637-
@@ -1220,225 +1180,9 @@
638+
@@ -1220,225 +1184,9 @@
638639
from (select bits::bigint::xfloat8::float8 as flt
639640
from testdata
640641
offset 0) s;

0 commit comments

Comments
 (0)