In article <1m40q40.be9cjllegby3m%[email protected]>, Emmanuel Dreyfus <[email protected]> wrote: >Hello > >I have a problem with Apache, that sometimes horribly dies with this >message: >Can't initialize threads: error 35 > >The strings is from libmysqlclient. In MySQL source, we have: >mysql-5.6.23/mysys/my_thr_init.c > if ((pth_ret= pthread_key_create(&THR_KEY_mysys, NULL)) != 0) > { > fprintf(stderr, "Can't initialize threads: error %d\n", pth_ret); > return 1; > } > >In NetBSD, src/lib/libpthread/pthread_tsd.c > for (i = nextkey; i < PTHREAD_KEYS_MAX; i++) > if (pthread__tsd_alloc[i] == NULL) > break; > > if (i == PTHREAD_KEYS_MAX) { > /* 2. If that didn't work, search from the start > * of the list back to "nextkey". > */ > for (i = 0; i < nextkey; i++) > if (pthread__tsd_alloc[i] == NULL) > break; > > if (i == nextkey) { > /* If we didn't find one here, there isn't one > * to be found. > */ > pthread_mutex_unlock(&tsd_mutex); > return EAGAIN; > >We hit a hardcoded value here, which is set to 256 in <limits.h>. Anyone >encountered this? Is there other workarounds than rebuilding libpthread >with a higher PTHREAD_KEYS_MAX? In an ideal world, we could throttle on >failure, instead of exitting.
The throttling needs to be done by the application; we return EAGAIN. I think you need to compile with a larger PTHREAD_KEYS_MAX. Perhaps we can make this more flexible by dynamically allocating the array, so one does not need to recompile (and provide PTHREAD_USER_KEYS_MAX like: http://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/pthread_key_create.3T.html). christos
