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

Duplicate Entry Fatal Error in SQL Query When Running LWT Program #196

Open
voothi opened this issue Apr 7, 2024 · 1 comment
Open

Duplicate Entry Fatal Error in SQL Query When Running LWT Program #196

voothi opened this issue Apr 7, 2024 · 1 comment
Labels
bug Something isn't working database Database-related issues

Comments

@voothi
Copy link

voothi commented Apr 7, 2024

Describe the bug

Fatal Error in SQL Query: INSERT INTO _migrations VALUES ('19700101_000001_lwt_original.sql'), ('19700102_000001_lwt_fork.sql'), ('20231224_131202_missing_auto_increment.sql'), ('20240103_120316_2.10.0-fork.sql')

Error Code & Message: [1062] Duplicate entry '19700101_000001_lwt_original.sql' for key 'PRIMARY'

Backtrace:

#0 /var/www/html/lwt/inc/database_connect.php(63): do_mysqli_query('...')
#1 /var/www/html/lwt/inc/database_connect.php(1873): runsql('...', '')
#2 /var/www/html/lwt/inc/database_connect.php(2180): check_update_db(0, '', '...')
#3 /var/www/html/lwt/inc/session_utility.php(19): require_once('...')
#4 /var/www/html/lwt/do_text.php(20): require_once('...')

To Reproduce
Steps to reproduce the behavior:

  1. I installed LWT from docker on Debian 12 (VM Hyper-V). Everything is in default settings.
  2. http://vm1:8010/lwt/backup_restore.php -> Empty LWT Database
  3. Add German Language.
  4. Add Text.
  5. In READ ▶ So würde ich programmieren lernen 2024. -> Translations on/off.
  6. I see db error.

Expected behavior

Screenshots
image

Server (please complete)
You can copy/paste data from http://[.. your LWT installation]/server_data.php.
Server Data
Server
Data Value
LWT version v002010000
Web Server Apache/2.4.56 (Debian)
Server Software Apache/2.4.56
Server Location vm1:8010
PHP Version 8.1.27
Database
Data Value
Database name learning-with-texts
Database prefix (surrounded by "") ""
Database Size 0.1 MB
MySQL Version 10.7.8-MariaDB-1:10.7.8+maria~ubu2004
Client API
Data Value
REST API Version 0.1.1
REST API Release date 2023-12-29

Desktop (if necessary):

  • OS: Debian 12/Docker
  • Browser Chrome
  • Version ...

Smartphone (if necessary):

Additional context
LWT Backup
lwt-backup-exp_version-2024-04-07-08-00-08.sql.gz

@HugoFara HugoFara added bug Something isn't working database Database-related issues labels Apr 7, 2024
@HugoFara
Copy link
Owner

HugoFara commented Apr 7, 2024

That's quite an annoying issue, because I thought it fixed before publishing 2.10, yet it nothing critical. I hope reloading the page whenever it happens should be enough.

The cause of this issue is that version 2.10 implements are cleaner database system, yet backward compatible with the previous iterations of LWT, so it's not so cleaned. This issue appears when two scripts are trying to check the database for updates at the same time. One way to fix it definitely is to comment (or delete) the first lines of db/schema/baseline.sql:
https://github.com/HugoFara/lwt/blob/13b0d85f37f916c5df0e4fbed9fcfda8e40598a1/db/schema/baseline.sql#L4C1-L16C1

Once I get rid of $tbpref it won't appear anymore, but I think it's better if I publish a hacky fix before that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working database Database-related issues
Projects
None yet
Development

No branches or pull requests

2 participants