ai
SonarQube Analysis Troubleshooting แก้ปัญหา —

SonarQube Troubleshooting

SonarQube Analysis Troubleshooting แก้ปัญหา Scanner Config Memory OOM Coverage Quality Gate CI/CD GitHub GitLab Jenkins Production
เนื้อหาเกี่ยวข้อง — ไฟล์ ai คืออะไร
| ปัญหา | สาเหตุ | วิธีแก้ | Priority |
|---|---|---|---|
| Connection Refused | Server ไม่ทำงาน / URL ผิด / Firewall | ตรวจ URL Port Token Network | Critical |
| Scanner OOM | JVM Heap น้อยเกินไป / Project ใหญ่ | SONAR_SCANNER_OPTS=-Xmx4g | High |
| Coverage 0% | Report Path ผิด / Format ไม่ถูก | ตั้ง sonar.coverage.reportPaths | High |
| Analysis Timeout | Project ใหญ่ / Server ช้า / Network | เพิ่ม Timeout + Exclude ไฟล์ไม่จำเป็น | Medium |
| Quality Gate Fail | Code ไม่ผ่านเกณฑ์ที่ตั้ง | แก้ Issues หรือ ปรับ Quality Gate | Medium |
| Server OOM | CE/ES Memory ไม่พอ | เพิ่ม ce.javaOpts search.javaOpts | Critical |
Memory & Performance

# === Memory & Performance Tuning ===
# Scanner Memory
# export SONAR_SCANNER_OPTS="-Xmx4g -Xms1g"
# sonar-scanner
# Maven
# mvn sonar:sonar -Dsonar.host.url=http://sonarqube:9000 \
# -Dsonar.token=sqp_xxx \
# MAVEN_OPTS="-Xmx4g"
# Gradle
# ./gradlew sonar -Dsonar.host.url=http://sonarqube:9000 \
# -Dorg.gradle.jvmargs="-Xmx4g"
# Server Memory (sonar.properties)
# sonar.web.javaOpts=-Xmx2g -Xms1g -XX:+UseG1GC
# sonar.ce.javaOpts=-Xmx4g -Xms2g -XX:+UseG1GC
# sonar.search.javaOpts=-Xmx2g -Xms2g
@dataclass
class MemoryConfig:
component: str
default: str
recommended: str
when_to_increase: str
max: str
memory_configs = [
MemoryConfig("Scanner (SONAR_SCANNER_OPTS)",
"-Xmx512m",
"-Xmx2g-4g",
"Project > 500K LOC หรือ OOM Error",
"-Xmx8g (ขึ้นกับ Project Size)"),
MemoryConfig("Web Server (sonar.web.javaOpts)",
"-Xmx512m",
"-Xmx1g-2g",
"Server ช้า UI ไม่ตอบสนอง",
"-Xmx4g"),
MemoryConfig("Compute Engine (sonar.ce.javaOpts)",
"-Xmx512m",
"-Xmx2g-4g",
"Analysis Queue สะสม Background Task ช้า",
"-Xmx8g (สำคัญที่สุด)"),
MemoryConfig("Elasticsearch (sonar.search.javaOpts)",
"-Xmx512m",
"-Xmx1g-2g",
"Search ช้า Project เยอะ Index ใหญ่",
"-Xmx4g (ไม่เกิน 50% RAM)"),
MemoryConfig("Database Connection Pool",
"10",
"20-50",
"Connection Timeout หลาย Concurrent Analysis",
"100 (PostgreSQL max_connections)"),
]
print("=== Memory Config ===")
for m in memory_configs:
print(f" [{m.component}]")
print(f" Default: {m.default} → Recommended: {m.recommended}")
print(f" Increase when: {m.when_to_increase}")
print(f" Max: {m.max}")
เคล็ดลับ
- Exclusions: ตั้ง Exclusions ลด Scan Time ไม่ Scan vendor node_modules
- CE Memory: Compute Engine สำคัญที่สุด เพิ่ม Memory ก่อน
- PostgreSQL: ใช้ PostgreSQL สำหรับ Production ไม่ใช้ H2
- Webhook: ตั้ง Webhook สำหรับ Quality Gate ใน CI/CD
- Token: ใช้ Project Token แทน Global Token Least Privilege
ปัญหาที่พบบ่อยมีอะไร
Connection Refused OOM Coverage 0% Timeout Quality Gate Fail SCM Language Plugin Elasticsearch Database Duplicate False Positive
แนะนำเพิ่มเติม — เรียนเทรดกับ iCafeForex
เนื้อหาเกี่ยวข้อง — ทำความเข้าใจ Elixir Nerves IoT — ข้อมูลครบถ้วน 2026
เนื้อหาเกี่ยวข้อง — แนะนำให้อ่าน Web Components MLOps Workflow





