Panic after trying to save to Azure Storage Blob
User was backing up DB to Azure Storage Blob, led to Panic:
I181029 15:16:33.807340 1576310 util/mon/bytes_usage.go:608 flow: bytes usage increases to 1.0 MiB (+10240)
I181029 15:16:34.095794 1576310 util/mon/bytes_usage.go:608 distsql: bytes usage increases to 2.0 MiB (+10240)
I181029 15:16:34.101021 1576310 util/mon/bytes_usage.go:608 flow: bytes usage increases to 2.0 MiB (+10240)
W181029 15:16:35.608421 1576231 sql/pgwire/server.go:486 [n1,client=192.168.50.21:23458] unknown configuration parameter: "ssl_renegotiation_limit"
I181029 15:16:38.065097 587 server/status/runtime.go:465 [n1] runtime stats: 13 GiB RSS, 442 goroutines, 188 MiB/1.9 GiB/2.3 GiB GO alloc/idle/total, 8.7 GiB/10 GiB CGO alloc/total, 185.0 CGO/sec, 45.5/15.3 %(u/s)time, 0.0 %gc (2x), 8.9 MiB/6.7 MiB (r/w)net
panic: illegal base64 data at input byte 61
goroutine 1576552 [running]:
github.com/cockroachdb/cockroach/vendor/github.com/Azure/azure-storage-blob-go/{{timestampe}}.NewSharedKeyCredential(0xc42b19e6e0, 0x12, 0xc4829f6ea0, 0x58, 0xc425f3e100)
/go/src/github.com/cockroachdb/cockroach/vendor/github.com/Azure/azure-storage-blob-go/2017-07-29/azblob/zc_credential_shared_key.go:23 +0x11c
github.com/cockroachdb/cockroach/pkg/ccl/storageccl.makeAzureStorage(0xc4960bc380, 0xc4202b1980, 0x0, 0x0, 0x5, 0x0)
/go/src/github.com/cockroachdb/cockroach/pkg/ccl/storageccl/export_storage.go:765 +0x6b
github.com/cockroachdb/cockroach/pkg/ccl/storageccl.MakeExportStorage(0x2ff8b00, 0xc43ed66720, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc4960bc380, ...)
The error shows:
panic: illegal base64 data at input byte 61
User issued the following commands (anonymized - ping me for originals if needed):
BACKUP DATABASE <databaseName> TO 'azure://<blobname>.blob.core.windows.net/backups?AZURE_ACCOUNT_KEY=key omitted==&AZURE_ACCOUNT_NAME=<AzureAccountName>' AS OF SYSTEM TIME '-10s';
Cockroach responded:
warning: connection lost!
opening new connection: all session settings will be lost
driver: bad connection
warning: connection lost!
opening new connection: all session settings will be lost
warning: error retrieving the transaction status: dial tcp <IP ADDRESS>:26257: connectex: No connection could be made because the target machine actively refused it.
warning: connection lost!
opening new connection: all session settings will be lost
warning: error retrieving the database name: dial tcp <IP ADDRESS>:26257: connectex: No connection could be made because the target machine actively refused it.
warning: connection lost!
opening new connection: all session settings will be lost
warning: error retrieving the transaction status: dial tcp <IP ADDRESS>:26257: connectex: No connection could be made because the target machine actively refused it.
This is backup (bulk I/O), not CDC.
This is happening for two reasons. 1) The Azure SDK panics instead of returning an error. The attached PR fixes that problem and will be backported to the 2.1 branch. 2) The user is entering bad data. See the note at https://www.cockroachlabs.com/docs/v2.0/import.html#import-file-urls about encodeURIComponent. They should run that function on their azure credentials and try again and it may succeed.
Hey @mjibson - does the entire URL need to be encoded or just the querystring? This is being run from CLI, so should it be
azure://<blobname>.blob.core.windows.net/backups?AZURE_ACCOUNT_KEY%3Dkey%20omitted%3D%3D%26AZURE_ACCOUNT_NAME%3D%3CAzureAccountName%3E
or
azure%3A%2F%2F%3Cblobname%3E.blob.core.windows.net%2Fbackups%3FAZURE_ACCOUNT_KEY%253Dkey%2520omitted%253D%253D%2526AZURE_ACCOUNT_NAME%253D%253CAzureAccountName%253E
?
I believe the former but wanted to confirm.
each parameter of the query string needs to be endoded. For AZURE_KEY=blah&AZURE_NAME=foo you would need to encode blah and foo separately.
Reopening since the client reports this is still happening after encoding - @roncrdb has the details.
@mjibson, user is correctly encoding params, but still seeing the panic happen when he runs the BACKUP DATABASE command.