Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE] "Error 2006: MySQL server has gone away" while executing mysqli prepared statements #653

Closed
3 tasks
slatyshev opened this issue Jun 2, 2023 · 1 comment · Fixed by #658
Closed
3 tasks
Assignees

Comments

@slatyshev
Copy link

slatyshev commented Jun 2, 2023

Describe the bug
I received "Error 2006: MySQL server has gone away" when trying to execute a prepared statement in my PHP code using mysqli via AcraServer. To reproduce the issue, you should pass "null" as one of the arguments with type "i" (integer). When I execute the query directly to MySQL, it works fine.

To Reproduce
Steps to reproduce the behavior:

  1. Create a schema and a table in your MySQL database (the table should have at least one numeric column).
  2. Connect to an acra-server via mysqli_connect in your PHP code.
  3. Create a SELECT prepared statement with a searching condition by the numeric field.
  4. Bind "null" to the field of your prepared statement.
  5. Execute the statement, get "false" as a result, and receive "Error 2006: MySQL server has gone away" from mysqli_errno and mysqli_error functions.

You can use the archive I attached to the report to reproduce it via docker: docker compose up test-php

Expected behavior
No errors occur. MySQL considers the result of comparison with "null" as FALSE.

Acra configuration files
For launching AcraServer from docker-compose.yml:

   # Acra
  test-acra-keymaker_client:
    image: cossacklabs/acra-keymaker:latest
    network_mode: "none"
    environment:
      ACRA_MASTER_KEY: N0MyZEVCRGY1cHA4ODRSVHp3c3BNeGtDekxaV3BhTHI=
    volumes:
      - ./:/keys
    command: >-
      --client_id="SomeId"
      --generate_acrawriter_keys
      --generate_hmac_key
      --keys_output_dir=/keys/acra-server
      --keys_public_output_dir=/keys/acra-server
      --keystore=v1

  test-acra-server:
    image: cossacklabs/acra-server:latest
    depends_on:
      - test-acra-keymaker_client
      - test-mysql
    ports:
      - "9393:9393"
      - "6060:6060"
    environment:
      ACRA_MASTER_KEY: N0MyZEVCRGY1cHA4ODRSVHp3c3BNeGtDekxaV3BhTHI=
    volumes:
      - ./acra-server:/keys:ro
      - ./config.yml:/config.yml
    command: >-
      --encryptor_config_file=/config.yml
      --client_id="SomeId"
      --mysql_enable
      --db_host=test-mysql
      --db_port=3306
      --keys_dir=/keys
      --keystore_cache_size=-1
      --keystore_cache_on_start_enable=false
      -ds
      -v
      -d

For AcraServer encryption (it can be omitted, though):

schemas:
  - table: test_table
    columns:
      - id
      - foo
      - bar
    encrypted:
      - column: foo
        searchable: true

Environment (please complete the following information):

  • Acra version: 0.95.0
  • Database server and its version: MySQL 8.0.33
  • Programming language: PHP 7.4
  • Installed components:
    • AcraServer
  • Data-in-transit encryption between Acra and the client-side application:
    • no transport encryption
  • Installation way:
    • via Docker

Additional context
You can quickly reproduce the error by launching docker compose up test-php from this archive:
issue.zip

@vixentael
Copy link
Collaborator

Thank you @slatyshev we put it in a queue to test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants