Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/workflows/update_golang_dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
go mod tidy

- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.CREATE_PR_VITESS_BOT }}
branch: "upgrade-go-deps-on-main"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update_golang_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:

- name: Create Pull Request
if: steps.detect-and-update.outputs.create-pr == 'true'
uses: peter-evans/create-pull-request@v4
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.CREATE_PR_VITESS_BOT }}
branch: "upgrade-go-to-${{steps.detect-and-update.outputs.go-version}}-on-${{ matrix.branch }}"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ $(PROTO_GO_OUTS): minimaltools install_protoc-gen-go proto/*.proto
# This rule builds the bootstrap images for all flavors.
DOCKER_IMAGES_FOR_TEST = mysql80 mysql84 percona80
DOCKER_IMAGES = common $(DOCKER_IMAGES_FOR_TEST)
BOOTSTRAP_VERSION=46
BOOTSTRAP_VERSION=47
ensure_bootstrap_version:
find docker/ -type f -exec sed -i "s/^\(ARG bootstrap_version\)=.*/\1=${BOOTSTRAP_VERSION}/" {} \;
sed -i 's/\(^.*flag.String(\"bootstrap-version\",\) *\"[^\"]\+\"/\1 \"${BOOTSTRAP_VERSION}\"/' test.go
Expand Down
2 changes: 1 addition & 1 deletion build.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
source ./tools/shell_functions.inc

go version >/dev/null 2>&1 || fail "Go is not installed or is not in \$PATH. See https://vitess.io/contributing/build-from-source for install instructions."
goversion_min 1.24.4 || echo "Go version reported: `go version`. Version 1.24.4+ recommended. See https://vitess.io/contributing/build-from-source for install instructions."
goversion_min 1.25.0 || echo "Go version reported: `go version`. Version 1.25.0+ recommended. See https://vitess.io/contributing/build-from-source for install instructions."

mkdir -p dist
mkdir -p bin
Expand Down
6 changes: 6 additions & 0 deletions changelog/23.0/23.0.0/summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,9 @@ ALTER USER 'vt_repl'@'%' IDENTIFIED WITH caching_sha2_password BY 'your-existing
```

In future Vitess versions, the `mysql_native_password` authentication plugin will be disabled for managed MySQL instances.

#### <a id="mysql-timezone-env"/>MySQL timezone environment propagation</a>

Fixed a bug where environment variables like `TZ` were not propagated from mysqlctl to the mysqld process.
As a result, timezone settings from the environment were previously ignored. Now mysqld correctly inherits environment variables.
⚠️ Deployments that relied on the old behavior and explicitly set a non-UTC timezone may see changes in how DATETIME values are interpreted. To preserve compatibility, set `TZ=UTC` explicitly in MySQL pods.
6 changes: 5 additions & 1 deletion docker/bootstrap/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,4 +182,8 @@ List of changes between bootstrap image versions.

## [46] - 2025-06-06
### Changes
- Update build to golang 1.24.4
- Update build to golang 1.24.4

## [47] - 2025-08-25
### Changes
- Update build to golang 1.25.0
2 changes: 1 addition & 1 deletion docker/bootstrap/Dockerfile.common
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=linux/amd64 golang:1.24.4-bookworm
FROM --platform=linux/amd64 golang:1.25.0-bookworm

# Install Vitess build dependencies
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
Expand Down
2 changes: 1 addition & 1 deletion docker/lite/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM --platform=linux/amd64 golang:1.24.4-bookworm AS builder
FROM --platform=linux/amd64 golang:1.25.0-bookworm AS builder

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER
Expand Down
2 changes: 1 addition & 1 deletion docker/lite/Dockerfile.mysql84
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM --platform=linux/amd64 golang:1.24.4-bookworm AS builder
FROM --platform=linux/amd64 golang:1.25.0-bookworm AS builder

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER
Expand Down
2 changes: 1 addition & 1 deletion docker/lite/Dockerfile.percona80
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM --platform=linux/amd64 golang:1.24.4-bookworm AS builder
FROM --platform=linux/amd64 golang:1.25.0-bookworm AS builder

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER
Expand Down
2 changes: 1 addition & 1 deletion docker/vttestserver/Dockerfile.mysql80
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM --platform=linux/amd64 golang:1.24.4-bookworm AS builder
FROM --platform=linux/amd64 golang:1.25.0-bookworm AS builder

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER
Expand Down
2 changes: 1 addition & 1 deletion docker/vttestserver/Dockerfile.mysql84
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM --platform=linux/amd64 golang:1.24.4-bookworm AS builder
FROM --platform=linux/amd64 golang:1.25.0-bookworm AS builder

# Allows docker builds to set the BUILD_NUMBER
ARG BUILD_NUMBER
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module vitess.io/vitess

go 1.24.4
go 1.25.0

require (
cloud.google.com/go/storage v1.54.0
Expand Down
2 changes: 1 addition & 1 deletion go/errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestUnwrap(t *testing.T) {
{
name: "double wrapped",
err: errors.Join(errors.Join(err1)),
expectUnwrap: []error{errors.Join(err1)},
expectUnwrap: []error{err1},
expectUnwrapAll: []error{err1},
expectUnwrapFirst: err1,
},
Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vtcombo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ Flags:
--query-log-stream-handler string URL handler for streaming queries log (default "/debug/querylog")
--query-timeout int Sets the default query timeout (in ms). Can be overridden by session variable (query_timeout) or comment directive (QUERY_TIMEOUT_MS)
--querylog-buffer-size int Maximum number of buffered query logs before throttling log output (default 10)
--querylog-emit-on-any-condition-met Emit to query log when any of the conditions (row-threshold, time-threshold, filter-tag) is met (default false)
--querylog-filter-tag string string that must be present in the query for it to be logged; if using a value as the tag, you need to disable query normalization
--querylog-format string format for query logs ("text" or "json") (default "text")
--querylog-mode string Mode for logging queries. "error" will only log queries that return an error. Otherwise all queries will be logged. (default "all")
Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vtgate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ Flags:
--purge-logs-interval duration how often try to remove old logs (default 1h0m0s)
--query-timeout int Sets the default query timeout (in ms). Can be overridden by session variable (query_timeout) or comment directive (QUERY_TIMEOUT_MS)
--querylog-buffer-size int Maximum number of buffered query logs before throttling log output (default 10)
--querylog-emit-on-any-condition-met Emit to query log when any of the conditions (row-threshold, time-threshold, filter-tag) is met (default false)
--querylog-filter-tag string string that must be present in the query for it to be logged; if using a value as the tag, you need to disable query normalization
--querylog-format string format for query logs ("text" or "json") (default "text")
--querylog-mode string Mode for logging queries. "error" will only log queries that return an error. Otherwise all queries will be logged. (default "all")
Expand Down
1 change: 1 addition & 0 deletions go/flags/endtoend/vttablet.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ Flags:
--publish-retry-interval duration how long vttablet waits to retry publishing the tablet record (default 30s)
--purge-logs-interval duration how often try to remove old logs (default 1h0m0s)
--query-log-stream-handler string URL handler for streaming queries log (default "/debug/querylog")
--querylog-emit-on-any-condition-met Emit to query log when any of the conditions (row-threshold, time-threshold, filter-tag) is met (default false)
--querylog-filter-tag string string that must be present in the query for it to be logged; if using a value as the tag, you need to disable query normalization
--querylog-format string format for query logs ("text" or "json") (default "text")
--querylog-mode string Mode for logging queries. "error" will only log queries that return an error. Otherwise all queries will be logged. (default "all")
Expand Down
81 changes: 64 additions & 17 deletions go/streamlog/streamlog.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"net/http"
"net/url"
"os"
"sort"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -63,13 +64,14 @@ const (
)

type QueryLogConfig struct {
RedactDebugUIQueries bool
FilterTag string
Format string
Mode string
RowThreshold uint64
TimeThreshold time.Duration
sampleRate float64
RedactDebugUIQueries bool
FilterTag string
Format string
Mode string
RowThreshold uint64
TimeThreshold time.Duration
sampleRate float64
EmitOnAnyConditionMet bool
}

var queryLogConfigInstance = QueryLogConfig{
Expand Down Expand Up @@ -114,6 +116,9 @@ func registerStreamLogFlags(fs *pflag.FlagSet) {

// QueryLogMode controls the mode for logging queries (all or error)
fs.StringVar(&queryLogConfigInstance.Mode, "querylog-mode", queryLogConfigInstance.Mode, `Mode for logging queries. "error" will only log queries that return an error. Otherwise all queries will be logged.`)

// EmitOnAnyConditionMet logs queries on any condition met (time/row/filtertag)
fs.BoolVar(&queryLogConfigInstance.EmitOnAnyConditionMet, "querylog-emit-on-any-condition-met", queryLogConfigInstance.EmitOnAnyConditionMet, "Emit to query log when any of the conditions (row-threshold, time-threshold, filter-tag) is met (default false)")
}

// StreamLogger is a non-blocking broadcaster of messages.
Expand All @@ -139,6 +144,17 @@ func New[T any](name string, size int) *StreamLogger[T] {
}
}

// helper function to compose both aCond and its reason and aggregate the result inal allMatches and reasons variable
func shouldEmitLogOnCondition(aCond bool, aReason string, allMatches bool, reasons []string) (bool, string, bool, []string) {
allMatches = allMatches || aCond
if aCond {
reasons = append(reasons, aReason)
return aCond, aReason, allMatches, reasons
} else {
return aCond, "", allMatches, reasons
}
}

// Send sends message to all the writers subscribed to logger. Calling
// Send does not block.
func (logger *StreamLogger[T]) Send(message T) {
Expand Down Expand Up @@ -271,21 +287,52 @@ func (qlConfig QueryLogConfig) shouldSampleQuery() bool {

// ShouldEmitLog returns whether the log with the given SQL query
// should be emitted or filtered
func (qlConfig QueryLogConfig) ShouldEmitLog(sql string, rowsAffected, rowsReturned uint64, totalTime time.Duration, hasError bool) bool {
if qlConfig.shouldSampleQuery() {
return true
// It also returns an EmitReason which is a comma-separated-string to indicate all the conditions triggered for log emit.
// If both TimeThreshold and FilterTag condition are met, EmitReason will be time,filtertag
func (qlConfig QueryLogConfig) ShouldEmitLog(sql string, rowsAffected, rowsReturned uint64, totalTime time.Duration, hasError bool) (bool, string) {
var aMatch, allMatches bool
var aReason string
reasons := []string{}

aMatch, aReason, allMatches, reasons = shouldEmitLogOnCondition(qlConfig.shouldSampleQuery(), "sample", allMatches, reasons)
if aMatch && !qlConfig.EmitOnAnyConditionMet {
return aMatch, aReason
}
if qlConfig.RowThreshold > max(rowsAffected, rowsReturned) && qlConfig.FilterTag == "" {
return false

if qlConfig.RowThreshold > 0 {
aMatch, _, allMatches, reasons = shouldEmitLogOnCondition(qlConfig.RowThreshold <= max(rowsAffected, rowsReturned), "row", allMatches, reasons)
if !aMatch && !qlConfig.EmitOnAnyConditionMet && qlConfig.FilterTag == "" {
return false, ""
}
}
if qlConfig.TimeThreshold > totalTime && qlConfig.TimeThreshold > 0 && qlConfig.FilterTag == "" {
return false

if qlConfig.TimeThreshold > 0 {
aMatch, _, allMatches, reasons = shouldEmitLogOnCondition(qlConfig.TimeThreshold <= totalTime, "time", allMatches, reasons)
if !aMatch && !qlConfig.EmitOnAnyConditionMet && qlConfig.FilterTag == "" {
return false, ""
}
}

if qlConfig.FilterTag != "" {
return strings.Contains(sql, qlConfig.FilterTag)
aMatch, aReason, allMatches, reasons = shouldEmitLogOnCondition(strings.Contains(sql, qlConfig.FilterTag), "filtertag", allMatches, reasons)
if !qlConfig.EmitOnAnyConditionMet {
return aMatch, aReason
}
}

if qlConfig.Mode == QueryLogModeError {
return hasError
aMatch, aReason, allMatches, reasons = shouldEmitLogOnCondition(hasError, "error", allMatches, reasons)
if !qlConfig.EmitOnAnyConditionMet {
return aMatch, aReason
}
}

// sort the array to make the reason string content deterministic
sort.Strings(reasons)
reasonStr := strings.Join(reasons, ",")
if qlConfig.EmitOnAnyConditionMet {
return allMatches, reasonStr
} else {
return true, reasonStr
}
return true
}
Loading
Loading