Comments (15)
mongo:ensure_index(Worker, Collection, {key, {tag, 1}, name, <<"tag_index">>})
this works, name parameter is optional.
The dropDups option is no longer available since mongo 3. What version of mongo do you try?
from mongodb-erlang.
i'm using mongo 2.6.5
It turns out when I put my code into console, it works and return ok, but if I put it in my application, even at the end, the app crashed
from mongodb-erlang.
Could you post a crash log here?
from mongodb-erlang.
This is crash log. Thank you
=ERROR REPORT==== 16-Apr-2015::14:50:25 ===
** Generic server <0.104.0> terminating
** Last message in was {ensure_index,conversations,{key,{page_id,1}}}
** When Server state == {state,#Port<0.3347>,49181,<<>>,
{conn_state,unsafe,master,pancake_development}}
** Reason for termination ==
** {function_clause,
[{mongo_protocol,'-put_message/3-lbc$^0/2-0-',
[{name,<<"i_page_id_1">>,unique,false,dropDups,false,key,
{page_id,1},
ns,<<"pancake_development.conversations">>},
<<>>],
[{file,"src/core/mongo_protocol.erl"},{line,49}]},
{mongo_protocol,put_message,3,
[{file,"src/core/mongo_protocol.erl"},{line,49}]},
{mc_worker_logic,'-encode_requests/2-fun-0-',3,
[{file,"src/connection/mc_worker_logic.erl"},{line,22}]},
{lists,foldl,3,[{file,"lists.erl"},{line,1261}]},
{mc_worker_logic,make_request,3,
[{file,"src/connection/mc_worker_logic.erl"},{line,71}]},
{mc_worker,handle_call,3,
[{file,"src/connection/mc_worker.erl"},{line,44}]},
{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,607}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,639}]}]}
=ERROR REPORT==== 16-Apr-2015::14:50:25 ===
** Generic server <0.98.0> terminating
** Last message in was {'EXIT',<0.48.0>,
{function_clause,
[{mongo_protocol,'-put_message/3-lbc$^0/2-0-',
[{name,<<"i_page_id_1">>,unique,false,dropDups,
false,key,
{page_id,1},
ns,<<"pancake_development.conversations">>},
<<>>],
[{file,"src/core/mongo_protocol.erl"},{line,49}]},
{mongo_protocol,put_message,3,
[{file,"src/core/mongo_protocol.erl"},{line,49}]},
{mc_worker_logic,'-encode_requests/2-fun-0-',3,
[{file,"src/connection/mc_worker_logic.erl"},
{line,22}]},
{lists,foldl,3,[{file,"lists.erl"},{line,1261}]},
{mc_worker_logic,make_request,3,
[{file,"src/connection/mc_worker_logic.erl"},
{line,71}]},
{mc_worker,handle_call,3,
[{file,"src/connection/mc_worker.erl"},{line,44}]},
{gen_server,try_handle_call,4,
[{file,"gen_server.erl"},{line,607}]},
{gen_server,handle_msg,5,
[{file,"gen_server.erl"},{line,639}]}]}}
** When Server state == {state,#Port<0.2447>,45084,<<>>,
{conn_state,unsafe,master,pancake_development}}
** Reason for termination ==
** {function_clause,
[{mongo_protocol,'-put_message/3-lbc$^0/2-0-',
[{name,<<"i_page_id_1">>,unique,false,dropDups,false,key,
{page_id,1},
ns,<<"pancake_development.conversations">>},
<<>>],
[{file,"src/core/mongo_protocol.erl"},{line,49}]},
{mongo_protocol,put_message,3,
[{file,"src/core/mongo_protocol.erl"},{line,49}]},
{mc_worker_logic,'-encode_requests/2-fun-0-',3,
[{file,"src/connection/mc_worker_logic.erl"},{line,22}]},
{lists,foldl,3,[{file,"lists.erl"},{line,1261}]},
{mc_worker_logic,make_request,3,
[{file,"src/connection/mc_worker_logic.erl"},{line,71}]},
{mc_worker,handle_call,3,
[{file,"src/connection/mc_worker.erl"},{line,44}]},
{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,607}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,639}]}]}
[*] Waiting for messages. To exit, press Ctrl+C
from mongodb-erlang.
I investigate this issue.
When using mongodb-erlang name
parameter is a must. That is why mongo:ensure_index(DBConn, <<"test">>, {key, {key, 1}})
won't work.
In shell, when you add index with db.test.createIndex({"test" : 1}, [])
- index name will be assigned from key parameter (name = test).
So, for your situation - just add name to the document:
mongo:ensure_index(DBConn, conversations, {key, {page_id, 1}, unique, true, dropDups, true, name, <<"page_id">>}).
from mongodb-erlang.
Please post me your call to mongo, which leads to the crash.
from mongodb-erlang.
This is my call to mongo:
mongo:ensure_index(DBConn, conversations, {key, {page_id, 1}, unique, true, dropDups, true})
I called it immediately below mongo connect.
By the way, please apologize for the delay in response.
from mongodb-erlang.
I tried your method, didn't work.
Do you have any idea about this issue?
from mongodb-erlang.
Please - post you call to mongo:ensure_index
from mongodb-erlang.
this is my mongo:ensure_index call:
mongo:ensure_index(DBConn, conversations, {key, {page_id, 1}, unique, true, dropDups, true, name, <<"page_id_1">>})
and crash log
=ERROR REPORT==== 9-Jun-2015::18:29:09 ===
** Generic server <0.94.0> terminating
** Last message in was {ensure_index,conversations,
{key,
{page_id,1},
unique,true,dropDups,true,name,
<<"page_id_1">>}}
** When Server state == {state,#Port<0.2735>,45084,<<>>,
{conn_state,unsafe,master,cake_development}}
** Reason for termination ==
** {function_clause,
[{mongo_protocol,'-put_message/3-lbc$^0/2-0-',
[{name,<<"page_id_1">>,unique,true,dropDups,true,key,
{page_id,1},
ns,<<"cake_development.conversations">>},
<<>>],
[{file,"src/core/mongo_protocol.erl"},{line,49}]},
{mongo_protocol,put_message,3,
[{file,"src/core/mongo_protocol.erl"},{line,49}]},
{mc_worker_logic,'-encode_requests/2-fun-0-',3,
[{file,"src/connection/mc_worker_logic.erl"},{line,22}]},
{lists,foldl,3,[{file,"lists.erl"},{line,1261}]},
{mc_worker_logic,make_request,3,
[{file,"src/connection/mc_worker_logic.erl"},{line,71}]},
{mc_worker,handle_call,3,
[{file,"src/connection/mc_worker.erl"},{line,44}]},
{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,607}]},
{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,639}]}]}
from mongodb-erlang.
May be you should try to set name as key? <<"page_id">> instead <<"page_id_1">>
from mongodb-erlang.
I tried both cases and they both crashed. Does this issue relate to my mongo version?
Thanks
from mongodb-erlang.
I do not test ensure index on 2.6.5, so I can't answer. It will be good - if you test your code on newer version of mongo.
from mongodb-erlang.
I will upgrade mongo and report back to you asap!
On Jun 9, 2015, at 6:58 PM, Valery [email protected] wrote:
I do not test ensure index on 2.6.5, so I can't answer. It will be good - if you test your code on newer version of mongo.
—
Reply to this email directly or view it on GitHub #64 (comment).
from mongodb-erlang.
Thanks!
from mongodb-erlang.
Related Issues (20)
- It doesn't seem to support 4.2
- Generic server terminating HOT 4
- Issue connecting to ReplicaSet HOT 2
- Issue connecting to ReplicaSet HOT 7
- Failed to update package rebar_ct from repo hexpm HOT 3
- Are distinct and aggregate command supported? HOT 2
- Maintenance plans? HOT 2
- MongoDB 4.2 cluster "Can't pass authentification" in 2nd erlang node HOT 8
- API Consistency Question HOT 1
- Connection Pool Issue HOT 2
- How to use SSL? HOT 2
- Is collation supported?
- undefined function erlang:get_stacktrace/0 HOT 1
- Exceeded memory limit for $group, but didn't allow external sort. Pass allowDiskUse:true
- Add support for MongoDB 6.X+ HOT 15
- How can I create/drop a collection using the driver HOT 1
- Master-slave switchover error
- Can't canonicalize query :: caused by :: unknown operator: $maxDistance
- OP_QUERY is no longer supported HOT 1
- How to add limit in find function in mongo_api call
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongodb-erlang.