You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "Revolyssup (via GitHub)" <gi...@apache.org> on 2025/10/28 18:26:10 UTC

[PR] chore: remove fast return to flush current queue log data during shutdown [apisix]

Revolyssup opened a new pull request, #12711:
URL: https://github.com/apache/apisix/pull/12711

   
   - [ ] I have explained the need for this PR and the problem it solves
   - [ ] I have explained the changes or the new features added to this PR
   - [ ] I have added tests corresponding to this change
   - [ ] I have updated the documentation to reflect this change
   - [ ] I have verified that this change is backward compatible (If not, please discuss on the [APISIX mailing list](https://github.com/apache/apisix/tree/master#community) first)
   
   <!--
   
   Note
   
   1. Mark the PR as draft until it's ready to be reviewed.
   2. Always add/update tests for any changes unless you have a good reason.
   3. Always update the documentation to reflect the changes made in the PR.
   4. Make a new commit to resolve conversations instead of `push -f`.
   5. To resolve merge conflicts, merge master instead of rebasing.
   6. Use "request review" to notify the reviewer after making changes.
   7. Only a reviewer can mark a conversation as resolved.
   
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore: remove fast return to flush current queue log data during shutdown [apisix]

Posted by "Revolyssup (via GitHub)" <gi...@apache.org>.
Revolyssup commented on PR #12711:
URL: https://github.com/apache/apisix/pull/12711#issuecomment-3472303210

   ## Test to check number of logs match number of requests with reloads
   ```bash
   #!/bin/bash
   
   # Configurable variables
   DURATION_HOURS=${1:-1}  # Default to 1 hour if no argument provided
   RELOAD_INTERVAL=10
   LOG_FILE="logs/file.log"
   
   # Calculate duration in seconds
   DURATION_SECONDS=$((DURATION_HOURS * 3600))
   
   # Initialize counters
   START_TIME=$(date +%s)
   END_TIME=$((START_TIME + DURATION_SECONDS))
   
   echo "Starting test for $DURATION_HOURS hour(s) ($DURATION_SECONDS seconds)"
   echo "Start time: $(date)"
   echo "End time: $(date -d "@$END_TIME")"
   echo "Reload interval: $RELOAD_INTERVAL seconds"
   echo "Log file: $LOG_FILE"
   echo "----------------------------------------"
   
   # Create log file if it doesn't exist
   mkdir -p "$(dirname "$LOG_FILE")"
   touch "$LOG_FILE"
   
   # Get initial line count
   INITIAL_LINE_COUNT=$(wc -l < "$LOG_FILE" 2>/dev/null || echo 0)
   echo "Initial line count in log: $INITIAL_LINE_COUNT"
   
   # Create a temporary file for request counting
   REQUEST_FILE=$(mktemp)
   echo "Request count file: $REQUEST_FILE"
   
   # Function to send curl requests
   send_requests() {
       local count=0
       while [ $(date +%s) -lt $END_TIME ]; do
           curl -s "http://localhost:9080" > /dev/null 2>&1
           count=$((count + 1))
           echo "request" >> "$REQUEST_FILE"
           # Small delay to prevent overwhelming the system
           sleep 0.1
       done
       echo "Sent $count requests"
   }
   
   # Function to perform reloads
   perform_reloads() {
       while [ $(date +%s) -lt $END_TIME ]; do
           sleep $RELOAD_INTERVAL
           if [ $(date +%s) -lt $END_TIME ]; then
               echo "$(date): Performing make reload..."
               make reload > /dev/null 2>&1
           fi
       done
   }
   
   # Start the reload process in background
   perform_reloads &
   RELOAD_PID=$!
   
   # Start the request sender in foreground (so we can count properly)
   echo "Starting request sender..."
   send_requests &
   REQUEST_PID=$!
   
   # Wait for the duration or until the request sender finishes
   echo "Test running... (PID: $REQUEST_PID, $RELOAD_PID)"
   wait $REQUEST_PID
   
   # Kill reload process if it's still running
   kill $RELOAD_PID 2>/dev/null
   wait $RELOAD_PID 2>/dev/null
   
   echo "----------------------------------------"
   echo "Test completed at: $(date)"
   
   # Wait a moment for any pending log writes
   sleep 10
   
   # Get final line count
   FINAL_LINE_COUNT=$(wc -l < "$LOG_FILE" 2>/dev/null || echo 0)
   LINES_ADDED=$((FINAL_LINE_COUNT - INITIAL_LINE_COUNT))
   
   # Count the number of requests from the temporary file
   REQUEST_COUNT=$(wc -l < "$REQUEST_FILE" 2>/dev/null || echo 0)
   
   echo "Final line count in log: $FINAL_LINE_COUNT"
   echo "Lines added during test: $LINES_ADDED"
   echo "Total curl requests sent: $REQUEST_COUNT"
   
   # Clean up temporary file
   rm -f "$REQUEST_FILE"
   
   # Compare results
   if [ $LINES_ADDED -eq $REQUEST_COUNT ]; then
       echo "✅ SUCCESS: Number of log lines ($LINES_ADDED) matches number of requests ($REQUEST_COUNT)"
       exit 0
   else
       echo "❌ FAILURE: Number of log lines ($LINES_ADDED) does not match number of requests ($REQUEST_COUNT)"
       echo "Difference: $((REQUEST_COUNT - LINES_ADDED))"
       exit 1
   fi
   
   ```
   
   ## Test result
   ```bash
   Fri Oct 31 03:28:05 PM IST 2025: Performing make reload...
   Fri Oct 31 03:28:15 PM IST 2025: Performing make reload...
   Fri Oct 31 03:28:26 PM IST 2025: Performing make reload...
   Fri Oct 31 03:28:37 PM IST 2025: Performing make reload...
   Sent 29079 requests
   ----------------------------------------
   Test completed at: Fri Oct 31 03:28:42 PM IST 2025
   Final line count in log: 29732
   Lines added during test: 29079
   Total curl requests sent: 29079
   ✅ SUCCESS: Number of log lines (29079) matches number of requests (29079)
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] chore: remove fast return to flush current queue log data during shutdown [apisix]

Posted by "nic-6443 (via GitHub)" <gi...@apache.org>.
nic-6443 merged PR #12711:
URL: https://github.com/apache/apisix/pull/12711


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org