imap_metadata plugin panic

Elisamuel Resto sam at samresto.dev
Wed Mar 23 12:25:41 UTC 2022


Hi,

So I have waited to see what comes in updates and while it hasn't been 
fixed on my end, it at least doesn't panic anymore and properly errors 
out. This error has only happened when deleting folders. No other action 
I do from day to day has triggered this in the logs that I can see.

Mar 23 07:13:57 wyvern dovecot[148148]: dict(454663): Error: metadata: 
dict_iterate() failed: sql dict iterate failed for 
priv/90da1903dab0c2614f0d0100a07d9965/: Key continues past the matched 
pattern priv/$
Mar 23 07:13:57 wyvern dovecot[148148]: 
imap(sam at samresto.dev)<453545><TYbKeteaFu0gAQRwHxEChGW9kEtbStsB>: Error: 
Mailbox Trash/2009: dict_iterate(priv/90da1903dab0c2614f0d0100a07d9965/) 
failed: dict-server returned failure: sql dict iterate failed for 
priv/90da1903dab0c2614f0d0100a07d9965/: Key continues past the matched 
pattern priv/$ (reply took 0.035 secs (0.036 in dict wait, 0.000 in 
other ioloops, 0.000 in locks, async-id reply 0.000 secs ago, started on 
dict-server 0.009 secs ago, took 0.009 secs))

The configurations have not changed much (if at all), but I have 
attached them for reference. I would love to be able to delete folders 
again.


Regards,
Elisamuel Resto

On 11/15/2021 12:27 PM, Elisamuel Resto wrote:
> Hello,
>
> This may be covered somewhere but recently I enabled the metadata 
> plugin to work with sieve as part of some updates I did a while back 
> and I hadn't checked my logs for any issues with it and so far they're 
> not completely taking my system down.
>
> Right now, upon trying to delete a folder I noticed the following in 
> my logs... what am I missing? I see the broken SQL query, but I don't 
> know enough about the dict system or the metadata plugin to know how 
> to add the missing information or fix it otherwise.
>
> Regards,
> Elisamuel Resto
>
>
> Nov 15 12:19:19 wyvern dovecot[461]: dict(51438): Panic: lib-sql: Too 
> many bind args (2) for statement: SELECT meta_key FROM metadata WHERE 
> meta_key LIKE  AND username = ?
> Nov 15 12:19:19 wyvern dovecot[461]: dict(51438): Error: Raw 
> backtrace: /usr/lib/dovecot/libdovecot.so.0(backtrace_append+0x43) 
> [0x7f449789d073] -> 
> /usr/lib/dovecot/libdovecot.so.0(backtrace_get+0x20) [0x7f449789d190] 
> -> /usr/lib/dovecot/libdovecot.so.0(+0xfaf1f) [0x7f44978a9f1f] -> 
> /usr/lib/dovecot/libdovecot.so.0(+0xfafb1) [0x7f44978a9fb1] -> 
> /usr/lib/dovecot/libdovecot.so.0(+0x4cd20) [0x7f44977fbd20] -> 
> dovecot/dict [0 clients, 0 lookups:0/0/0/0, 0 iters:0/0/0/0, 0 
> commits:0/0/0/0](+0x875a) [0x555e60d7775a] -> dovecot/dict [0 clients, 
> 0 lookups:0/0/0/0, 0 iters:0/0/0/0, 0 
> commits:0/0/0/0](sql_statement_query+0x42) [0x555e60d7f262] -> 
> dovecot/dict [0 clients, 0 lookups:0/0/0/0, 0 iters:0/0/0/0, 0 
> commits:0/0/0/0](+0xd97f) [0x555e60d7c97f] -> 
> /usr/lib/dovecot/libdovecot.so.0(dict_iterate_values+0x25) 
> [0x7f4497868615] -> dovecot/dict [0 clients, 0 lookups:0/0/0/0, 0 
> iters:0/0/0/0, 0 commits:0/0/0/0](+0xa929) [0x555e60d79929] -> 
> dovecot/dict [0 clients, 0 lookups:0/0/0/0, 0 iters:0/0/0/0, 0 
> commits:0/0/0/0](+0xb224) [0x555e60d7a224] -> dovecot/dict [0 clients, 
> 0 lookups:0/0/0/0, 0 iters:0/0/0/0, 0 commits:0/0/0/0](+0xb381) 
> [0x555e60d7a381] -> dovecot/dict [0 clients, 0 lookups:0/0/0/0, 0 
> iters:0/0/0/0, 0 commits:0/0/0/0](dict_command_input+0xd9) 
> [0x555e60d7a579] -> dovecot/dict [0 clients, 0 lookups:0/0/0/0, 0 
> iters:0/0/0/0, 0 commits:0/0/0/0](+0x95b8) [0x555e60d785b8] -> 
> /usr/lib/dovecot/libdovecot.so.0(connection_input_default+0x15e) 
> [0x7f44978a16ce] -> 
> /usr/lib/dovecot/libdovecot.so.0(io_loop_call_io+0x6b) 
> [0x7f44978bfebb] -> 
> /usr/lib/dovecot/libdovecot.so.0(io_loop_handler_run_internal+0x13b) 
> [0x7f44978c15cb] -> 
> /usr/lib/dovecot/libdovecot.so.0(io_loop_handler_run+0x51) 
> [0x7f44978bff61] -> /usr/lib/dovecot/libdovecot.so.0(io_loop_run+0x41) 
> [0x7f44978c0131] -> 
> /usr/lib/dovecot/libdovecot.so.0(master_service_run+0x14) 
> [0x7f4497831f74] -> dovecot/dict [0 clients, 0 lookups:0/0/0/0, 0 
> iters:0/0/0/0, 0 commits:0/0/0/0](main+0x189) [0x555e60d78139] -> 
> /usr/lib/libc.so.6(__libc_start_main+0xd5) [0x7f44972cfb25] -> 
> dovecot/dict [0 clients, 0 lookups:0/0/0/0, 0 iters:0/0/0/0, 0 
> commits:0/0/0/0](_start+0x2e) [0x555e60d7819e]
> Nov 15 12:19:19 wyvern dovecot[461]: 
> imap(sam at samresto.dev)<51449><+BGq2NfQM/7Pisr9>: Error: Mailbox 
> Trash/Processed: dict_iterate(priv/c841ad0291c27461ac670100a07d9965/) 
> failed: Connection closed (reply took 0.204 secs (0.204 in dict wait, 
> 0.000 in other ioloops, 0.000 in locks))
> Nov 15 12:19:19 wyvern dovecot[461]: dict(51438): Fatal: master: 
> service(dict): child 51438 killed with signal 6 (core dumped)
>
-------------- next part --------------
# 2.3.18 (9dd8408c18): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.18 (0bc28b32)
# OS: Linux 5.16.15-arch1-1 x86_64  ext4
# Hostname: wyvern.simplysam.us
auth_mechanisms = plain login
dict {
  lastlogin = mysql:/etc/dovecot/dovecot-lastlogin-dict.conf.ext
  metadata = mysql:/etc/dovecot/dovecot-metadata-dict.conf.ext
  quota_clone = mysql:/etc/dovecot/dovecot-quota-dict.conf.ext
}
doveadm_worker_count = 5
first_valid_gid = 5000
first_valid_uid = 5000
imap_client_workarounds = delay-newmail tb-extra-mailbox-sep tb-lsub-flags
last_valid_gid = 5000
last_valid_uid = 5000
lda_mailbox_autocreate = yes
lda_mailbox_autosubscribe = yes
lda_original_recipient_header = X-Original-To
lmtp_client_workarounds = whitespace-before-path
lmtp_rcpt_check_quota = yes
lmtp_save_to_detail_mailbox = yes
mail_attachment_detection_options = add-flags-on-save
mail_attribute_dict = proxy::metadata
mail_gid = 5000
mail_home = /var/mail/virtual/%Ld/%Ln
mail_location = maildir:/var/mail/virtual/%Ld/%Ln
mail_plugins = " quota quota_clone mailbox_alias trash fts fts_flatcurve"
mail_uid = 5000
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext spamtestplus virustest vnd.dovecot.pipe vnd.dovecot.filter
namespace inbox {
  inbox = yes
  location =
  mailbox Archive {
    auto = subscribe
    special_use = \Archive
  }
  mailbox Drafts {
    auto = subscribe
    special_use = \Drafts
  }
  mailbox Sent {
    auto = subscribe
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    auto = no
    special_use = \Sent
  }
  mailbox Spam {
    auto = subscribe
    autoexpunge = 30 days
    special_use = \Junk
  }
  mailbox Trash {
    auto = subscribe
    autoexpunge = 60 days
    special_use = \Trash
  }
  prefix =
  separator = /
  type = private
}
passdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
plugin {
  antispam_backend = pipe
  antispam_pipe_program = /usr/local/sbin/sa-learn-pipe
  antispam_pipe_program_notspam_arg = --ham
  antispam_pipe_program_spam_arg = --spam
  antispam_pipe_tmpdir = /tmp
  antispam_spam = Junk;Spam
  antispam_trash = trash;Trash;Deleted Items;Deleted Messages
  fts = flatcurve
  fts_autoindex = yes
  fts_autoindex_exclude = \Spam
  fts_autoindex_exclude2 = \Trash
  fts_enforced = yes
  fts_flatcurve_commit_limit = 500
  fts_flatcurve_max_term_size = 30
  fts_flatcurve_min_term_size = 2
  fts_flatcurve_optimize_limit = 10
  fts_flatcurve_rotate_size = 5000
  fts_flatcurve_rotate_time = 5000
  fts_flatcurve_substring_search = yes
  fts_languages = en es
  fts_tokenizer_generic = algorithm=simple
  fts_tokenizers = generic email-address
  imapsieve_mailbox1_after = file:/var/lib/dovecot/sieve/report-spam.sieve
  imapsieve_mailbox1_causes = COPY
  imapsieve_mailbox1_name = Junk
  imapsieve_mailbox2_after = file:/var/lib/dovecot/sieve/report-spam.sieve
  imapsieve_mailbox2_causes = COPY
  imapsieve_mailbox2_name = Spam
  imapsieve_mailbox3_after = file:/var/lib/dovecot/sieve/report-ham.sieve
  imapsieve_mailbox3_causes = COPY
  imapsieve_mailbox3_from = Junk
  imapsieve_mailbox3_name = *
  imapsieve_mailbox4_after = file:/var/lib/dovecot/sieve/report-ham.sieve
  imapsieve_mailbox4_causes = COPY
  imapsieve_mailbox4_from = Spam
  imapsieve_mailbox4_name = *
  imapsieve_mailbox5_after = file:/var/lib/dovecot/sieve/report-ham.sieve
  imapsieve_mailbox5_causes = COPY
  imapsieve_mailbox5_name = Archive
  imapsieve_mailbox6_after = file:/var/lib/dovecot/sieve/mark-seen.sieve
  imapsieve_mailbox6_causes = COPY
  imapsieve_mailbox6_name = Trash
  imapsieve_url = sieve://wyvern.simplysam.us:4190
  last_login_dict = proxy::lastlogin
  last_login_key = # hidden, use -P to show it
  mailbox_alias_new = Sent Messages
  mailbox_alias_new2 = Sent Items
  mailbox_alias_new3 = Junk
  mailbox_alias_old = Sent
  mailbox_alias_old2 = Sent
  mailbox_alias_old3 = Spam
  quota = count:User quota
  quota_clone_dict = proxy::quota_clone
  quota_grace = 10%%
  quota_max_mail_size = 30M
  quota_rule = *:storage=1G
  quota_rule2 = Trash:ignore
  quota_rule3 = Spam:ignore
  quota_status_nouser = DUNNO
  quota_status_overquota = 552 5.2.2 Mailbox is full
  quota_status_success = DUNNO
  quota_vsizes = yes
  sieve = file:~/sieve;active=~/dovecot.sieve
  sieve_before = /var/lib/dovecot/sieve.d/
  sieve_extensions = +spamtestplus +virustest +vnd.dovecot.pipe +vnd.dovecot.filter
  sieve_max_redirects = 30
  sieve_plugins = sieve_extprograms
  sieve_vacation_send_from_recipient = yes
  trash = /etc/dovecot/dovecot-trash.conf.ext
}
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
pop3_enable_last = yes
pop3_reuse_xuidl = yes
protocols = imap pop3 lmtp sieve
quota_full_tempfail = yes
service auth-worker {
  user = $default_internal_user
}
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0660
    user = postfix
  }
  unix_listener auth-userdb {
    mode = 0666
  }
}
service dict {
  unix_listener dict {
    group = vmail
    mode = 0660
    user = vmail
  }
}
service imap-login {
  inet_listener imap {
    port = 143
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
  process_min_avail = 1
  service_count = 1
}
service lmtp {
  unix_listener /var/spool/postfix/private/dovecot-lmtp {
    group = postfix
    mode = 0600
    user = postfix
  }
  unix_listener lmtp {
    mode = 0666
  }
}
service managesieve-login {
  inet_listener sieve {
    port = 4190
  }
  process_min_avail = 1
  service_count = 1
}
service managesieve {
  process_limit = 20
}
service pop3-login {
  inet_listener pop3 {
    port = 110
  }
  inet_listener pop3s {
    port = 995
    ssl = yes
  }
}
service stats {
  unix_listener stats-reader {
    group = vmail
    mode = 0664
    user = vmail
  }
  unix_listener stats-writer {
    group = vmail
    mode = 0666
    user = vmail
  }
}
service submission-login {
  inet_listener submission {
    port = 587
  }
}
ssl_cert = </etc/letsencrypt/live/wyvern.simplysam.us/fullchain.pem
ssl_cipher_list = ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
ssl_dh = # hidden, use -P to show it
ssl_key = # hidden, use -P to show it
userdb {
  args = /etc/dovecot/dovecot-sql.conf.ext
  driver = sql
}
verbose_proctitle = yes
protocol lmtp {
  auth_username_format = %Lu
  mail_plugins = " quota quota_clone mailbox_alias trash fts fts_flatcurve sieve"
}
protocol !indexer-worker {
  mail_vsize_bg_after_count = 100
}
protocol lda {
  mail_plugins = " quota quota_clone mailbox_alias trash fts fts_flatcurve sieve"
}
protocol imap {
  imap_metadata = yes
  mail_plugins = " quota quota_clone mailbox_alias trash fts fts_flatcurve imap_quota last_login"
}
protocol sieve {
  mail_plugins =
}
protocol pop3 {
  mail_plugins = " quota quota_clone mailbox_alias trash fts fts_flatcurve last_login"
}
protocol submission {
  mail_plugins = " quota quota_clone mailbox_alias trash fts fts_flatcurve"
}
-------------- next part --------------
map {
        pattern = shared/last-login/$user
        table = lastlogin
        value_field = last_login
        value_type = uint

        fields {
                username = $user
        }
}
-------------- next part --------------
map {
        pattern = shared/$key
        table = metadata
        username_field = username
        value_field = meta_value

        fields {
                meta_key = $key
        }
}

map {
        pattern = priv/$key
        table = metadata
        username_field = username
        value_field = meta_value

        fields {
                meta_key = $key
        }
}
-------------- next part --------------
map {
        pattern = priv/quota/storage
        table = quota2
        username_field = username
        value_field = bytes
}

map {
        pattern = priv/quota/messages
        table = quota2
        username_field = username
        value_field = messages
}
-------------- next part --------------
driver = mysql
default_pass_scheme = SHA512-CRYPT

user_query = SELECT maildir, 5000 AS uid, 5000 AS gid, CONCAT('*:bytes=', quota) as quota_rule FROM mailbox WHERE username = '%Lu' AND active='1'
password_query = SELECT username AS user, password FROM mailbox WHERE username = '%Lu' AND active='1'
iterate_query = SELECT username AS user FROM mailbox
-------------- next part --------------
# Spam mailbox is emptied before Trash
1 Spam
# Trash mailbox is emptied before Sent
2 Trash
# If both Sent and "Sent Messages" mailboxes exist, the next oldest message
# to be deleted is looked up from both of the mailboxes.
3 Sent
3 Sent Messages


More information about the dovecot mailing list