You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Tapple Gao <ta...@gmail.com> on 2015/12/25 18:36:02 UTC

apr_shm_create succeeds then fails on Mac OS X

Hi. I’m trying to get mod_tile working on the builtin apache in Mac OS X El Capitan. I am running into a problem with apr_shm_create failing to allocate memory during ap_hook_post_config:
[Fri Dec 25 12:09:17.898197 2015] [tile:error] [pid 22431] Successfully create shared memory segment size 888 on file /tmp/httpd_shm.22431
[Fri Dec 25 12:09:17.898285 2015] [tile:error] [pid 22431] (12)Cannot allocate memory: Failed to create shared memory segment size 2401448 on file /tmp/httpd_shm_delay.22431

Is there something I need to configure to get this shared memory working, or increase the limit? This module is most often run on Ubuntu linux, where it’s been running for years to power openstreetmap.org

FYI, I’m a total apache noob. I’d never even tried to set up an httpd server before this week, let alone debug issues in a third-party module

Configuration:

Mac OS X 10.11.2 El Capitan
I have the latest server.app installed from: https://itunes.apple.com/us/app/os-x-server/id883878097?mt=12
I have built and installed mod_tile from git HEAD: https://github.com/openstreetmap/mod_tile

Full command line:

sh-3.2# ls -lh /tmp/httpd_*
ls: /tmp/httpd_*: No such file or directory
sh-3.2# SERVER_INSTALL_PATH_PREFIX=/Applications/Server.app/Contents/ServerRoot /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/apache2/httpd_server_app.conf -E /var/log/apache2/error_log -D WEBSERVICE_ON -X
sh-3.2# ls -lh /tmp/httpd_*
-rw-r--r--  1 root  wheel     0B Dec 25 12:09 /tmp/httpd_shm_delay.22431
sh-3.2# 

Full logs:

[Fri Dec 25 12:09:17.858821 2015] [tile:notice] [pid 22431] Loading tile config default at /osm_tiles/ for zooms 0 - 20 from tile directory /var/lib/mod_tile with extension .png and mime type image/png
[Fri Dec 25 12:09:17.858990 2015] [core:trace3] [pid 22431] core.c(3112): Setting LogLevel for all modules to trace8
[Fri Dec 25 12:09:17.861300 2015] [ssl:trace3] [pid 22431] ssl_engine_init.c(486): Creating new SSL context (protocols: TLSv1)
[Fri Dec 25 12:09:17.861383 2015] [ssl:trace1] [pid 22431] ssl_engine_init.c(743): Configuring permitted SSL ciphers [!aNULL:!eNULL:!EXP:AES:ALL:!aNULL:!eNULL:+RC4:@STRENGTH]
[Fri Dec 25 12:09:17.896125 2015] [tile:notice] [pid 22431] Loading tile config default at /osm_tiles/ for zooms 0 - 20 from tile directory /var/lib/mod_tile with extension .png and mime type image/png
[Fri Dec 25 12:09:17.896172 2015] [core:trace3] [pid 22431] core.c(3112): Setting LogLevel for all modules to trace8
[Fri Dec 25 12:09:17.897983 2015] [proxy_balancer:debug] [pid 22431] mod_proxy_balancer.c(789): AH01178: Doing balancers create: bal_persist is FALSE, AP_SLOTMEM_TYPE_CLEARINUSE
[Fri Dec 25 12:09:17.898197 2015] [tile:error] [pid 22431] Successfully create shared memory segment size 888 on file /tmp/httpd_shm.22431
[Fri Dec 25 12:09:17.898285 2015] [tile:error] [pid 22431] (12)Cannot allocate memory: Failed to create shared memory segment size 2401448 on file /tmp/httpd_shm_delay.22431
[Fri Dec 25 12:09:17.898301 2015] [:emerg] [pid 22431] AH00020: Configuration Failed, exiting

Apache config:

sh-3.2# httpd -v
Server version: Apache/2.4.16 (Unix)
Server built:   Jul 31 2015 15:53:26
sh-3.2# SERVER_INSTALL_PATH_PREFIX=/Applications/Server.app/Contents/ServerRoot /usr/sbin/httpd -D FOREGROUND -f /Library/Server/Web/Config/apache2/httpd_server_app.conf -E /var/log/apache2/error_log -D WEBSERVICE_ON -t -D DUMP_MODULES
Loaded Modules:
 core_module (static)
 so_module (static)
 http_module (static)
 mpm_prefork_module (static)
 authn_file_module (shared)
 authn_core_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_core_module (shared)
 access_compat_module (shared)
 cache_module (shared)
 cache_disk_module (shared)
 socache_shmcb_module (shared)
 socache_dbm_module (shared)
 socache_memcache_module (shared)
 dumpio_module (shared)
 reqtimeout_module (shared)
 filter_module (shared)
 substitute_module (shared)
 deflate_module (shared)
 mime_module (shared)
 log_config_module (shared)
 log_forensic_module (shared)
 logio_module (shared)
 env_module (shared)
 mime_magic_module (shared)
 expires_module (shared)
 headers_module (shared)
 usertrack_module (shared)
 setenvif_module (shared)
 version_module (shared)
 remoteip_module (shared)
 proxy_module (shared)
 proxy_connect_module (shared)
 proxy_http_module (shared)
 proxy_fcgi_module (shared)
 proxy_scgi_module (shared)
 proxy_wstunnel_module (shared)
 proxy_ajp_module (shared)
 proxy_balancer_module (shared)
 proxy_express_module (shared)
 slotmem_shm_module (shared)
 ssl_module (shared)
 lbmethod_byrequests_module (shared)
 unixd_module (shared)
 dav_module (shared)
 status_module (shared)
 autoindex_module (shared)
 asis_module (shared)
 info_module (shared)
 cgi_module (shared)
 dav_fs_module (shared)
 dav_lock_module (shared)
 vhost_alias_module (shared)
 negotiation_module (shared)
 dir_module (shared)
 actions_module (shared)
 speling_module (shared)
 alias_module (shared)
 rewrite_module (shared)
 hfs_apple_module (shared)
 auth_digest_apple_module (shared)
 apple_auth_module (shared)
 apple_status_module (shared)
 tile_module (shared)
sh-3.2# 

Full source code (modified by me with extra logging):

    /*
     * Create a unique filename using our pid. This information is
     * stashed in the global variable so the children inherit it.
     * TODO get the location from the environment $TMPDIR or somesuch.
     */
    shmfilename = apr_psprintf(pconf, "/tmp/httpd_shm.%ld", (long int)getpid());
    shmfilename_delaypool = apr_psprintf(pconf, "/tmp/httpd_shm_delay.%ld", (long int)getpid());

    /* Now create that segment 
     * would prefer to use scfg->configs->nelts here but that does
     * not seem to be set at this stage, so rely on previously set layerCount */

    size = sizeof(stats_data) + layerCount * 2 * sizeof(apr_uint64_t);
    rs = apr_shm_create(&stats_shm, size,
                        (const char *) shmfilename, pconf);
    if (rs != APR_SUCCESS) {
        ap_log_error(APLOG_MARK, APLOG_ERR, rs, s,
                     "Failed to create shared memory segment size %d on file %s",
                     size, shmfilename);
        return HTTP_INTERNAL_SERVER_ERROR;
    } else {
        ap_log_error(APLOG_MARK, APLOG_ERR, rs, s,
                     "Successfully create shared memory segment size %d on file %s",
                     size, shmfilename);
    }

    size = sizeof(delaypool);
    rs = apr_shm_create(&delaypool_shm, size,
                        (const char *) shmfilename_delaypool, pconf);
    if (rs != APR_SUCCESS) {
        ap_log_error(APLOG_MARK, APLOG_ERR, rs, s,
                     "Failed to create shared memory segment size %d on file %s",
                     size, shmfilename_delaypool);
        return HTTP_INTERNAL_SERVER_ERROR;
    } else {
        ap_log_error(APLOG_MARK, APLOG_ERR, rs, s,
                     "Successfully create shared memory segment size %d on file %s",
                     size, shmfilename_delaypool);
    }











Re: apr_shm_create succeeds then fails on Mac OS X

Posted by "Helmut K. C. Tessarek" <te...@evermeet.cx>.
On 27.12.15 8:47 , Sorin Manolache wrote:
> I think that the location of the shmfile must be on a filesystem of a special type, namely tmpfs, which maps in memory and not on disk. Execute "mount" and check if you have such filesystems mounted. For example on my Linux machine:

In that case the module wouldn't work on Linux either, since the '/tmp/...' path is hard-coded and /tmp is usually not a tmpfs.
Just my 2 cents.

Cheers,
  K. C.

-- 
regards Helmut K. C. Tessarek
lookup http://sks.pkqs.net for KeyID 0xC11F128D

/*
   Thou shalt not follow the NULL pointer for chaos and madness 
   await thee at its end.
*/

Re: apr_shm_create succeeds then fails on Mac OS X

Posted by Jim Jagielski <ji...@jaguNET.com>.
Registering it as a cleanup is likely better
> On Dec 28, 2015, at 9:09 AM, Yann Ylavic <yl...@gmail.com> wrote:
> 
> You could possible add a call to apr_shm_remove(shmfilename, pconf)
> (resp. shmfilename_delaypool) in the module's post_config, before the
> SHMs are created with apr_shm_create().
> 
> Regards,
> Yann.
> 
> On Mon, Dec 28, 2015 at 2:56 PM, Jim Jagielski <ji...@jagunet.com> wrote:
>> Looks like the module is not cleaning up and removing the shared memory
>> segment during a shutdown and/or restart.
>> 
>>> On Dec 28, 2015, at 8:43 AM, Tapple Gao <ta...@gmail.com> wrote:
>>> 
>>> I found something that helped: I googled and discovered the ipcs utility:
>>> 
>>> 68 08:24 tapple /Library/Server/Web/Config/apache2/sites $ ipcs -am
>>> IPC status from <running system> as of Mon Dec 28 08:24:42 EST 2015
>>> T     ID     KEY        MODE       OWNER    GROUP  CREATOR   CGROUP NATTCH  SEGSZ  CPID  LPID   ATIME    DTIME    CTIME
>>> Shared Memory:
>>> m  65536 0x0052e2c1 --rw------- postgres postgres postgres postgres      6     56    484    484 19:25:25  8:24:22 19:25:25
>>> m 1572865 0x0101d953 --rw-------     root    wheel     root    wheel      0 2401448  78687  78687 17:32:23 17:32:58 17:32:23
>>> m  65541 0x00000000 --rw------- _devicemgr _devicemgr _devicemgr _devicemgr      5      1    652    652 19:25:36  8:24:22 19:25:36
>>> m 2293766 0x0101d952 --rw-------     root    wheel     root    wheel      0    904  78687  78687 17:32:23 17:32:58 17:32:23
>>> 
>>> Hey. that size of 2401448 looks familiar. yup. that’s the size listed of the failed allocation in the logs. Let’s try removing it:
>>> 
>>> 171 08:26 tapple /Library/Server/Web/Config/apache2/sites $ sudo ipcrm -m 1572865
>>> Password:
>>> 172 08:26 tapple /Library/Server/Web/Config/apache2/sites $ ipcs -am
>>> IPC status from <running system> as of Mon Dec 28 08:26:38 EST 2015
>>> T     ID     KEY        MODE       OWNER    GROUP  CREATOR   CGROUP NATTCH  SEGSZ  CPID  LPID   ATIME    DTIME    CTIME
>>> Shared Memory:
>>> m  65536 0x0052e2c1 --rw------- postgres postgres postgres postgres      6     56    484    484 19:25:25  8:26:22 19:25:25
>>> m  65541 0x00000000 --rw------- _devicemgr _devicemgr _devicemgr _devicemgr      5      1    652    652 19:25:36  8:26:22 19:25:36
>>> m 2293766 0x0101d952 --rw-------     root    wheel     root    wheel      0    904  78687  78687 17:32:23 17:32:58 17:32:23
>>> 
>>> Now my server starts. Hovever, as soon as I kill and restart the server, the same problem returns.
>>> I’m not familiar with ipc at all. Anybody know why any of this happened? why the shared memory stuck around after apache quit? Why it couldn’t allocate another block? why it worked after deleting the leftover one?
>>> 
>>>> On Dec 28, 2015, at 7:49 AM, Tapple Gao <ta...@gmail.com> wrote:
>>>> 
>>>> /tmp is not a special volume on my system, and has plenty of room for a 2MB file:
>>>> sh-3.2# df -h
>>>> Filesystem                          Size   Used  Avail Capacity  iused    ifree %iused  Mounted on
>>>> /dev/disk0s2                       184Gi  170Gi   14Gi    93% 44604554  3741719   92%   /
>>>> devfs                              329Ki  329Ki    0Bi   100%     1138        0  100%   /dev
>>>> map -hosts                           0Bi    0Bi    0Bi   100%        0        0  100%   /net
>>>> map auto_home                        0Bi    0Bi    0Bi   100%        0        0  100%   /home
>>>> map -fstab                           0Bi    0Bi    0Bi   100%        0        0  100%   /Network/Servers
>>>> /dev/disk0s5                       442Gi  353Gi   89Gi    80% 92513182 23266901   80%   /Volumes/Shared
>>>> localhost:/18XTcmWVPTgvjvav7dUs5F  184Gi  184Gi    0Bi   100%        0        0  100%   /Volumes/MobileBackups
>>>> 
>>>> 
>>>>> On Dec 27, 2015, at 4:18 PM, Jim Jagielski <ji...@jaguNET.com> wrote:
>>>>> 
>>>>> Are you *sure* that /tmp really has enough space?
>>>>> 
>>>>>> On Dec 27, 2015, at 8:47 AM, Sorin Manolache <so...@gmail.com> wrote:
>>>>>> 
>>>>>> On 2015-12-25 19:36, Tapple Gao wrote:
>>>>>>> Hi. I’m trying to get mod_tile working on the builtin apache in Mac OS X El Capitan. I am running into a problem with apr_shm_create failing to allocate memory during ap_hook_post_config:
>>>>>>> [Fri Dec 25 12:09:17.898197 2015] [tile:error] [pid 22431] Successfully create shared memory segment size 888 on file /tmp/httpd_shm.22431
>>>>>>> [Fri Dec 25 12:09:17.898285 2015] [tile:error] [pid 22431] (12)Cannot allocate memory: Failed to create shared memory segment size 2401448 on file /tmp/httpd_shm_delay.22431
>>>>>>> 
>>>>>>> Is there something I need to configure to get this shared memory working, or increase the limit? This module is most often run on Ubuntu linux, where it’s been running for years to power openstreetmap.org
>>>>>>> 
>>>>>>> 
>>>>>>> /*
>>>>>>>  * Create a unique filename using our pid. This information is
>>>>>>>  * stashed in the global variable so the children inherit it.
>>>>>>>  * TODO get the location from the environment $TMPDIR or somesuch.
>>>>>>>  */
>>>>>>> shmfilename = apr_psprintf(pconf, "/tmp/httpd_shm.%ld", (long int)getpid());
>>>>>>> shmfilename_delaypool = apr_psprintf(pconf, "/tmp/httpd_shm_delay.%ld", (long int)getpid());
>>>>>> 
>>>>>> 
>>>>>> I think that the location of the shmfile must be on a filesystem of a special type, namely tmpfs, which maps in memory and not on disk. Execute "mount" and check if you have such filesystems mounted. For example on my Linux machine:
>>>>>> 
>>>>>> $ mount
>>>>>> /dev/sda6 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
>>>>>> tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=398160k)
>>>>>> /dev/sda9 on /tmp type ext4 (rw,relatime,data=ordered)
>>>>>> 
>>>>>> As you see, / and /tmp are of disk partitions while /run/shm has a filesystem of type tmpfs.
>>>>>> 
>>>>>> I suggest to change the code and use a different location from /tmp/... On Linux the shared memory is often created in /run/shm/*. I have no experience with Mac OS X.
>>>>>> 
>>>>>> The cleanest way would be to implement what's written in the commentary of the code above, namely the possibility to specify the path by an evrionment variable or from a configuration directive.
>>>>>> 
>>>>>> Sorin
>>>>>> 
>>>>> 
>>>> 
>>> 
>> 


Re: apr_shm_create succeeds then fails on Mac OS X

Posted by Yann Ylavic <yl...@gmail.com>.
You could possible add a call to apr_shm_remove(shmfilename, pconf)
(resp. shmfilename_delaypool) in the module's post_config, before the
SHMs are created with apr_shm_create().

Regards,
Yann.

On Mon, Dec 28, 2015 at 2:56 PM, Jim Jagielski <ji...@jagunet.com> wrote:
> Looks like the module is not cleaning up and removing the shared memory
> segment during a shutdown and/or restart.
>
>> On Dec 28, 2015, at 8:43 AM, Tapple Gao <ta...@gmail.com> wrote:
>>
>> I found something that helped: I googled and discovered the ipcs utility:
>>
>> 68 08:24 tapple /Library/Server/Web/Config/apache2/sites $ ipcs -am
>> IPC status from <running system> as of Mon Dec 28 08:24:42 EST 2015
>> T     ID     KEY        MODE       OWNER    GROUP  CREATOR   CGROUP NATTCH  SEGSZ  CPID  LPID   ATIME    DTIME    CTIME
>> Shared Memory:
>> m  65536 0x0052e2c1 --rw------- postgres postgres postgres postgres      6     56    484    484 19:25:25  8:24:22 19:25:25
>> m 1572865 0x0101d953 --rw-------     root    wheel     root    wheel      0 2401448  78687  78687 17:32:23 17:32:58 17:32:23
>> m  65541 0x00000000 --rw------- _devicemgr _devicemgr _devicemgr _devicemgr      5      1    652    652 19:25:36  8:24:22 19:25:36
>> m 2293766 0x0101d952 --rw-------     root    wheel     root    wheel      0    904  78687  78687 17:32:23 17:32:58 17:32:23
>>
>> Hey. that size of 2401448 looks familiar. yup. that’s the size listed of the failed allocation in the logs. Let’s try removing it:
>>
>> 171 08:26 tapple /Library/Server/Web/Config/apache2/sites $ sudo ipcrm -m 1572865
>> Password:
>> 172 08:26 tapple /Library/Server/Web/Config/apache2/sites $ ipcs -am
>> IPC status from <running system> as of Mon Dec 28 08:26:38 EST 2015
>> T     ID     KEY        MODE       OWNER    GROUP  CREATOR   CGROUP NATTCH  SEGSZ  CPID  LPID   ATIME    DTIME    CTIME
>> Shared Memory:
>> m  65536 0x0052e2c1 --rw------- postgres postgres postgres postgres      6     56    484    484 19:25:25  8:26:22 19:25:25
>> m  65541 0x00000000 --rw------- _devicemgr _devicemgr _devicemgr _devicemgr      5      1    652    652 19:25:36  8:26:22 19:25:36
>> m 2293766 0x0101d952 --rw-------     root    wheel     root    wheel      0    904  78687  78687 17:32:23 17:32:58 17:32:23
>>
>> Now my server starts. Hovever, as soon as I kill and restart the server, the same problem returns.
>> I’m not familiar with ipc at all. Anybody know why any of this happened? why the shared memory stuck around after apache quit? Why it couldn’t allocate another block? why it worked after deleting the leftover one?
>>
>>> On Dec 28, 2015, at 7:49 AM, Tapple Gao <ta...@gmail.com> wrote:
>>>
>>> /tmp is not a special volume on my system, and has plenty of room for a 2MB file:
>>> sh-3.2# df -h
>>> Filesystem                          Size   Used  Avail Capacity  iused    ifree %iused  Mounted on
>>> /dev/disk0s2                       184Gi  170Gi   14Gi    93% 44604554  3741719   92%   /
>>> devfs                              329Ki  329Ki    0Bi   100%     1138        0  100%   /dev
>>> map -hosts                           0Bi    0Bi    0Bi   100%        0        0  100%   /net
>>> map auto_home                        0Bi    0Bi    0Bi   100%        0        0  100%   /home
>>> map -fstab                           0Bi    0Bi    0Bi   100%        0        0  100%   /Network/Servers
>>> /dev/disk0s5                       442Gi  353Gi   89Gi    80% 92513182 23266901   80%   /Volumes/Shared
>>> localhost:/18XTcmWVPTgvjvav7dUs5F  184Gi  184Gi    0Bi   100%        0        0  100%   /Volumes/MobileBackups
>>>
>>>
>>>> On Dec 27, 2015, at 4:18 PM, Jim Jagielski <ji...@jaguNET.com> wrote:
>>>>
>>>> Are you *sure* that /tmp really has enough space?
>>>>
>>>>> On Dec 27, 2015, at 8:47 AM, Sorin Manolache <so...@gmail.com> wrote:
>>>>>
>>>>> On 2015-12-25 19:36, Tapple Gao wrote:
>>>>>> Hi. I’m trying to get mod_tile working on the builtin apache in Mac OS X El Capitan. I am running into a problem with apr_shm_create failing to allocate memory during ap_hook_post_config:
>>>>>> [Fri Dec 25 12:09:17.898197 2015] [tile:error] [pid 22431] Successfully create shared memory segment size 888 on file /tmp/httpd_shm.22431
>>>>>> [Fri Dec 25 12:09:17.898285 2015] [tile:error] [pid 22431] (12)Cannot allocate memory: Failed to create shared memory segment size 2401448 on file /tmp/httpd_shm_delay.22431
>>>>>>
>>>>>> Is there something I need to configure to get this shared memory working, or increase the limit? This module is most often run on Ubuntu linux, where it’s been running for years to power openstreetmap.org
>>>>>>
>>>>>>
>>>>>>  /*
>>>>>>   * Create a unique filename using our pid. This information is
>>>>>>   * stashed in the global variable so the children inherit it.
>>>>>>   * TODO get the location from the environment $TMPDIR or somesuch.
>>>>>>   */
>>>>>>  shmfilename = apr_psprintf(pconf, "/tmp/httpd_shm.%ld", (long int)getpid());
>>>>>>  shmfilename_delaypool = apr_psprintf(pconf, "/tmp/httpd_shm_delay.%ld", (long int)getpid());
>>>>>
>>>>>
>>>>> I think that the location of the shmfile must be on a filesystem of a special type, namely tmpfs, which maps in memory and not on disk. Execute "mount" and check if you have such filesystems mounted. For example on my Linux machine:
>>>>>
>>>>> $ mount
>>>>> /dev/sda6 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
>>>>> tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=398160k)
>>>>> /dev/sda9 on /tmp type ext4 (rw,relatime,data=ordered)
>>>>>
>>>>> As you see, / and /tmp are of disk partitions while /run/shm has a filesystem of type tmpfs.
>>>>>
>>>>> I suggest to change the code and use a different location from /tmp/... On Linux the shared memory is often created in /run/shm/*. I have no experience with Mac OS X.
>>>>>
>>>>> The cleanest way would be to implement what's written in the commentary of the code above, namely the possibility to specify the path by an evrionment variable or from a configuration directive.
>>>>>
>>>>> Sorin
>>>>>
>>>>
>>>
>>
>

Re: apr_shm_create succeeds then fails on Mac OS X

Posted by Jim Jagielski <ji...@jaguNET.com>.
Looks like the module is not cleaning up and removing the shared memory
segment during a shutdown and/or restart.

> On Dec 28, 2015, at 8:43 AM, Tapple Gao <ta...@gmail.com> wrote:
> 
> I found something that helped: I googled and discovered the ipcs utility:
> 
> 68 08:24 tapple /Library/Server/Web/Config/apache2/sites $ ipcs -am
> IPC status from <running system> as of Mon Dec 28 08:24:42 EST 2015
> T     ID     KEY        MODE       OWNER    GROUP  CREATOR   CGROUP NATTCH  SEGSZ  CPID  LPID   ATIME    DTIME    CTIME
> Shared Memory:
> m  65536 0x0052e2c1 --rw------- postgres postgres postgres postgres      6     56    484    484 19:25:25  8:24:22 19:25:25
> m 1572865 0x0101d953 --rw-------     root    wheel     root    wheel      0 2401448  78687  78687 17:32:23 17:32:58 17:32:23
> m  65541 0x00000000 --rw------- _devicemgr _devicemgr _devicemgr _devicemgr      5      1    652    652 19:25:36  8:24:22 19:25:36
> m 2293766 0x0101d952 --rw-------     root    wheel     root    wheel      0    904  78687  78687 17:32:23 17:32:58 17:32:23
> 
> Hey. that size of 2401448 looks familiar. yup. that’s the size listed of the failed allocation in the logs. Let’s try removing it:
> 
> 171 08:26 tapple /Library/Server/Web/Config/apache2/sites $ sudo ipcrm -m 1572865
> Password:
> 172 08:26 tapple /Library/Server/Web/Config/apache2/sites $ ipcs -am
> IPC status from <running system> as of Mon Dec 28 08:26:38 EST 2015
> T     ID     KEY        MODE       OWNER    GROUP  CREATOR   CGROUP NATTCH  SEGSZ  CPID  LPID   ATIME    DTIME    CTIME
> Shared Memory:
> m  65536 0x0052e2c1 --rw------- postgres postgres postgres postgres      6     56    484    484 19:25:25  8:26:22 19:25:25
> m  65541 0x00000000 --rw------- _devicemgr _devicemgr _devicemgr _devicemgr      5      1    652    652 19:25:36  8:26:22 19:25:36
> m 2293766 0x0101d952 --rw-------     root    wheel     root    wheel      0    904  78687  78687 17:32:23 17:32:58 17:32:23
> 
> Now my server starts. Hovever, as soon as I kill and restart the server, the same problem returns.
> I’m not familiar with ipc at all. Anybody know why any of this happened? why the shared memory stuck around after apache quit? Why it couldn’t allocate another block? why it worked after deleting the leftover one?
> 
>> On Dec 28, 2015, at 7:49 AM, Tapple Gao <ta...@gmail.com> wrote:
>> 
>> /tmp is not a special volume on my system, and has plenty of room for a 2MB file:
>> sh-3.2# df -h
>> Filesystem                          Size   Used  Avail Capacity  iused    ifree %iused  Mounted on
>> /dev/disk0s2                       184Gi  170Gi   14Gi    93% 44604554  3741719   92%   /
>> devfs                              329Ki  329Ki    0Bi   100%     1138        0  100%   /dev
>> map -hosts                           0Bi    0Bi    0Bi   100%        0        0  100%   /net
>> map auto_home                        0Bi    0Bi    0Bi   100%        0        0  100%   /home
>> map -fstab                           0Bi    0Bi    0Bi   100%        0        0  100%   /Network/Servers
>> /dev/disk0s5                       442Gi  353Gi   89Gi    80% 92513182 23266901   80%   /Volumes/Shared
>> localhost:/18XTcmWVPTgvjvav7dUs5F  184Gi  184Gi    0Bi   100%        0        0  100%   /Volumes/MobileBackups
>> 
>> 
>>> On Dec 27, 2015, at 4:18 PM, Jim Jagielski <ji...@jaguNET.com> wrote:
>>> 
>>> Are you *sure* that /tmp really has enough space?
>>> 
>>>> On Dec 27, 2015, at 8:47 AM, Sorin Manolache <so...@gmail.com> wrote:
>>>> 
>>>> On 2015-12-25 19:36, Tapple Gao wrote:
>>>>> Hi. I’m trying to get mod_tile working on the builtin apache in Mac OS X El Capitan. I am running into a problem with apr_shm_create failing to allocate memory during ap_hook_post_config:
>>>>> [Fri Dec 25 12:09:17.898197 2015] [tile:error] [pid 22431] Successfully create shared memory segment size 888 on file /tmp/httpd_shm.22431
>>>>> [Fri Dec 25 12:09:17.898285 2015] [tile:error] [pid 22431] (12)Cannot allocate memory: Failed to create shared memory segment size 2401448 on file /tmp/httpd_shm_delay.22431
>>>>> 
>>>>> Is there something I need to configure to get this shared memory working, or increase the limit? This module is most often run on Ubuntu linux, where it’s been running for years to power openstreetmap.org
>>>>> 
>>>>> 
>>>>>  /*
>>>>>   * Create a unique filename using our pid. This information is
>>>>>   * stashed in the global variable so the children inherit it.
>>>>>   * TODO get the location from the environment $TMPDIR or somesuch.
>>>>>   */
>>>>>  shmfilename = apr_psprintf(pconf, "/tmp/httpd_shm.%ld", (long int)getpid());
>>>>>  shmfilename_delaypool = apr_psprintf(pconf, "/tmp/httpd_shm_delay.%ld", (long int)getpid());
>>>> 
>>>> 
>>>> I think that the location of the shmfile must be on a filesystem of a special type, namely tmpfs, which maps in memory and not on disk. Execute "mount" and check if you have such filesystems mounted. For example on my Linux machine:
>>>> 
>>>> $ mount
>>>> /dev/sda6 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
>>>> tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=398160k)
>>>> /dev/sda9 on /tmp type ext4 (rw,relatime,data=ordered)
>>>> 
>>>> As you see, / and /tmp are of disk partitions while /run/shm has a filesystem of type tmpfs.
>>>> 
>>>> I suggest to change the code and use a different location from /tmp/... On Linux the shared memory is often created in /run/shm/*. I have no experience with Mac OS X.
>>>> 
>>>> The cleanest way would be to implement what's written in the commentary of the code above, namely the possibility to specify the path by an evrionment variable or from a configuration directive.
>>>> 
>>>> Sorin
>>>> 
>>> 
>> 
> 


Re: apr_shm_create succeeds then fails on Mac OS X

Posted by Tapple Gao <ta...@gmail.com>.
I found something that helped: I googled and discovered the ipcs utility:

68 08:24 tapple /Library/Server/Web/Config/apache2/sites $ ipcs -am
IPC status from <running system> as of Mon Dec 28 08:24:42 EST 2015
T     ID     KEY        MODE       OWNER    GROUP  CREATOR   CGROUP NATTCH  SEGSZ  CPID  LPID   ATIME    DTIME    CTIME
Shared Memory:
m  65536 0x0052e2c1 --rw------- postgres postgres postgres postgres      6     56    484    484 19:25:25  8:24:22 19:25:25
m 1572865 0x0101d953 --rw-------     root    wheel     root    wheel      0 2401448  78687  78687 17:32:23 17:32:58 17:32:23
m  65541 0x00000000 --rw------- _devicemgr _devicemgr _devicemgr _devicemgr      5      1    652    652 19:25:36  8:24:22 19:25:36
m 2293766 0x0101d952 --rw-------     root    wheel     root    wheel      0    904  78687  78687 17:32:23 17:32:58 17:32:23

Hey. that size of 2401448 looks familiar. yup. that’s the size listed of the failed allocation in the logs. Let’s try removing it:

171 08:26 tapple /Library/Server/Web/Config/apache2/sites $ sudo ipcrm -m 1572865
Password:
172 08:26 tapple /Library/Server/Web/Config/apache2/sites $ ipcs -am
IPC status from <running system> as of Mon Dec 28 08:26:38 EST 2015
T     ID     KEY        MODE       OWNER    GROUP  CREATOR   CGROUP NATTCH  SEGSZ  CPID  LPID   ATIME    DTIME    CTIME
Shared Memory:
m  65536 0x0052e2c1 --rw------- postgres postgres postgres postgres      6     56    484    484 19:25:25  8:26:22 19:25:25
m  65541 0x00000000 --rw------- _devicemgr _devicemgr _devicemgr _devicemgr      5      1    652    652 19:25:36  8:26:22 19:25:36
m 2293766 0x0101d952 --rw-------     root    wheel     root    wheel      0    904  78687  78687 17:32:23 17:32:58 17:32:23

Now my server starts. Hovever, as soon as I kill and restart the server, the same problem returns.
I’m not familiar with ipc at all. Anybody know why any of this happened? why the shared memory stuck around after apache quit? Why it couldn’t allocate another block? why it worked after deleting the leftover one?

> On Dec 28, 2015, at 7:49 AM, Tapple Gao <ta...@gmail.com> wrote:
> 
> /tmp is not a special volume on my system, and has plenty of room for a 2MB file:
> sh-3.2# df -h
> Filesystem                          Size   Used  Avail Capacity  iused    ifree %iused  Mounted on
> /dev/disk0s2                       184Gi  170Gi   14Gi    93% 44604554  3741719   92%   /
> devfs                              329Ki  329Ki    0Bi   100%     1138        0  100%   /dev
> map -hosts                           0Bi    0Bi    0Bi   100%        0        0  100%   /net
> map auto_home                        0Bi    0Bi    0Bi   100%        0        0  100%   /home
> map -fstab                           0Bi    0Bi    0Bi   100%        0        0  100%   /Network/Servers
> /dev/disk0s5                       442Gi  353Gi   89Gi    80% 92513182 23266901   80%   /Volumes/Shared
> localhost:/18XTcmWVPTgvjvav7dUs5F  184Gi  184Gi    0Bi   100%        0        0  100%   /Volumes/MobileBackups
> 
> 
>> On Dec 27, 2015, at 4:18 PM, Jim Jagielski <ji...@jaguNET.com> wrote:
>> 
>> Are you *sure* that /tmp really has enough space?
>> 
>>> On Dec 27, 2015, at 8:47 AM, Sorin Manolache <so...@gmail.com> wrote:
>>> 
>>> On 2015-12-25 19:36, Tapple Gao wrote:
>>>> Hi. I’m trying to get mod_tile working on the builtin apache in Mac OS X El Capitan. I am running into a problem with apr_shm_create failing to allocate memory during ap_hook_post_config:
>>>> [Fri Dec 25 12:09:17.898197 2015] [tile:error] [pid 22431] Successfully create shared memory segment size 888 on file /tmp/httpd_shm.22431
>>>> [Fri Dec 25 12:09:17.898285 2015] [tile:error] [pid 22431] (12)Cannot allocate memory: Failed to create shared memory segment size 2401448 on file /tmp/httpd_shm_delay.22431
>>>> 
>>>> Is there something I need to configure to get this shared memory working, or increase the limit? This module is most often run on Ubuntu linux, where it’s been running for years to power openstreetmap.org
>>>> 
>>>> 
>>>>   /*
>>>>    * Create a unique filename using our pid. This information is
>>>>    * stashed in the global variable so the children inherit it.
>>>>    * TODO get the location from the environment $TMPDIR or somesuch.
>>>>    */
>>>>   shmfilename = apr_psprintf(pconf, "/tmp/httpd_shm.%ld", (long int)getpid());
>>>>   shmfilename_delaypool = apr_psprintf(pconf, "/tmp/httpd_shm_delay.%ld", (long int)getpid());
>>> 
>>> 
>>> I think that the location of the shmfile must be on a filesystem of a special type, namely tmpfs, which maps in memory and not on disk. Execute "mount" and check if you have such filesystems mounted. For example on my Linux machine:
>>> 
>>> $ mount
>>> /dev/sda6 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
>>> tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=398160k)
>>> /dev/sda9 on /tmp type ext4 (rw,relatime,data=ordered)
>>> 
>>> As you see, / and /tmp are of disk partitions while /run/shm has a filesystem of type tmpfs.
>>> 
>>> I suggest to change the code and use a different location from /tmp/... On Linux the shared memory is often created in /run/shm/*. I have no experience with Mac OS X.
>>> 
>>> The cleanest way would be to implement what's written in the commentary of the code above, namely the possibility to specify the path by an evrionment variable or from a configuration directive.
>>> 
>>> Sorin
>>> 
>> 
> 


Re: apr_shm_create succeeds then fails on Mac OS X

Posted by Tapple Gao <ta...@gmail.com>.
/tmp is not a special volume on my system, and has plenty of room for a 2MB file:
sh-3.2# df -h
Filesystem                          Size   Used  Avail Capacity  iused    ifree %iused  Mounted on
/dev/disk0s2                       184Gi  170Gi   14Gi    93% 44604554  3741719   92%   /
devfs                              329Ki  329Ki    0Bi   100%     1138        0  100%   /dev
map -hosts                           0Bi    0Bi    0Bi   100%        0        0  100%   /net
map auto_home                        0Bi    0Bi    0Bi   100%        0        0  100%   /home
map -fstab                           0Bi    0Bi    0Bi   100%        0        0  100%   /Network/Servers
/dev/disk0s5                       442Gi  353Gi   89Gi    80% 92513182 23266901   80%   /Volumes/Shared
localhost:/18XTcmWVPTgvjvav7dUs5F  184Gi  184Gi    0Bi   100%        0        0  100%   /Volumes/MobileBackups


> On Dec 27, 2015, at 4:18 PM, Jim Jagielski <ji...@jaguNET.com> wrote:
> 
> Are you *sure* that /tmp really has enough space?
> 
>> On Dec 27, 2015, at 8:47 AM, Sorin Manolache <so...@gmail.com> wrote:
>> 
>> On 2015-12-25 19:36, Tapple Gao wrote:
>>> Hi. I’m trying to get mod_tile working on the builtin apache in Mac OS X El Capitan. I am running into a problem with apr_shm_create failing to allocate memory during ap_hook_post_config:
>>> [Fri Dec 25 12:09:17.898197 2015] [tile:error] [pid 22431] Successfully create shared memory segment size 888 on file /tmp/httpd_shm.22431
>>> [Fri Dec 25 12:09:17.898285 2015] [tile:error] [pid 22431] (12)Cannot allocate memory: Failed to create shared memory segment size 2401448 on file /tmp/httpd_shm_delay.22431
>>> 
>>> Is there something I need to configure to get this shared memory working, or increase the limit? This module is most often run on Ubuntu linux, where it’s been running for years to power openstreetmap.org
>>> 
>>> 
>>>    /*
>>>     * Create a unique filename using our pid. This information is
>>>     * stashed in the global variable so the children inherit it.
>>>     * TODO get the location from the environment $TMPDIR or somesuch.
>>>     */
>>>    shmfilename = apr_psprintf(pconf, "/tmp/httpd_shm.%ld", (long int)getpid());
>>>    shmfilename_delaypool = apr_psprintf(pconf, "/tmp/httpd_shm_delay.%ld", (long int)getpid());
>> 
>> 
>> I think that the location of the shmfile must be on a filesystem of a special type, namely tmpfs, which maps in memory and not on disk. Execute "mount" and check if you have such filesystems mounted. For example on my Linux machine:
>> 
>> $ mount
>> /dev/sda6 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
>> tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=398160k)
>> /dev/sda9 on /tmp type ext4 (rw,relatime,data=ordered)
>> 
>> As you see, / and /tmp are of disk partitions while /run/shm has a filesystem of type tmpfs.
>> 
>> I suggest to change the code and use a different location from /tmp/... On Linux the shared memory is often created in /run/shm/*. I have no experience with Mac OS X.
>> 
>> The cleanest way would be to implement what's written in the commentary of the code above, namely the possibility to specify the path by an evrionment variable or from a configuration directive.
>> 
>> Sorin
>> 
> 


Re: apr_shm_create succeeds then fails on Mac OS X

Posted by Jim Jagielski <ji...@jaguNET.com>.
Are you *sure* that /tmp really has enough space?

> On Dec 27, 2015, at 8:47 AM, Sorin Manolache <so...@gmail.com> wrote:
> 
> On 2015-12-25 19:36, Tapple Gao wrote:
>> Hi. I’m trying to get mod_tile working on the builtin apache in Mac OS X El Capitan. I am running into a problem with apr_shm_create failing to allocate memory during ap_hook_post_config:
>> [Fri Dec 25 12:09:17.898197 2015] [tile:error] [pid 22431] Successfully create shared memory segment size 888 on file /tmp/httpd_shm.22431
>> [Fri Dec 25 12:09:17.898285 2015] [tile:error] [pid 22431] (12)Cannot allocate memory: Failed to create shared memory segment size 2401448 on file /tmp/httpd_shm_delay.22431
>> 
>> Is there something I need to configure to get this shared memory working, or increase the limit? This module is most often run on Ubuntu linux, where it’s been running for years to power openstreetmap.org
>> 
>> 
>>     /*
>>      * Create a unique filename using our pid. This information is
>>      * stashed in the global variable so the children inherit it.
>>      * TODO get the location from the environment $TMPDIR or somesuch.
>>      */
>>     shmfilename = apr_psprintf(pconf, "/tmp/httpd_shm.%ld", (long int)getpid());
>>     shmfilename_delaypool = apr_psprintf(pconf, "/tmp/httpd_shm_delay.%ld", (long int)getpid());
> 
> 
> I think that the location of the shmfile must be on a filesystem of a special type, namely tmpfs, which maps in memory and not on disk. Execute "mount" and check if you have such filesystems mounted. For example on my Linux machine:
> 
> $ mount
> /dev/sda6 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
> tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=398160k)
> /dev/sda9 on /tmp type ext4 (rw,relatime,data=ordered)
> 
> As you see, / and /tmp are of disk partitions while /run/shm has a filesystem of type tmpfs.
> 
> I suggest to change the code and use a different location from /tmp/... On Linux the shared memory is often created in /run/shm/*. I have no experience with Mac OS X.
> 
> The cleanest way would be to implement what's written in the commentary of the code above, namely the possibility to specify the path by an evrionment variable or from a configuration directive.
> 
> Sorin
> 


Re: apr_shm_create succeeds then fails on Mac OS X

Posted by Sorin Manolache <so...@gmail.com>.
On 2015-12-25 19:36, Tapple Gao wrote:
> Hi. I’m trying to get mod_tile working on the builtin apache in Mac OS X El Capitan. I am running into a problem with apr_shm_create failing to allocate memory during ap_hook_post_config:
> [Fri Dec 25 12:09:17.898197 2015] [tile:error] [pid 22431] Successfully create shared memory segment size 888 on file /tmp/httpd_shm.22431
> [Fri Dec 25 12:09:17.898285 2015] [tile:error] [pid 22431] (12)Cannot allocate memory: Failed to create shared memory segment size 2401448 on file /tmp/httpd_shm_delay.22431
>
> Is there something I need to configure to get this shared memory working, or increase the limit? This module is most often run on Ubuntu linux, where it’s been running for years to power openstreetmap.org
>
>
>      /*
>       * Create a unique filename using our pid. This information is
>       * stashed in the global variable so the children inherit it.
>       * TODO get the location from the environment $TMPDIR or somesuch.
>       */
>      shmfilename = apr_psprintf(pconf, "/tmp/httpd_shm.%ld", (long int)getpid());
>      shmfilename_delaypool = apr_psprintf(pconf, "/tmp/httpd_shm_delay.%ld", (long int)getpid());


I think that the location of the shmfile must be on a filesystem of a 
special type, namely tmpfs, which maps in memory and not on disk. 
Execute "mount" and check if you have such filesystems mounted. For 
example on my Linux machine:

$ mount
/dev/sda6 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=398160k)
/dev/sda9 on /tmp type ext4 (rw,relatime,data=ordered)

As you see, / and /tmp are of disk partitions while /run/shm has a 
filesystem of type tmpfs.

I suggest to change the code and use a different location from /tmp/... 
On Linux the shared memory is often created in /run/shm/*. I have no 
experience with Mac OS X.

The cleanest way would be to implement what's written in the commentary 
of the code above, namely the possibility to specify the path by an 
evrionment variable or from a configuration directive.

Sorin