Repository navigation
Closed
Labels
kind/bugSomething isn't working
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main, 3.0
Commit ID
latest
Other Environment Information
- Hardware parameters:
- OS type:
- Others:Actual Behavior
When injecting random retry errors in LockRows, the system hits multiple failures during retries/rollback of nested SQL. Symptoms include:
- panic: slice bounds out of range in disttae.(*Transaction).adjustUpdateOrderLocked
- panic: assignment to entry in nil map in txn/client.(*runSQLTracker).enterToken
- auto_incrment column constant value overflows bigint unsigned
- FATAL: read incr record invalid in incrservice/store_sql.go
These appear correlated with retry/rollback paths and suggest nested SQL execution/cleanup and auto‑increment allocation are not robust under retries.
Steps to Reproduce:
-
Inject retry in pkg/sql/colexec/lockop/lock_op.go:
if rand.Int()%100 < 5 {
return moerr.NewTxnNeedRetryWithDefChangedNoCtx()
} -
Build and run:
make -j4
./mo-service -debug-http=:11235 -launch etc/launch/launch.toml > log.log -
Execute:
./venv/bin/python issue.py
#!/usr/bin/env python3
"""
Reproduction script for fulltext_bm25 test case.
This script continuously executes the SQL statements from fulltext_bm25.sql
to reproduce the panic issue.
"""
import sys
import os
import time
import signal
from datetime import datetime
# Add the clients/python directory to the path to import matrixone
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'clients', 'python'))
from matrixone import Client
from matrixone.exceptions import ConnectionError
class FulltextBM25Repro:
"""Reproduction script for fulltext_bm25 test case."""
def __init__(self):
self.running = True
self.iteration = 0
self.success_count = 0
self.error_count = 0
self.start_time = datetime.now()
# SQL statements to execute
self.sql_statements = [
"drop table if exists t1;",
"create table t1(a int primary key, b varchar(200));",
'insert into t1 select result, "test create big fulltext index" from generate_series(3840001) g;',
"create fulltext index ftidx on t1 (b);",
"select count(*) from t1 where match(b) against ('test create' in natural language mode);",
"drop table t1;"
]
# Setup signal handler for graceful shutdown
signal.signal(signal.SIGINT, self.signal_handler)
signal.signal(signal.SIGTERM, self.signal_handler)
def signal_handler(self, signum, frame):
"""Handle interrupt signals gracefully."""
print(f"\n\n⚠️ Received signal {signum}, shutting down gracefully...")
self.running = False
def get_connection_params(self):
"""Get connection parameters from environment variables or use defaults."""
return {
'host': os.getenv('MATRIXONE_HOST', 'localhost'),
'port': int(os.getenv('MATRIXONE_PORT', '6001')),
'user': os.getenv('MATRIXONE_USER', 'root'),
'password': os.getenv('MATRIXONE_PASSWORD', '111'),
'database': os.getenv('MATRIXONE_DATABASE', 'test')
}
def execute_sql_statements(self, client):
"""Execute all SQL statements in sequence."""
for i, sql in enumerate(self.sql_statements, 1):
try:
print(f" [{i}/{len(self.sql_statements)}] Executing: {sql[:60]}...")
result = client.execute(sql)
# For SELECT statements, fetch and display results
if sql.strip().upper().startswith('SELECT'):
rows = result.fetchall()
if rows:
print(f" Result: {rows[0][0]}")
# Small delay between statements
time.sleep(0.1)
except Exception as e:
print(f" ❌ Error executing SQL: {e}")
raise
def run_iteration(self):
"""Run one complete iteration of the test."""
self.iteration += 1
print(f"\n{'='*80}")
print(f"Iteration #{self.iteration} - {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
print(f"{'='*80}")
client = None
try:
# Get connection parameters
params = self.get_connection_params()
# Create and connect client
client = Client()
client.connect(
host=params['host'],
port=params['port'],
user=params['user'],
password=params['password'],
database=params['database']
)
# Execute all SQL statements
self.execute_sql_statements(client)
# Success
self.success_count += 1
print(f"✅ Iteration #{self.iteration} completed successfully")
except ConnectionError as e:
self.error_count += 1
print(f"❌ Iteration #{self.iteration} failed - Connection error: {e}")
print(" Waiting 5 seconds before retry...")
time.sleep(5)
except Exception as e:
self.error_count += 1
print(f"❌ Iteration #{self.iteration} failed - Error: {e}")
print(f" Error type: {type(e).__name__}")
import traceback
traceback.print_exc()
# Wait a bit before retrying
print(" Waiting 2 seconds before retry...")
time.sleep(2)
finally:
# Cleanup connection
if client:
try:
client.disconnect()
except:
pass
def print_statistics(self):
"""Print current statistics."""
elapsed = (datetime.now() - self.start_time).total_seconds()
total = self.success_count + self.error_count
success_rate = (self.success_count / total * 100) if total > 0 else 0
print(f"\n{'='*80}")
print("Statistics:")
print(f" Total iterations: {self.iteration}")
print(f" Successful: {self.success_count}")
print(f" Failed: {self.error_count}")
print(f" Success rate: {success_rate:.2f}%")
print(f" Elapsed time: {elapsed:.2f} seconds")
if self.iteration > 0:
print(f" Average time per iteration: {elapsed/self.iteration:.2f} seconds")
print(f"{'='*80}\n")
def run(self, max_iterations=None, delay=1):
"""
Run the reproduction script.
Args:
max_iterations: Maximum number of iterations (None for infinite)
delay: Delay in seconds between iterations
"""
print("🚀 Starting Fulltext BM25 Reproduction Script")
print(f" Max iterations: {max_iterations or 'Infinite'}")
print(f" Delay between iterations: {delay} seconds")
print(f" Press Ctrl+C to stop gracefully\n")
try:
while self.running:
# Check if we've reached max iterations
if max_iterations and self.iteration >= max_iterations:
print(f"\n✅ Reached maximum iterations ({max_iterations})")
break
# Run one iteration
self.run_iteration()
# Print statistics every 10 iterations
if self.iteration % 10 == 0:
self.print_statistics()
# Delay before next iteration
if self.running and (not max_iterations or self.iteration < max_iterations):
time.sleep(delay)
except KeyboardInterrupt:
print("\n\n⚠️ Interrupted by user")
finally:
# Print final statistics
print("\n" + "="*80)
print("Final Statistics:")
self.print_statistics()
print("👋 Script terminated")
def main():
"""Main function."""
import argparse
parser = argparse.ArgumentParser(
description='Reproduction script for fulltext_bm25 test case',
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
# Run infinite iterations with 1 second delay
python repro_fulltext_bm25.py
# Run 100 iterations
python repro_fulltext_bm25.py --max-iterations 100
# Run with custom delay
python repro_fulltext_bm25.py --delay 5
# Use custom connection parameters via environment variables
export MATRIXONE_HOST=localhost
export MATRIXONE_PORT=6001
export MATRIXONE_USER=root
export MATRIXONE_PASSWORD=111
export MATRIXONE_DATABASE=test
python repro_fulltext_bm25.py
"""
)
parser.add_argument(
'--max-iterations',
type=int,
default=None,
help='Maximum number of iterations to run (default: infinite)'
)
parser.add_argument(
'--delay',
type=float,
default=1.0,
help='Delay in seconds between iterations (default: 1.0)'
)
args = parser.parse_args()
# Create and run the reproduction script
repro = FulltextBM25Repro()
repro.run(max_iterations=args.max_iterations, delay=args.delay)
if __name__ == '__main__':
main()
- Observe panics/FATAL/out‑of‑range errors.
Expected Behavior
No response
Steps to Reproduce
see aboveAdditional information
No response
Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't working
Activity